Hi All,
After my successful Glow igniter project I have now moved onto trying to make an all in one setup / testing unit using a 16F876A and a Hitachi LCD module.
I have been able to output standard strings to the LCD (Startup instructions, menu etc) however I am now looking to get started with the servo and Receiver side of the project.
What I am looking to do is read in the pulsin value from the Rx and display it on the screen (sounds simple as I used this for the glow project), but this seems to not be working on the 16F.
What I get on the screen with the code below (stripped out the menu structures for testing) is the word "Pulse" with the space and then a strange alphanumeric single character which varies depending on the stick position of the transmitter (Clearly its picking up something).
My first though is that I'm using WORD to store the incoming value, however this has worked previously with the 12F PIC i used for the glow project.
Any ideas why my "P" does not output the correct value to the LCD? I would expect something between 100-200 as a numeric value.Code:@ DEVICE PIC16F876A,HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 20 '20 MHz Osc
DEFINE LCD_COMMANDUS 2000
TRISB = %00000001 'Set PortB.0 as input for Rx
Rx Var PORTB.0 'Rx input
servo var PORTB.1 'Servo output
P VAR word 'Pulse Input
pause 2000 ' Allow LCD to init
Main:
PulsIn Rx,1,P 'Read in Rx input
pulsout servo, P 'output to a servo connected on B.1
Toggle PORTB.5
LCDOUT $FE, 1, "Pulse"," ", P 'Output to LCD
LCDOUT $FE, $C0," ", P 'Testing on the second line
goto main:
End
Could it be that the 20Mhz crystal is too fast as this would give me a 2us resolution? (I noticed that the servo was moving in really tiny increments)
Many Thanks
Rob