PDA

View Full Version : Problem with servo and PIC16F616



Forkosh
- 18th November 2007, 03:10
Heres my problem :
I can get one of the modified servos to go forward ( a pulse of 100 ) and another one of the modified servos to go backward ( a pulse of 169) , only at the same time.

In other words

I can do :

servo1 var portc.3 'left Servo
servo2 var portc.2 'right Servo
forward con 100
backward con 169

pulsout servo1,Forward
Pulsout servo2,Backward
pause 18

to make one servo go backward and one go forward

BUT when I do just servo2 like follows

servo1 var portc.3 'left Servo
servo2 var portc.2 'right Servo

forward con 100
backward con 169
pulsout servo2,backward

it gets messed up and then it can only go in one direction and it doesn't reverse. But still for both of them at the same time it can do both , but not reverse one. I've tried different pulses with servo2 to get it to go backwards but its a no go.


What am I doing wrong???

I am using a PIC16F616 @ 4mhz and two modified HS-425BB servos.

mister_e
- 18th November 2007, 09:07
sure you didn't properly disabled the ADCs... did you? i don't see any line with ANSEL?

Datasheet, register 4-3, PDF page 34.

BrianT
- 18th November 2007, 21:22
The pulsout command just flips the state of the pin. If the pin were high it gets set low, if the pin were low it gets set high. Although you might expect your starting state to be always low, real world interference does happen and you must set the pin state low to be really sure. I spent days hunting low level random servo chatter in my UAV controller which was corrected by initialising the pins before calling pulsout..

1. Try presetting the state before calling Pulseout.
Low servo1
low servo2
pulsout servo1, forward
pulsout servo2, reverse

2. Current draw causes weirdo effects.
When you demand a large movement from one or more servos almost instantaneously the servos will draw high current. Although the servos draw small average current, they pull high instantaneous currents. About 1500 mA for a standard size analog servo and about 5000 mA for a digital servo (as measured on my JR servos). This can cause your power supply to sag and give you weird outputs. I always drive my RC logic from a separate power supply to the servos to minimise this and stagger servo operation with the maximum possible delay between each servo movement.

HTH
Brian