Hi,
I'm making a display unit for my car using a serial LCD screen, some sensors and a 16F877a. So far I've figured out most of my problems using the search function but this has me baffled.
I've built a circuit which creates a 5-1v output for 0-100% of fuel level sensor travel. I wrote code for it and it displays 1-99%. Good enough.
So I copy the code and variables into the main program which has the rest of the code for the other parameters I'm showing like coolant temp, oil pressure and such. That program runs fine except for the fuel level part. It displays either 36 or 45 for a split second before display the correct number then writing 36 or 45 as the program cycles again. It does this each time the program cycles. I've removed the lookdown2 tables and set fuel2 and fuel4 to be 25 each so it should display just plain 50 but even then 36 or 45 still flash up.
My question is what is causing this and how can I fix it?
I've made sure #fuel isn't being sent out anywhere else in the program. I'll explain the code but you guys shouldn't need it. The code is below.
It uses 2 lookdown2 function depending on where the fuel sender is. If one table's maxed out it, that's automatically set to the highest value in the lookdown2 table. It then adds the output of the two tables to and displays it.
Thanks.
Code:FUELlevel: ADCIN 3, rawfuel if rawfuel > 511 then fuel1 = rawfuel/4 fuel3 = 253 else fuel3 = rawfuel/2 fuel1 = 129 endif lookdown2 fuel1, >[254,252,249,246,243,241,238,235,_ 232,230,227,224,221,219,216,213,_ 210,207,205,202,199,196,194,191,_ 188,186,183,180,177,175,172,169,_ 167,164,161,159,156,154,151,148,_ 146,143,141,138,136,133,131,129], fuel2 lookdown2 fuel3,>[253,248,243,239,234,230,225,221,_ 216,212,208,204,199,195,191,187,_ 184,180,176,172,169,165,162,158,_ 155,152,149,146,143,143,140,137,_ 134,132,129,127,124,122,120,118,_ 116,114,112,111,109,108,106,105,_ 104,103,102,101,100,99], fuel4 fuel= fuel2 + fuel4 if fuel <100 then serout Portd.2, N9600, [017, 015, 003] serout Portd.2, N9600, [" "] else serout Portd.2, N9600, [017, 015, 003] endif if fuel <10 then 'serout Portd.2, N9600, [017, 015, 003] serout Portd.2, N9600, [" "] endif serout portd.2, N9600, [#fuel] goto fuellevel
Bookmarks