Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How to hide first time running digit 00.00

Status
Not open for further replies.

sacban

Junior Member level 3
Joined
Aug 20, 2015
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
412
Hello Everyone,
I made a project for a volt meter, this project already working fine, just I want to change the method during first time running.

First time running, I got digit 00.00 onto LCD appears, then once the voltage read source voltage "example 4,5 volt" the digit reading for 04.50, this is true, how can I change that way, when first time running the digit never show digit 00.00, then once have voltage 4.5 volt the digit will show 4.50.

Below are the code :

Code:
void main()
{
 ADCON1=0x82;
 TRISA=0XFF;
 Lcd_Init();
 lcd_cmd(_LCD_CLEAR);
 lcd_cmd(_LCD_CURSOR_OFF);
 Lcd_Out(1,5," Meter");
 lcd_out(2,1,"VOLT:");
 for(;;){
         adc_value=ADC_Read(0);
         adc_value=adc_value*5000/1023;
         
          hit1=adc_value/1000;
          hit2=(adc_value%1000)/100;
          hit3=((adc_Value%1000)%100)/10;
          hit4=((adc_value%1000)%100)%10;
          
          lcd_chr(2,11,48+hitung1);   
          lcd_chr_cp(hitung2+48);
          lcd_chr_cp('.');
          lcd_chr_cp(48+hitung3);
          lcd_chr_cp(48+hitung4);
          lcd_chr_cp('V');
         
         delay_ms(20);
        }
}


I hope someone there will help me solve this out.

Thank you.
 

Try this. It just needs a if() condition.

Code:
for(;;){
         adc_value=ADC_Read(0);
         adc_value=adc_value*5000/1023;
         
	if(adc_value > 0.0) {
          hit1=adc_value/1000;
          hit2=(adc_value%1000)/100;
          hit3=((adc_Value%1000)%100)/10;
          hit4=((adc_value%1000)%100)%10;
          
          lcd_chr(2,11,48+hitung1);   
          lcd_chr_cp(hitung2+48);
          lcd_chr_cp('.');
          lcd_chr_cp(48+hitung3);
          lcd_chr_cp(48+hitung4);
          lcd_chr_cp('V');
         
         delay_ms(20);
	}
        }
 

Hi,

My thoughts:
* What's wrong when it shows "00.00"?
* there are different variable names. I don't understand howit can work. "hit1" -> "hitung1"
* with the code of post#2 ... it never shows 0. So if you immediately remove the voltage, then it may "01.23" while the input voltage is 0V.
* a delay of 20ms is not useful. Our eyes can't read more than 3-4 values per second, thus a delay of 300ms is more suitable.

Klaus
 

Why not by simply handling digits, writing a space character instead Zero ?
Something like that (eg. for the first digit), not tested :

Code:
if (hitung1)
          lcd_chr(2,11,48+hitung1);   
else
          lcd_chr(2,11, ' ');
 

Hello There,
Thank you for your respond according my question.

As well your suggestion below are :

baileychic : I trying that method but doesn't working.
KlausST : My thoughts:
* What's wrong when it shows "00.00"?
** It's no wrong but more better if the zero hidden before use.

* there are different variable names. I don't understand howit can work. "hit1" -> "hitung1"
** Yes.....you are correct, there is should be hit1 not hitung....:oops:

* with the code of post#2 ... it never shows 0. So if you immediately remove the voltage, then it may "01.23" while the input voltage is 0V.
** Yes.....If I go to lower voltage example 9 volt, then will show 09.00

* a delay of 20ms is not useful. Our eyes can't read more than 3-4 values per second, thus a delay of 300ms is more suitable.
** It's ok for the Delay_ms(20), but can change to 300ms.
Thank you......

andre_teprom : I trying your method and that working as well my expected.

Below are the code :
unsigned long adc_value; //Declaration of adc_value (variable)
unsigned char hit1, hit2,hit3,hit4; //Declaration of hit (variable)

void main()
{
ADCON1=0x82;
TRISA=0XFF;
Lcd_Init();
lcd_cmd(_LCD_CLEAR);
lcd_cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"VOLT METER");
lcd_out(2,1,"VOLT:");
for(;;){
adc_value=ADC_Read(0); // Get AN0 PIN
adc_value=adc_value*5000/1023; // Calculate ADC_Read for 4.88 Vdc


hit1=adc_value/1000;
hit2=(adc_value%1000)/100;
hit3=((adc_Value%1000)%100)/10;
hit4=((adc_value%1000)%100)%10;

// lcd_chr(2,11,48+hit1);
if (hit1) // Follow andrew method edaforum
lcd_chr(2,11,48+hit1);
else
lcd_chr(2,11, ' ');

lcd_chr_cp(hit2+48);
lcd_chr_cp('.');
lcd_chr_cp(48+hit3);
lcd_chr_cp(48+hit4);
lcd_chr_cp('V');

// lcd_chr(2,11, ' ');

delay_ms(20);
}
}

Test LCD Volt.JPG
Test LCD Volt1.JPG
Test LCD Volt2.JPG

Thank you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top