Attempting to read 3x R/C servo pulses.
In the few weeks since purchasing PBP I have so far learned several basics, including how to use Darrel Taylor's BarGraph.INC, etc. and have now run into this problem:
Code:
; Date: July 2010
; File name: test.pbp
; Compiler: PicBasic Pro V2.6
; Editor: MicroStudio V3.0.0.5
; Processor: 16F877A
; ----------------------------------------------------------------------------
DEFINE LCD_DREG PortB ; Use Port B for all bus lines
DEFINE LCD_DBIT 4 ; (4 = 4-bit bus; 0 = 8-bit bus)
; Connect PIC pins 37 ~ 40 (B.4 ~ B.7)
; to LCD pins 11 ~ 14 (D4 ~ D7)
DEFINE LCD_EREG PortB ; Put the Enable Register on Port B
DEFINE LCD_EBIT 3 ; Connect PIC pin 36 (B.3) to LCD pin 6 (En)
DEFINE LCD_RSREG PortB ; Put the ReSet Register on Port B
DEFINE LCD_RSBIT 2 ; Connect PIC pin 35 (B.2) to LCD pin 4 (RS)
DEFINE LCD_BITS 4 ; Set bus size (4 = 4-bit bus; 8 = 8-bit bus)
DEFINE LCD_LINES 4 ; Set number of LCD lines (1 ~ 4)
DEFINE LCD_COMMANDUS 2000 ; Set 2-millisecond command period
DEFINE LCD_DATAUS 50 ; Set data delay period
DEFINE LCD4X20 1
DEFINE OSC 20
LCDOUT $FE, 1
PAUSE 200
CMCON = 7
ADCON1 = 7
throttle VAR word
rudder VAR word
gear VAR word
LOW PortC.4 ; R/C landing gear output pin
LOW PortC.5 ; R/C rudder output pin
LOW PortC.6 ; R/C throttle output pin
; ----------------------------------------------------------------------------
start:
PULSIN PortA.3, 1 , throttle
PULSOUT PortC.6, throttle
throttle = throttle *2
LCDOUT $FE, $80, "Thtl = ", #throttle /1000, ".", #throttle DIG 2, #throttle DIG 1, "mS"
PULSIN PortA.4, 1 , rudder
PULSOUT PortC.5, rudder
rudder = rudder *2
LCDOUT $FE, $C0, "Rddr = ", #rudder /1000, ".", #rudder DIG 2, #rudder DIG 1, "mS"
PULSIN PortA.5, 1 , gear
PULSOUT PortC.4, gear
gear = gear *2
LCDOUT $FE, $94, "Gear = ", #gear /1000, ".", #gear DIG 2, #gear DIG 1, "mS"
GOTO start
END
The servos are a tad sluggish and their torque is somewhat lower than normal. If either one of the three input signals is disconnected, then the other two servos tend to move even slower or not at all. I'm thinking that perhaps I should be using Darrel's interrupt.INC, but I'm not sure how to implement it with three separate R/C inputs.
Could someone perhaps tell me if it is indeed possible to have as many as three PULSIN statements like this?
Thank you for your help.