![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
chin0609
Joined: 13 Sep 2011 Posts: 18
|
Help on display code |
Posted: Sat Nov 05, 2011 6:52 am |
|
|
Is there any wrong with the display code..this is because my LCD sometime can display and sometimes not..i guess there is some wrong with the code but i tested with virtual simulator no problem so what is the problem??
Code: | #include <16F877A.H>
#use delay (clock=20000000) // 20MHz
#include <lcd.c>
#FUSES HS,NOWDT, NOPROTECT, BROWNOUT, NOLVP, PUT
#define SERVO1 PIN_c1
#define led_green PIN_d1
#define led_red PIN_d0
int8 i; // looping
void nocar()
{
for (i=0;i<30;i++) //0 deg
{
output_low(led_green);
output_high(led_red);
output_high(SERVO1);
delay_us(1500);
output_low(SERVO1);
delay_ms(18);
}
delay_ms(200);
lcd_init();
lcd_putc("\fDoor Closed");
lcd_putc("\nScan Your Card");
}
void car()
{
for (i=0;i<30;i++) // 90 deg
{
output_low(led_red);
output_high(led_green);
output_high(SERVO1);
delay_us(2000);
output_low(SERVO1);
delay_ms(18);
}
delay_ms(200);
lcd_init();
lcd_putc("\fDoor Opened");
lcd_putc("\nYou Can Go Now");
}
void main()
{
while(1)
{
if(input(PIN_C0)) //Sensor input
{ nocar(); }
else
{ car(); }
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9171 Location: Greensville,Ontario
|
|
Posted: Sat Nov 05, 2011 8:49 am |
|
|
Why blame the code ? If, and it's a BIG IF, it worked in the 'simulation', your code may be fine as 'simulators' don't really care about important details like power supplies, wiring, contrast adjustments,etc.
Does it fail in the same spot or random ?
What else is happening when it fails ?
Does the screen go 'funny' or just blank?
I'd trim down your code to a simple 'hello world' program and be sure it's not the hardware.
Have you wired the LCD up according to the mfr?
Do you have proper contrast voltage ?
Are all 'control' pins wired right?
Is ALL the wiring good" No loose conenctions, proper solder joints, LCD mechanically supported ?
Power supply a good,stable +5 volts of at least 1 amp?(looks like you're using RC servos, so you needs AMPS not milliamps for the supply !)
oh yeah...you only need to run LCD_INIT() once before MAIN, not everytime you print to the LCD. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|