PDA

View Full Version : servo pulse problem...



tonkgang
- 1st April 2006, 16:59
hye.. i am newbie here and this is the first time ever i joined a forum in the net. first of all, sorry 4 my poor english..

a little question. is there a limit number of pin for microcontroller to generate pulse? i am using pic16f877 with a 4Mhz oscillator to drive a servos. i started with the code for centering 8 servos and the problem is when i checked the pulseout signal with a oscilloscope, the delay between pulse (1.5ms) is about 40ms. how could this happen?

here is my code:

b0 var byte
b1 var byte
b2 var byte
b3 var byte
b4 var byte
b5 var byte
b6 var byte
b7 var byte
b8 var byte
b1 var 150
b2 var 150
b3 var 150
b4 var 150
b5 var 150
b6 var 150
b7 var 150
b8 var 150

trisb = %00000000
portb = %00000000


init:
pulsout portb.0, b1
pulsout portb.1, b2
pulsout portb.2, b3
pulsout portb.3, b4
pulsout portb.4, b5
pulsout portb.5, b6
pulsout portb.6, b7
pulsout portb.7, b8
pause 20
goto init

end
------------------------------

is it microcntrlr problem or my code or anytihng else that i dont know?
sorry for being dumb. i am new to this pic and picbasic thing.
appreciate any helps

sayzer
- 3rd April 2006, 06:43
Try the little experiment below if you could.
Also, if you can, use 20Mhz OSC and modify the timing accordingly.


TRISA = 0
TRISB = 0
TRISC = 0
TRISD = 0
TRISE = 0


b var byte[8]

for b[8]=0 to 7
b[b[8]]=150
next b[8]



init:
pulsout portb.0, b[0]
pauseus 2250
pulsout portb.1, b[1]
pauseus 2250
pulsout portb.2, b[2]
pauseus 2250
pulsout portb.3, b[3]
pauseus 2250
pulsout portb.4, b[4]
pauseus 2250
pulsout portb.5, b[5]
pauseus 2250
pulsout portb.6, b[6]
pauseus 2250
pulsout portb.7, b[7]
pauseus 2250

'Total pause for each servo is approx. 18mS (~50Hz)

goto init

tonkgang
- 3rd April 2006, 12:45
thankz so much sayzer for showing me the other way to solve the problem. i dont try it yet. hope it works for this time.

can u explain to me why such problem occurs in my code?

tonkgang
- 7th April 2006, 04:35
er one more newbie questions.. why the servo position its shaft at outmost left for 2.0ms pulseout and 1.0ms pulseout position the servo shaft at outmost right?

Acetronics2
- 7th April 2006, 09:44
er one more newbie questions.. why the servo position its shaft at outmost left for 2.0ms pulseout and 1.0ms pulseout position the servo shaft at outmost right?

Hi, tonk

The same question : why do we drive on the right side in France and on the left side in England ...

Some times ago there were "normal" servos and "reverse" servos ... then went the programmable radios ... and the mechanical problem disappeared.

Alain

tonkgang
- 7th April 2006, 16:12
never know that. thanks alain

then again.. is there a limit no. of pins to generate pulse? i have read somewhere before this which say not to exceed 8-10 servos for each microcontroller. correct me if i'm wrong..

thankz again