Continuous Rotation Servo
jessica
Posts: 8
Hello everybody
I'm new to this forum, my name is jessica. I live in France and I'm interested in robotics.
I'm studying servo right now with the parallax usb oscilloscope and I have a question about this spin code
found on #900-00008-CRservo pdf:
ServoRotation.spin
I don't understand why we have to add and subtract 200 (see bold underlined code) ?
I can't see any difference with the scope (even zooming) if I use the three times:
Can someone explain this to me ?
Thanks for your help and understanding.
jessica
I'm new to this forum, my name is jessica. I live in France and I'm interested in robotics.
I'm studying servo right now with the parallax usb oscilloscope and I have a question about this spin code
found on #900-00008-CRservo pdf:
ServoRotation.spin
CON _clkmode = xtal1 + pll16x ' System clock → 80 MHz _xinfreq = 5_000_000 PUB CenterServo | tInc, tc, tCtr, tCw, tCcw, t ctra[noparse][[/noparse]30..26] := %00100 ' Configure Counter A to NCO ctra[noparse][[/noparse]8..0] := 0 frqa := 1 dira[noparse][[/noparse]0]~~ tInc := clkfreq/1_000_000 ' 1 µs increment tC := tInc * 21_500 ' Low pulse tCtr := tInc * 1500 ' Center pulse = 1.5 ms tCw := tInc * 1300 ' Clockwise fast = 1.3 ms tCcw := tInc * 1700 ' Counter-Clockwise fast = 1.7 ms t := cnt ' Mark counter time repeat 100 ' Repeat PWM signal 100x phsa := -tCw ' Set up clockwise fast pulse [b][u]t += tC[/u][/b] ' Calculate next cycle repeat waitcnt(t) ' Wait for next cycle (20 ms) repeat 100 ' Repeat PWM signal 100x phsa := -tCtr ' Set up the center pulse [b][u]t += (tC + 200)[/u][/b] ' Calculate next cycle repeat waitcnt(t) ' Wait for next cycle (20 ms) repeat 100 ' Repeat PWM signal 100x phsa := -tCcw ' Set up counter-clockwise fast pulse [u][b]t += (tC - 200)[/b][/u] ' Calculate next cycle repeat waitcnt(t) ' Wait for next cycle (20 ms)
I don't understand why we have to add and subtract 200 (see bold underlined code) ?
I can't see any difference with the scope (even zooming) if I use the three times:
t += tC
Can someone explain this to me ?
Thanks for your help and understanding.
jessica
Comments
I'm not totally sure, but it looks like the code is first turning the servo clockwise increasing speed (+200), then counter-clockwise, decreasing speed.
I could be wrong tho'!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
Welcome to the forum
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Where am I? Where am I going? Why am I in a handbasket?"
John Abshier
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
I picked up the servo32v7 object and it works fine with CR servo.
But I have problems using standard servo ...
I'll try to search in the forum