Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
But here's the big problem. The same timer could be used for other things as well - say like a measured pulse to a servo, or as the system clock. These are all happy co-existing but then you say multiply the frequency by 1000. This would need a timer pre-scaler change and, in turn, this would mess up everything else.So its 'easy in theory' but complex in practice.
Probably not the most efficient, accurate or eloquent but can't you drive variable freq signals in appcontrol. Set the pin high/low depending on the frequency you want with clockGetus(..) and a pre-cached CLOCK_TICK value?You can probably also use the timer.h routines as well. Jack
However: I think you may be asking this question with regard to driving stepper motors via an L297 where one pulse = one step. In which case, IMHO, you shouldn't be using PWM or any other form of automatic signal generation to drive the motors anyway- particularly if you don't have encoders. As this means you have no idea how many pulses have been sent. You are far better off just toggling the output pin yourself. You could of course do this via the scheduler if you want it to keep happening in the background.
-set the pin to high and get current time and store it in variable t1;-set a variable t2 = t1 + duty period(us);-set a variable t2 = t1 + period(us);-if current time >= t2 then pin_low;-if current time >= t3 then goto top;
Webbot, did you ever implement the software PWM in the library?Basically the software PWM for servos, but allowing the option to fully modify the square wave (frequency and duty cycle).
4. The counter idea is a good one, but it represents the reason why steppers aren't used in industrial robotics applications. You would thing that if you send 20 impulses to a stepper, it does 20 steps. It could... It definitely should. The fact is that it sometimes slips. So in power applications you need to add encoders. And if you add encoders, you might as well use brushless DC servos, as they're easier to control (although they require a breaking system). But for our normal everyday use, it should work perfectly.