problem with LCD; mikroc-pic

Status
Not open for further replies.

mailus

Full Member level 4
Joined
Mar 6, 2012
Messages
234
Helped
7
Reputation
16
Reaction score
7
Trophy points
1,308
Location
-
Activity points
2,706
0-99Min pre-settable timer.
pic16f84A,4Mhz osc,mikroc pic.

i attached my dsn file and c code....in this code msg2 is always blinking it doesn't show the value correctly and in real time the msg 2 display counting 0-9 and start again 0-9 continuously without any input.
 

Attachments

  • 0-99min.zip
    17.5 KB · Views: 106
Last edited:

Where is the hex file? Where is the LCD code? It displays nothing. You have to add pull down resistors to the switches.. Post the proper files.

values of s, o, t are wrong. There are only 2 buttons connected to RB6 and RB7. so any two of s, o, t should be 6 and 7.
 
Last edited:

i am sorry internetuser2k12 ,
i uploaded wrong file... now i changed the file with hex file....i used s,t,o for define pin in button function...
 

Attachments

  • 0-99min.zip
    17.5 KB · Views: 100

What are the problems you are facing? Explain a little.

Check this file.

What should be done to see msg2?

---------------------------Update---------------------------

Check this file.
 

Attachments

  • 0-99min v2.rar
    15.5 KB · Views: 102
  • 0-99min v3.rar
    15.5 KB · Views: 111
Last edited:
Reactions: mailus

    mailus

    Points: 2
    Helpful Answer Positive Rating
In my program user input is always blinking and msg2 also blinking...how to stop this blinking.....

- - - Updated - - -

wow, it's working fine.....please post the c code..... what am i wrong....please point out my mistakes it will helpful for me......
 

Here is the modified code.

Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

//pin description
sbit ten_b at ra0_bit;
sbit one_b at ra1_bit;
sbit ss_b at ra2_bit;
sbit led at ra3_bit;

sbit rly1 at rb6_bit;
sbit rly2 at rb7_bit;


//message to be display
char msg1[]="SET TIME=";
char msg2[]="O ON";
char msg3[]="MIN";
char set[]="00";

//end message

//define
#define port porta
#define delay 10
#define smh 1080
#define t 0
#define o 1
#define s 2
//end

//declare variables
bit ss_select,io;
unsigned int in,check,copy_set;
short ten,one;
int DisplayOnce = 0;
// end of declaration


void interrupt()
{
 in++;
 if(in==check)
 {
  io=~io;
  in=0;
  }
  intcon.tmr0if=0;
  tmr0=39;
 }



void main()
{
 trisa=0x07;
 trisb=0x00;
 porta=0x00;
 portb=0x00;
 option_reg=0x07;
 tmr0=39;
 ten,one,in,check,ss_select,io,copy_set,led=0;
 lcd_init();
 lcd_cmd(_lcd_clear);
 lcd_cmd(_lcd_cursor_off);
 delay_ms(10);

do
{
    if(button(&port,s,delay,1))  //logical 1 detect
    {
          ss_select=~ss_select;       //toggle ss select
    }
    
    while(ss_b=~ss_b);
 
start:
      if(ss_select==0)
      {
           if(io==0)
           {
               intcon=0;in=0;
               lcd_out(1,1,msg1);
               lcd_out(1,14,msg3);


               if(button(&port,t,delay,1))  //if logical one is detected
               {
                   ten++;                                    //increment ten
                   if(ten==10) 
                         ten=0;                        //it ten==10 means reset
               }
               
               while(ten_b=~ten_b);

               if(button(&port,o,delay,1))    //if logical one detected
               {
                   one++;                      //increment one
                   if(one==10) one=0;          //1f 10 reset
               }
               
               while(one_b=~one_b);

               set[0]=ten+48;
               set[1]=one+48;
               copy_set=atoi(set);
               check=(copy_set * smh);
               lcd_out(1,11,set);
  }

   if(io)
  {
   io=0;
   rly1=0;
   rly2=0;
   led=0;
  }
 }

 if(ss_select==0&&copy_set==0) goto start;

 if(ss_select&&copy_set!=0)
 {

  intcon=0xA0;
  if(io)
  {
   intcon=0x00;
   rly1=1;
   one=0;
   rly2=1;
   ten=0;
   led=1;
   
   if(DisplayOnce == 0) {
   lcd_cmd(_lcd_clear);
   lcd_out(2,1,msg2);
   delay_ms(100);
   DisplayOnce = 1;
   }
  }while(ss_select==0);

 }
}while(1);
}
 
Reactions: mailus

    mailus

    Points: 2
    Helpful Answer Positive Rating
i have one more doubt...please clear it.....
Code:
char msg1[]="SET TIME=00MIN";
by this code i get input from user, then how to convert the numeric value into integer?

- - - Updated - - -

i have one more doubt...please clear it.....
Code:
char msg1[]="SET TIME=00MIN";
by this code i get input from user, then how to convert the numeric value into integer?
 

Somewhere in the button routine of RA0 and RA1 add the code DisplayOnce = 0; so that everytime the timer is started DisplayOnce is set to 0.

What do you mean by convert numeric value to Integer. Isn't Integer value a numeric value?
 

i get values from user and display through this message(char msg1[]="SET TIME= 00 MIN"; ). the user value is indicated in this code as"00". how to convert these "00"values to integer.
 

i get values from user and display through this message(char msg1[]="SET TIME= 00 MIN"; ). the user value is indicated in this code as"00". how to convert these "00"values to integer.


I have changed the code like this
Code:
 //message to be display
char msg1[]="SET TIME=";
char msg2[]="O ON";
char msg3[]="MIN";
char set[]="00";

char msg1[]="SET TIME= 00 MIN"; is only a string variable holding a string. There is no function in microC to convert string to Integer.

According to the new code you don't have to convert anything.

First according to the following code
Code:
 lcd_out(1,1,msg1);
               lcd_out(1,14,msg3);
"SET TIME=" and "MIN" is displayed then according to the code
Code:
 lcd_out(1,11,set);
the value of set is displayed. As you have set the value of set to "00" initially. you don't have to convert anything.
 
Last edited:
Reactions: mailus

    mailus

    Points: 2
    Helpful Answer Positive Rating
Ok,thank you internetuser2k12.i will contact you soon with anyother doubt
 

HI.,
IN REAL TIME whenever i switch on the unit output automatically set to high....but as per my program initial state is low, in simulation it's working fine....
i checked with breadboard...is it any problem due to using breadboard.
 

HI.,
IN REAL TIME whenever i switch on the unit output automatically set to high....but as per my program initial state is low, in simulation it's working fine....
i checked with breadboard...is it any problem due to using breadboard.

Output set to high? Which output?
 

relay, led and display also show output on
 

the same circuit (as posted above) only i wired....
 

yes...your circuit with pull down resistors for buttons

- - - Updated - - -

note: in simulation it's working fine.
 

i checked, but all other operations are as i expected.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…