Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

LCD Progress bar

Sai Shoby

Newbie
Joined
Oct 22, 2020
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
23
Hi all,
I am using I2C 2x20 oled display. I want to make a VU meter for my audio signal. for the first step I try to see the progress bar in my LCD. In most of the examples, they use Lcd_out, Lcd_Cmd(), Lcd_Chr_Cp(), Lcd_Cmd(),Lcd_Chr() but i dont have this function in I2c Lcd Library. I am using #include "I2C_LCD.C".

Please help me to write a code for this
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,453
Helped
4,117
Reputation
8,234
Reaction score
4,051
Trophy points
113
Activity points
121,454
Hi

Please understand that we don't know what microcontroller, type of LCD, schematic, IDE, compiler, language....you use.

Klaus
 

paulfjujo

Advanced Member level 4
Joined
Jun 9, 2008
Messages
1,409
Helped
284
Reputation
568
Reaction score
271
Trophy points
1,363
Location
France 01800
Activity points
9,829
hello,

it seems you have a TEXTE LCD ...


so the only way to do bargraph is to define 8 caracters in CGRAM to represent the 8 steps
inside one char ..
you have 20 chars wide LCD => you can get 8x20=160 steps into your bargraph
new 1rst char have only one pixel wide , 8 pixels Height
second char have 2 pixel wide ... 8 pixel height
..and so on
last is a black cractere 8x8

The value to display must be sclaled before to 160 (full range)
then you divide your value by 8 , to write this number of char ( plain char) on the line (if >=1)
following by the rest (of division) to select the CGRAM charctere by %8 (modulo 8)
and add it as last char on the line
(needs some limits checking to do in software .)



example of char definition
on my LCD2119 I2C ..
not used here for bargraph ...

Code:
void Cree_8_cars_CGRAM()
{
unsigned char b1,b2;
 I2C1_Start();
 I2C1_Wr(LCD_ADR); // i2c slave Adress
 I2C1_Wr(0x00);
 // Cde Set_CGRAM address to 0  =>  (0x40 + adresse=0 )
 I2C1_Wr(0x40);
// I2C1_Start();
 I2C1_Repeated_Start() ;
 I2C1_Wr(LCD_ADR); // i2c slave Adress
 I2C1_Wr(0x40);// set CGRAM adress
// blanc  
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);
I2C1_Wr(0b00000000);

// degre C
I2Cx_Wr(0b00000000);
I2Cx_Wr(0b00001110);
I2Cx_Wr(0b00010001);
I2Cx_Wr(0b00001110);
I2Cx_Wr(0b00000000);
I2Cx_Wr(0b00000000);
I2Cx_Wr(0b00000000);
I2Cx_Wr(0b00000000);

// The Euro currency character can be recognized by the 0/1 pattern (see Figure 48)
I2C1_Wr(0x06); // 00110
I2C1_Wr(0x09); // 01001
I2C1_Wr(0x08); // 01000
I2C1_Wr(0x1E); // 11110
I2C1_Wr(0x1E); // 11110
I2C1_Wr(0x08); // 01000
I2C1_Wr(0x09); // 01001
I2C1_Wr(0x06); // 00110

  // petit rectangle
I2C1_Wr(0b0000000);
I2C1_Wr(0b0000000);
I2C1_Wr(0b0011111);
I2C1_Wr(0b0010001);
I2C1_Wr(0b0011111);
I2C1_Wr(0b0000000);
I2C1_Wr(0b0000000);
I2C1_Wr(0b0000000);
I2C1_Stop();
}
 

paulfjujo

Advanced Member level 4
Joined
Jun 9, 2008
Messages
1,409
Helped
284
Reputation
568
Reaction score
271
Trophy points
1,363
Location
France 01800
Activity points
9,829
but, you will see some gap between each step
because
Only bit 0 to bit 5 of the CGRAM address are set by the Set_CGRAM command.

else use a Graphic LCD as Nokia 5110
version 84x48 or 96x64
then bargraph could be contineous .. pixel by pixel

some LCD have allready , in ROM some specific char to draw vertical or horizontal bargraph
but with 5 pixel wide in horizontal mode or only 6 pixel in vertical mode
 

Attachments


paulfjujo

Advanced Member level 4
Joined
Jun 9, 2008
Messages
1,409
Helped
284
Reputation
568
Reaction score
271
Trophy points
1,363
Location
France 01800
Activity points
9,829
Hello,

i wrote this example for 18F47K42 and classique LCD2x16, driven in 4bits mode.
but could be adapted to other MCU
and use you LCD I2C syntaxe instead of MikroC LCD library
The main item is to build the specifics chars into the CGRAM
Then use them to draw the bargraph...
With a TEXTE LCD , you get a blank space between each step of one char
impossible to fill this gap.. else you have to use a GRAPHIC LCD
or find out a Text LCD with Font characteres in 8x8 bits ..
i don't know if that exist ?

Bargraph_EA0_B.jpg
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,664
Helped
14,077
Reputation
28,411
Reaction score
12,742
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,914
All character LCD driver IC on the market are compatible with Hitachi HD44780 controller, supporting 5x8 and optionally 5x10 dot matrix. They require LCD glasses with inter-character gap, thus no chance to display a continuous bar graph.
 

Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top