Ricardoco said:
Just a chance this will help you...let me know
**broken link removed**
do a search (edit in I.E) in the above url for the word pulseout
thanks for that, the code has been taken from there 1 question? is this code using the a PVM function inside the PIC (for the pulsout)? or can this be achieved using any pic eg a 16f84?
DEFINE OSC 4
TRISB = %10000000 'portb is all outputs except portb.7 which has my direction switch
TRISD = %00000000 'set portd as all outputs
minValue con 60 ' set up the min and the max values for my pulseout
maxValue con 240 ' remember if you use a faster clock these have to be changed
'these just are the min and max range of motion for the servo
restperiod con 20 ' the servo needs a rest of about 18 mSeconds
pulseWidth var byte 'this is going to hold the length of pulsewidth that will be pulsed to the servo
pulseWidth = minvalue 'I initialized my starting position at the min
main:
if portb.7 = 1 and pulsewidth < maxvalue THEN 'if I push the switch and
'I haven't gotten to maxvalue yet
pulsewidth = pulsewidth + 1 'I add one to pulsewidth moving it towards max, try other numbers
endif
if portb.7 = 0 and pulsewidth > minvalue then 'if I am not pushing the button and I haven't
'gotten down to minvalue subtract one from pulsewidth
pulsewidth = pulsewidth - 1
endif
low portd.2 'bring pin low so that it can be pulsed high
pulsout portd.2, pulsewidth 'pulse my servo on portd.2 for pulsewidth time
pause restperiod 'pause for 20 mseconds
goto main