PDA

View Full Version : Servo reverse



bill_23
- 22nd February 2009, 05:03
Hello,
I have a question about reversing servos i am currently building a remote controlled boat that has a turret with a fishing pole with reel and everything on it (cool?) but i can only get my servos to turn one way. I have tried messing around with different values with pretty much everything but the most i could get was a fidget in the opposite direction. Here is my code.

symbol TRISB = 134
symbol TRISA = $85
symbol PORTB = 6
symbol PORTA = 5
poke TRISB,0
poke TRISA,255
main:
peek PORTA,B0
if bit0 = 1 then Go_Turret 'drive turret
if bit0 = 0 then main 'check again
Go_turret:
peek PORTA,B0 'check portA values
if bit1 = 1 then turret_left
if bit2 = 1 then turret_right
if bit3 = 1 then pole_up
if bit4 = 1 then pole_down
goto main

turret_left: 'moves turret left
low 1 'should move clockwise?
pulsout 1, 1000
pause 10
goto main

turret_right: 'moves turret right
high 1 'should move counterclockwise?
pulsout 1, 1000
pause 10
goto main

pole_up: 'moves the pole up
low 2 'move servo clockwise?
pulsout 2, 1000
pause 10
goto main

pole_down: 'moves the pole down
high 2 'should move servo counterclockwise?
pulsout 2, 1000
pause 10
goto main

The manual says that the initial state of the pin determines the polarity of the pulse, so i added the LOW and HIGH values before it sends the pulse but I'm thinking that its not that easy. I have tried to adapt a sweeping program but i couldn't get it to run continuously, any help in getting them to turn the other way would be greatly appreciated.
Thanks

Acetronics2
- 22nd February 2009, 08:12
Hi,

First : Three big misunderstandings ...

1) LOW before PULSOUT is just to ensure the servo pulse will be positive. NEVER use "high" it could damage your servos ...

2) Servo positions ... 1000 µs is right, 1500 µs is centered, 2000 µs is left ( mainly - left and right can be inverted ) To change position, you must change pulse value ...

3) The Pulses MUST be sent regularly @ ~ 30-50 times per second. Even if the servo has to keep on its position.


Smooth movement will be chapter 2 ...

Alain

Nicmus
- 22nd February 2009, 12:41
Hi bill_23,

Unless you are using a 4o MHz oscillator you might want to revise your PULSOUT statements. For 4 MHz your PULSOUT resolution will be 10 µs.

Also depending on your servos (90º, 120° or 180°) and the desired range of movement you might want to change the 1000-2000 µs window to a narrower one. Keep in mind your 1500 µs pulse will be your center.

Regards,

Nick

tenaja
- 22nd February 2009, 14:58
3) The Pulses MUST be sent regularly @ ~ 30-50 times per second. Even if the servo has to keep on its position.
For clarification for the less experienced...

Alain is ONLY talking about old fashioned "cheap" analog servos. Most of the new digital servos (which aren't all that expensive, either) will accept a single pulse; they will go to that position and hold. I've used some in an application where the maintenance of an analog servo position was not practical.

Acetronics2
- 22nd February 2009, 17:48
Hi, Tenaja

It can be a trick ... but here, it is not "genuine planned" : the servo, receiving no new pulse, keeps position as a Failsafe ...

Not all brands do that ... so, it must be checked before use ...

Alain

bill_23
- 22nd February 2009, 19:56
Wow,
That was really simple, i was really getting hung up on this but i changed one side to 100 and one to 200 and it seems to work just how i want! This also got rid of the fidget in the opposite direction, except on a couple of the cheapo servos i am using but i just changed the 200 to a 190 and it stopped it from bouncing at the end.
Thank you all very much!
Now as far as Acetronics said

3) The Pulses MUST be sent regularly @ ~ 30-50 times per second. Even if the servo has to keep on its position. If it works now should i change it? I am using very cheap ($3) servos, and some ones from parallax and i assume they are analog.
Thanks again

Acetronics2
- 22nd February 2009, 20:06
Wow,
If it works now should i change it? I am using very cheap ($3) servos, and some ones from parallax and i assume they are analog.
Thanks again

Generally, if a µP program works as you expected ... Do not change anything until you have a VERY good reason to change it ...

AND Overall ... do not wipe off the first project until the new one has successfully passed ALL the "live" tests ...

Alain