OK, anthor problem...
I'm trying to run an RC servo from a PIC12F683. I'm using pin 0 as output and pin 1 as input (from receiver)
As long as there is a signal from pin 1, the PULSOUT will output the PULSIN value. When no signal is present (PULSIN=0) then PULSOUT should go to a failsafe value.
Situation: When the signal is present, the PULSOUT sends the PULSIN value, but when PULSIN = 0, the PULSOUT does send the proper value, but in 1/2 second intervals (it pulses the value about every 0.5 sec). I can't figure out why!!!
here's the code:
oSCCON = %01100000 ' Ocs set to 4 MHz
TRISIO = %00000000 ' Set all ports to outputs, in this example
CMCON0 = 7 ' Analog comparators off
ANSEL = 0 ' Analog select set to digital, pg 69 data
ADCON0 = 0 ' A/D turned OFF, pg 68 of data
cont var word
failsafe var word
posoutput var word
posinput var word
usefailsafe var byte
pausetime var word
low gpio.0
low gpio.1
low gpio.2
low gpio.3
failsafe=80
pausetime=10
START:
;pulsout portb.4, failsafe
;pause 50
;goto start
GETSIGNAL:
pulsin gpio.1,1,posoutput
if posoutput=0 then goto runfailsafe
goto runnormal
runfailsafe:
pulsout gpio.0, failsafe
pause pausetime
goto getsignal
runnormal:
pulsout gpio.0, posoutput
pause pausetime
goto getsignal
Bookmarks