I’m having problems getting my program to read my encoder fast enough to be acurate (trying to get a shaft to turn 450 degrees). I need to have my motor stop at a count of only 10. I’m using a custom-made encoder that has only 8 slots per revolution. Unfortunately, Easy-C is as far as my skills and resources go, and the deadline for our class competition is fast approaching. Any Insight would be great.
I’m not sure about the program, but maybe the slots in the disk are not large enough. Also what are u using to count the slots as they go by? Maybe its not “seeing” the slots.
Once the Microcontroller “decides” to read an input (i.e. once your software starts issuing those instructions), the task almost certainly takes much less than a millisecond.
When an encoder connected to an intterupt port raises an interrupt, “servicing” that interrupt by doing something like incrementing a variable that tracks an encoder’s “tick” count should only take much, much, much less than a millisecond.
Your software that you load into the “user” part of the Vex Microcontroller is activated/run about once every 18.5 milliseconds, and gets to run for a big chunk of the the time between any one invocation and the next, but not all of it.
There is a timer in EasyC that you can use to record (in an array) when the ticks are seen by your part of the software and what the tick count is at each of those times. Do this for 10-12 ticks and and then report (via printf’s) those values.
To make this reasonably accurate, while the experiment is occuring, turn off all printing or other tasks that take a lot of time (a lot = more than a millisecond). Do the experiment a few times to see how consistent the results are.
Compare the results to what you would expect from pencil and paper calculations.
The result of this experiment should start to illuminate what is really going on and help you separate software problems from mechanical design and or sensor problems. Turning the motor/encoder by hand is probably a useful variation on this experiment.
Since you are only looking to achieve 1-1/4 turns of the shaft, make sure that you do not have the motor running at full speed or it will definately overshoot your target.
Here’s some more of the facts: I tested my custom encoder with the encoder test program and it read and displayed every single notch without skipping any numbers. This tells me the encoder works fine.
I have tried slowing the motor down, but it is doing a lot of work. So when I slow it down to where the program will read every notch, the motor won’t turn.