What is the recommended way of sending pulses to a stepper motor driver with more than 65535 pulses?
I used the following approach:
- physically wire FIO4 and FIO5
- setup a timer (PWM8) and counter
- reset the counter
- start the timer
- when the counter reaches a certain number below the target, stop the timer
- setup two timers, PWM8 and TimerStop
- use TimerStop to pulses the balance
Is there a better way as it stops then continue a little for the balance?
How fast are your pulses?
How many pulses do you need?
If you need 200,000 pulses, is it okay if you wind up with a little more or less as long as you know how many pulses?
I set the timer to 48mhz, divisor = 10, PWM8, that's the fastest before I get errors from the servo controller (GeckoDrive G320x). I assume it will be 48mhz/10/256 = 18.75 khz.
I am using a motor with a reducer, so 60,000 pulses per revolution. I need billions of pulses (seriously).
I am doing position control so the number of pulses must be exact. The GeckoDrive G320X responds to negative edge trigger.
UD series devices use a 16-bit counter, so 65535 is the max. You will need to run multiple groups of 65k. T-Series devices use a 32-bit counter which is limited to 4.2 billion.
Thanks for suggestion.
But will I be able to get an accurate pulse count by using a counter tied to a pwm8 timer? It seems there is no way to stop the timer without resetting the counter, so I set the pwm duty of 0%. Then read the counter to get the final pulse count. Will there be possible missing pulses? Btw, on startup I set pwm timer to 0% and reset the counter. Then set the pwm to 50%.
If I use several 65535, I won't be able to get smooth movement. So to answer your initial question regarding 200k pulses more or less, it is okay as long as I get an accurate count.
Please point me to sample codes or libraries if available. I hope you have prebuilt libraries that developers can just call to send X pulses with acceleration deceleration.
The hardware counters are pretty fast. As long as the signal is making through the logic thresholds the counter should not miss any counts.
It sounds like your plan is to run for the approximate amount of time necessary to get close to the desired number of counts. Then use the stop-timer to slowly approach the desired position. I think that is a good idea.
Timer mode 7 (Frequency Output) can change frequencies without glitches. It is important up update the timer, not reconfigure the timer. Normally timers are configured using eTCConfig and updated with eTCValues. Mode 7 has limited frequency range and resolution, so it is important to do the math to make sure you can get the range of values that you need with acceptable steps: https://labjack.com/support/datasheets/u3/hardware-description/timers-co...