Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
hi Jim,
Try this program, it samples every 0.1sec and displays the average of 5 samples every 0.5sec.
Use the remmed out values for BOTH the TIMER1 values when you program a PIC.
TMR1H = 0xfe ''0xcf 'FFFF - CF2C = 30D3 == 12500 * 8 = ~ 0.1 sec/intr
TMR1L = 0xfe ''0x2c
NOTE: these TIMER1 values are for a 4 MHz xtal.!
also make this =0
Define SIMULATION_WAITMS_VALUE = 1 'make this =0 for programming a PIC
Convert the LCD PORT pins to suit your project.
For my details look at my forum profile.
ahh, did not see that... maybe this could be something to do with it???
would it just be a matter of seeing if removing:
TMR1H = 0xfe
TMR1L = 0xfe
and replacing with:
TMR1H = 0xcf 'FFFF - CF2C = 30D3 == 12500 * 8 = ~ 0.1 sec/intr
TMR1L = 0x2c
cheers...
hi Jim,
Please confirm the frequency of the PIC crystal that you are using
The one above is for a 4mHz xtal and the TMR1H = 0x3c TMR1L = 0xb0 is for a 16mHz.
These values are ONLY for the sim
TMR1H = 0xfe
TMR1L = 0xfe
EDIT:
Where is the RW pin of the LCD connected too.?
also what difference does the config word (2007h) make when programming the PIC with the OS software? i have been told to set it to 3f72 though the default was 3f71...
could be part of the fault?
will iterally try attaching my LCD to ground now, see wat occurs...
at the moment it is displaying but not entirely correctly, just a solid top line and nothing on the bottom...
my theory too because a couple of the sample things were running ridiculously fast but i slowed them down and it worked...
how would i slow the headers down or should i just get rid of them?
really thanks for this
i am just concidering if i cant get this going in the next hour or so just cutting my losses and finding a way of adapting the lcd sample that comes with it and doing the maths to get it to go between 0.5 and 3.7V and merely display 0.0-20.0L... better than nothing
Lcdcmdout LcdClear 'clear LCD display
Lcdout "Fuel Level " 'text for the line 1
If lit < 10 Then
Lcdout "<50% Fuel "
Endif
If lit < 5 Then
Lcdout "Low Fuel: <25% "
Endif
If lit < 2 Then
Lcdout "EMERGENCY FUEL "
Endif
WaitMs 5 '000
Lcdout "EMERGENCY <10% "
Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
Lcdout "Volume: ",
If lit < 10 Then Lcdout " ",
Lcdout #lit, ".", #dec, " L" 'formatted text for line 2
WaitMs 1 '00 'larger value should be used in real device
Goto loop 'loop forever
tried the above to get the top line to display "<50%" when fuel falls below 10L then "Low fuel" when it falls below 5L etc etc but it just seems to run them all at once... maybe i need to include an interupt somewhere?
loop ' Start of endless loop
... take fuel readings here...
' Detemine fuel status here, print it out.
Lcdcmdout LcdClear 'clear LCD display
Lcdout "Fuel Level: " 'text for the line 1
If lit =< 2 Then
Lcdout "EMERGENCY FUEL "
Endif
If lit > 2 AND lit < 5 Then
Lcdout "<25% "
Endif
If lit => 5 AND < 10 Then
Lcdout "<50% Fuel "
Endif
WaitMs 5 '000
' Here's a problem: after determing and printing your fuel status above,
' you just print this next line out without a conditional
Lcdout "EMERGENCY <10% " ' Try using "FUEL GOOD, >50%" here to indicate OK fuel status
Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
Lcdout "Volume: ",
If lit < 10 Then Lcdout " ",
Lcdout #lit, ".", #dec, " L" 'formatted text for line 2
WaitMs 1 '00 'larger value should be used in real device
Goto loop 'loop forever
[END CODE]
Hope this helps.
kenjj