CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help on display code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chin0609



Joined: 13 Sep 2011
Posts: 18

View user's profile Send private message

Help on display code
PostPosted: Sat Nov 05, 2011 6:52 am     Reply with quote

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();  }

}
}             
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Nov 05, 2011 8:49 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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