encoder counts and PWM frequency
Hi!!
I have a new challenge [noparse]:)[/noparse]
I want to control the speed of the motor through a microcontroller and the thing is that I am not sure at what frequency should I work to generate the PWM signal.
The encoder of the motor makes 360 counts / revolution at a speed of 170 rpm.
The encoder has two output signals (in quadrature) and each of those are three pulses / revolution
for each shaft of the motor we obtain 12 pair of signals ...
now what I did was:
170 rpm / 60 = period 1
period 1··* freq = 360 counts ; f = 127 Hz
if I assume that it is correct I just have the possibility of using f = 122 Hz (after scaling the fcpu) and it would turn on a wrong number of counts ... I am a bit confussed ...
What do u think about it? Am I wrong?
I would be very thankful for any piece of advice
Have a good weekend
fang-wei
I have a new challenge [noparse]:)[/noparse]
I want to control the speed of the motor through a microcontroller and the thing is that I am not sure at what frequency should I work to generate the PWM signal.
The encoder of the motor makes 360 counts / revolution at a speed of 170 rpm.
The encoder has two output signals (in quadrature) and each of those are three pulses / revolution
for each shaft of the motor we obtain 12 pair of signals ...
now what I did was:
170 rpm / 60 = period 1
period 1··* freq = 360 counts ; f = 127 Hz
if I assume that it is correct I just have the possibility of using f = 122 Hz (after scaling the fcpu) and it would turn on a wrong number of counts ... I am a bit confussed ...
What do u think about it? Am I wrong?
I would be very thankful for any piece of advice
Have a good weekend
fang-wei
Comments
are you using two encoders to measure the motor's speed? why? (I see one 360 [noparse][[/noparse]count/rev] and one 3 [noparse][[/noparse]count/rev] encoder listed)
also, the math is a bit off. I'd recommend keeping units with everything and making sure the units cancel into what you're looking for.
170 [noparse][[/noparse]rev/min] * 1/60 [noparse][[/noparse]min/sec] = 2.833 [noparse][[/noparse]rev/sec] aka [noparse][[/noparse]Hz]
The period of this rotation is then 1/2.833 [noparse][[/noparse]sec/rev] or 0.3529 [noparse][[/noparse]sec/rev]
assuming a 360 [noparse][[/noparse]count/rev] quadrature encoder with 4x decoding. (so decoded encoder resolution is 360*4 = 1440 [noparse][[/noparse]count/rev] )
2.833 [noparse][[/noparse]rev/sec] * 1440 [noparse][[/noparse]count/rev] = 4079.5 [noparse][[/noparse]counts/sec]
Hope this helps,
Marty
I see... thanks Marty [noparse]:)[/noparse], and the 4x decoding is because you have to count the rise and fall flanks of each output signal?
So, the specs from the vendor say that the resolution is 360 counts / revolution. (The other information was that there are 3 pulses per shaft and per signal)
So, now to generate the PWM signal with the microcontroller, I could scale the frequency till 4 KHz. In order to measure the position of the motor, could be acceptable to say that each 1412 counts the motor makes a complete shaft?
maybe I am still making it harder than it is ...
Thanks
Have a nice day
fang-wei
·Ok, now that you can read the motor speed with the encoder,· (aka how many encoder counts per second) you need a servo loop to control the motor.· First find the motor's speed error.· (i.e. subtract the current speed from the desired speed.· be shure to use the same units.)· Next, multiply this error by some constant, this is the manipulation.· (this constant depends on the specific system and is usually found by experimentation, or careful modeling)··Finally, the·manipulation is used to determine how much power is sent to the motor.· In other words the duty cycle of the·PWM for the motor should be proportional to the manipulation that was calculated from the motor's speed error.·
I hope this helps.· I've just gone over the bare basics.· Try this stuff out, the information on more sophisticated servo loops is just a web search away.· (Google and Wikipedia is your friend )
best of luck,
Marty