Hello Forum,
I am using an Arduino Uno and a VNH5019 PID controller to drive a DC motor with an encoder.
I would like to use an event to to "step" the motor a certain rotation.
I was using a delay() to drive the pwm pin (pin 9 in this case), and this works. BUT,
I think I can get better control using a timer interrupt. I cannot use timer1 (the best choice) as it uses
pin 9 for the pwm part of things. I would like to be able to create a delay from .25 secs to 30 secs.
I.E. "step" this DC motor. time2 is 8bits, and hence a max count of 256. so if I want to have a delay of
3 seconds, the max count for this timer is reached in the millisecond range (approx 16 ms). So for me
to get a delay of 3 seconds, I would have to count up, clear and count up a BUNCH of times to
get a 3 second delay. I am using or would like to use a timer2 ISR interrupt. Any suggestions on using this counter or some other method?
complements to your web site (particularly the freq counter).
I can use timer2 to generate an interrupt no problem. The issue I have is that
i would like to move the motor a few encoder counts (uses a pin change interrupt for encoder counts), when my timer2 counts the desired amount, lets say every 2 seconds move the motor about 1/4 turn.
The code I use to move the motor doe not run when I try to use the timer2 interrupt. I think that I do not have other code that interferes with either timer1 (for pwm) or timer2 (tone().
Any suggestions on how to take a counted interval (using your 1uS timer2 count) of 2 seconds,
and move the motor?