This is now fixed. Thanks go to Darrel Taylor over at melabs for giving me a clue.
Repaired Code with less coments.
Code:
'****************************************************************
' *
'* Notes : DC motor ESC written for PIC12F683 *
'* : Input from RX - Throttle *
'* : PWM FET Driver Output *
'* : *
'****************************************************************
#CONFIG
__config _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _WDT_ON
#ENDCONFIG
Include "modedefs.bas"
ADCON0 = 0 'A/D Off
CMCON0 = 7 'Comparators Off
ANSEL = 0 'Set all Digital
osccon = %01100000 '4mhz
DEFINE osc 4 'Set oscillator to 4mhz'
DEFINE DEBUG_REG GPIO
DEFINE DEBUG_BIT 5
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1
DEFINE DEBUGIN_REG GPIO
DEFINE DEBUGIN_BIT 4
DEFINE DEBUGIN_MODE 1
rxin var GPIO.3 'input from rc receiver
txout var GPIO.2 'pwm output to driver
rxval var BYTE
adjp var byte
INPUT rxin
output txout
hold: 'wait here if the receiver is not up yet
pulsin rxin,1,rxval
if rxval=0 then goto hold
arm: 'receiver is up now make sure throttle is low
pulsin rxin,1,rxval
if rxval>115 then goto arm
main: 'Throttle is low now start looking for pulses
pulsin rxin,1,rxval
adjp = (((rxval - 110)*5)/14)*10 'normalize the pulses & convert for pwm
HPWM 1,adjp,1000
debug "Pulsewidth:",#adjp,10
goto main
Bookmarks