That’s fine, but it means you eat up a lot of processor just to check in on the encoder even if it isn’t moving. Then they built a state machine to track the encoder. Most of what I found required you to periodically call some function or set up a timer interrupt. So my goal was simple: I wanted something interrupt driven. I mention this because it is nearly impossible to read one of these flawlessly. If you were trying to do precision work, you should probably be looking at a different technology like an optical encoder. Also, these cheap mechanical encoders are terrible. There are many ways you can read a rotary encoder. I thought I’d share my code and the process of how I got there. How hard can it be to write the code yourself? How hard, indeed. Of course, reading an encoder isn’t a mysterious process. Unfortunately, Mbed OS doesn’t have a driver for an encoder and the first few third-party libraries I found either worked via polling or wouldn’t compile with the latest Mbed. Not the finest encoder in the land, I’m sure, but it should do the job. I needed a rotary encoder - I pulled a cheap one out of one of those “49 boards for Arduino” kits you see around. Unfortunately, that means that a lot of libraries and examples you can find don’t work with the newer system. There was a time when Mbed was pretty simple, but a lot has changed since it has morphed into Mbed OS. As you may have noticed, I’ve been working with an STM32 ARM CPU using Mbed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |