PDA

View Full Version : Servo does not move



ruijc
- 6th November 2007, 22:22
Greetings,

i've found a program to move a servo ( left and right ).

Did some minor modifications ( lcd pinouts ) and programmed my pic 16f84A.

However the servo does not move !

The LCD displays the position OK and the buttons work OK but there is no movement from the servo.
With an ohmeter i cannot sense any voltage also.

Is there something wrong with the program ?
Any ideas ?

This is the program:

pos var word ' Servo position
servo1 var PORTB.4 ' Alias servo pin

Low servo1 ' Servo output low
PORTB = 0 ' PORTB lines low to read buttons
TRISB = $fe ' Enable first button row
Pause 100 ' Wait for LCD to startup
Gosub center ' Center servo

mainloop:
If PORTB.5 = 1 Then
Gosub left
Endif
If PORTB.2 = 1 Then
Gosub center
Endif
If PORTB.6 = 1 Then
Gosub right
Endif

servo1 = 1 ' Start servo pulse
Pauseus 1000 + pos ' Delay for servo pulse high time
servo1 = 0 ' End servo pulse
Pause 16 ' Servo update rate about 60Hz
Goto mainloop ' Do it all forever

left:
If pos < 2000 Then
pos = pos + 1
GoSub display ' Display new position on LCD
Endif
Return

right:
If pos > 1000 Then
pos = pos - 1
GoSub display ' Display new position on LCD
Endif
Return

center:
pos = 1500
GoSub display ' Display new position on LCD
Return

display:
Lcdout $fe, 1, "Position = ", #pos
Return

end

thanks

HenrikOlsson
- 7th November 2007, 06:51
Hi,
You have the servo on portB.4 but then you do

TRISB = $fe ' Enable first button row

Which sets that pin to input. So when you do:


servo1 = 1 ' Start servo pulse
Pauseus 1000 + pos ' Delay for servo pulse high time
servo1 = 0 ' End servo pulse
Pause 16 ' Servo update rate about 60Hz
Goto mainloop ' Do it all forever
PortB.4 won't go high since it's set to be an input.

Either change your servo1 = 1 to HIGH servo1 and servo1 = 0 to LOW servo1 or make sure that PortB.4 is setup as an output.

/Henrik Olsson.

ruijc
- 8th November 2007, 19:04
that's it !

i missed that !

thanks . it's working fine now.

.

ruijc
- 10th November 2007, 11:13
I have all things working and changed the code to be more complete.

But still having some issues.

I've noticed that the value for the servo to be centered the pos must be 400 ( even with the original code )

for far left the value must be 1300

but for far right 0 is not enough.

i've tryed this but doesnt work...

right:
If pos > -100 Then
pos = pos - 10
Endif
servo1 = 1
Pauseus 1000 + pos
servo1 = 0
Pause 16 ' Servo update rate about 60Hz
Return

any ideas ?
and why arent the original values working for me ? I've seen many servo programs and all have the same values for center.

thanks

Acetronics2
- 10th November 2007, 12:27
Hi, Ruijc

I think you are "mixing" and misunderstanding some servo parameters here ...

so, before going further ... what is your servo model and brand ??? and what is your radio set ???

Alain

ruijc
- 10th November 2007, 13:31
Hi Alain,

thanks for your help.

i'm currently using a futaba's S148 servo.

My idea is to test any futaba and hitec servos ( digital and analog ).


.

Acetronics2
- 10th November 2007, 18:24
Hi, Ruijc

héhé ...

Futaba S148 !!! the "mechanical neutral" ( half of the two geometric max positions ) ... corresponds to ~ 1300 µS ( an heritage of the old Robbe/Futaba join venture ! )

Now ... YOU must place your servo arm to have your "application neutral" with a trustable 1500µS pulse !!! ( remember Xtals are NOT generating exactly their nominal frequency ... especially for "common" ones )

Moreover consider Futaba "analogic" servos have a quasi-linear positionning in the 900-2100 µS range .

Outside those limits, you can send from 200 to 2500 µS pulses ... but with no more linearity at all !!! Specially at low values ... ( I did those tests to try to get 180° travel without any mod to the servos ...)

to fill the "bottle" ... your servos have a deadband of ~ 4/5 µS ... around their position, so, don't ask them to show you 1µS steps !!!

I did not test any Hitec servos ... so don't ask me for them !!!

Alain

ruijc
- 11th November 2007, 19:01
Got it Alain,

just changed the xtal from 4Mhz to 8Mhz and is was easy to tune !

thanks

.

ruijc
- 12th November 2007, 13:37
One last question:

i found my 7805 getting very hot when my circuit is looping through auto motion.

The code is safe in terms of not letting the servo go to extremes and overloads the circuit.

It's just moving arround ( left and right ) on it's own.

Is there a way to control it's temperature ?

I'm trying to avoid using a heatsink because it will be in a small box.

any ideas ?

HenrikOlsson
- 12th November 2007, 16:05
The 7805 is getting hot because your supplying current to the servo thru it. Even though the motor is "just turning" it consumes much, much more current than the PIC. When you start "loading" the servo it will draw even more current and will probably overheat the regulator. Basicly you have four options.

1) Mount a heatsink.
2) Reduce the powersupply voltage. That will reduce power dissipation in the regulator.
3) Use a switching type regulator instead of a linear (78xx type)
4) Only run the PIC on the regulated voltage. And the servo on the raw, unregulated voltage.

Number 4 may not be an option depending on your actual supply voltage and max voltage that the servo can take.

/Henrik Olsson.

Acetronics2
- 12th November 2007, 16:29
Hi,Ruijc

Why not run it with 4 or 5 old NiCd cells ??? if 12v batt used, only a switching regulator will do it ( LM 2575 or 2576 i.e )

Alain

ruijc
- 12th November 2007, 17:25
thanks Alain and HenrikOlsson,

all good tips ;)

at my workbench i have a 12V/3A power supply but i designed to have a normal 9v battery.

#1 Since the 9v battery does not have that much voltage/current the regulator will not over heat ( or will it ? )

#2 The nicad pack is a good idea running the servo directly from it and keeping the regulator for the pic only . But since it will be used at the field and there are many different packs available, i'm affraid that a lipo pack would burn up the regulator :s


.

HenrikOlsson
- 12th November 2007, 19:14
Yes, the regulator will run cooler with an input of 9V instead of 12V. With 12V input and pulling, say, 200mA the regulator dissipates (12-5)*0.2=1.4W and with 9V input it's (9-5)*0.2=0.8W. If the regulator will overheat or not depends on the actual current and the ambient temperature. A standard 9V battery may not be able to supply the current needed for the servo though and in any case it won't last for very long.

/Henrik.