Hello all,
I would like to control the speed of a step motor. Having done some RTFM, I have successfully used PWM to overvoltage the motor and I am now looking into slowly increasing the frequency of the steps.
Keeping to simple math, best results are obtained from using a formula of the sort
where x is a base delay between stepping and n is the number of steps that have been completed so far.
Now, the addition is ok (addwf) and multiplication by the constants is ok (rlf), it's the division that has me stumped (I have only in the past couple of months started using asm). I have trawled through the sample code graciously maintained over at piclist.org, and everything is for 16 and 32bit variables. I am using a clock pulse to determine the delay and anything over 8bit accuracy is overkill.
Any pointers as to how to approach this division?
Thanks for your help.
Spiros
I would like to control the speed of a step motor. Having done some RTFM, I have successfully used PWM to overvoltage the motor and I am now looking into slowly increasing the frequency of the steps.
Keeping to simple math, best results are obtained from using a formula of the sort
Code:
y = x + [(2*x) / (4*n+1)]
Now, the addition is ok (addwf) and multiplication by the constants is ok (rlf), it's the division that has me stumped (I have only in the past couple of months started using asm). I have trawled through the sample code graciously maintained over at piclist.org, and everything is for 16 and 32bit variables. I am using a clock pulse to determine the delay and anything over 8bit accuracy is overkill.
Any pointers as to how to approach this division?
Thanks for your help.
Spiros