Variable frequency pulse generation - low speed

Hi,

I’m looking for a way to generate pulses at low frequency with the SVP-1284.
I’ve been reading on Timers and interrupt - very new at this stuff - and from what I gathered I can only go so slow; ie not slow enough.
Anyone could point me in the right direction to generate 150-200 pulses per seconds, all the way down to one pulse every 10 minutes - and variably so, meaning that the pulse frequency is constantly updated in my main loop?

The goal is to control a stepper driver at variable speed for extended period of time.

I was thinking of using a compare condition at the beginning of the loop like that:

if ((getCurrentTime-getLastTime) >= varStep){
pulseOut
}

…but my loop already takes 2-3ms to complete, and it’ll take much longer when I add more functions - so that would limit the maximum amount of steps I can generate. I’m not too worried about the steps being “out of sync” by a few ms, but I want to be able to pulse at least at up to 150Hz, so my loop could not take longer than 6ms to complete otherwise it’ll limit the max speed of the motor.

Thanks,
-Ariel

Hello, Ariel.

It looks like you are on the right path. You might consider using a hardware PWM for the fast pulses in conjunction with the polling method you described for the less frequent pulses. If you run into any problems, please post your code. I would be happy to take a look at it.

- Jeremy