If functional, this is a subset of what you want as it doesn't decelerate the stepper but it could be modified to do so. You just need to choose a 16-bit timer which has an OC brought out to a pin. It's for a Mega2560 but with a few changes should be adaptable to an Uno. This compiles but I haven't checked it on a scope. Is there any reason this will not work? I am hoping to prototype it using a 328P Timer1, but hope it can eventually run on an ATTiny-1604 TimerB.Īny comments or problems with this approach? When a stop is commanded, the compare register is updated using values read from the table in reverse order, decelerating the motor using the acceleration profile in reverse. The motor therefore continues to move at maximum speed until a stop is commanded. The above repeats until the last entry from the table is loaded into the compare register, at which time the motor is moving at maximum speed, so that last table entry is added to the compare register on each update. In this way, the active edge of each step pulse is created by hardware (so very low jitter), the counter counts up continuously, and the compare value always stays ahead of the counter (assuming interrupts are handled promptly), except for the brief period between the compare and the associated interrupt. The interrupt handler will then reset the output pin, load the NEXT (shorter) entry from the table, add that value to the previous compare value, and write that value into the compare register. I assume I can also generate an interrupt when the compare match occurs. This will trigger a step from the stepper driver hardware. I am assuming the timer can be programmed to generate a rising edge on an output pin when the counter reaches the compare value. The compare register would be set to the value in the first table entry, which is the longest delay. ![]() To start motion, the timer would be cleared, then started counting at a rate of 1uSec/count. The profile provides a step-by-step acceleration ramp from 0 RPM up to the motors maximum RPM. ![]() The acceleration profile is stored in a 225-entry lookup table, with each entry being a single step period, in uSec. I'm hoping someone here knows the Arduino timers well enough to tell me if what I'd like to do is possible, before I take the time to study the datasheet to understand the specifics. The way I'd like to do it is to use a 16-bit timer with compare to generate the pulses to the external stepper driver. I need to drive a stepper motor with a very specific acceleration/deceleration profile.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |