Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to create bar graph on lcd

Status
Not open for further replies.

Gadavi

New Member
Hi,

Does anyone knwo where i can find some code on how to create a bar graph which changes according to values / pulses? I built a lcd tacho, which get a signal from the car's ecu. I display the rpm on the top line of the lcd. What i want to do now, is display a bar graph of that value on the second line. I'm using a pic16F84A with a hd44780 lcd. My code is in assembler it would be nice to get some simple examples on how to do this.

Thanks
 
Do you want the bar to go across the display or to be in each individual character?

Google for ways to write the custom characters of the LCD.

Mike.
 
Last edited:
I have seached, but only find examples in c or basic. It would be nice to get a simple example in assembler.
 
Hi,

You can create a solid character block by sending out ' 0XFF ' to the lcd - its part of the standard character set.

Just compare your RPM readings to preset values to determine how many 'blocks' you turn on eg 500 rmp = 1 block etc
 
I want to display solid block as a start and then later use some custom characters. That sounds like a good idea yes, but i'm struggling to implement it as code. Does no-one know where I can find some examples in assembler?
 
To define the first 8 characters you send command 0x40 + address of character data. So, to write to character 5 you would send command 0x40+(5*8) = 0x68 followed by writing 8 data bytes. Try sending the following,
Command 0x68
Data 0xff,0xff,0,0,0,0,0,0
Command 0x80
Data 0x05
You should get a semi filled character in position 0 on the top line of the display.
Now try altering the 8 data bytes in the second line.

Mike.
 
Thanks man, will try it this evening. Now how will i link that up to display a certain amount of bars according to certain values or pulses?
 
Assuming that you want the bar to move from left to right on the display and the display is 16 characters wide, this would give you 6*16=96 positions. I counted the gap between chars as a pixel so the movement would be smooth.

The simplest way to convert your 0-95 number into characters would be two lookup tables. One containing the number of solid chars to display and the second containing the character to display after the full ones.

Mike.
 
You are also going to need to fill the remaining spaces with blanks, otherwise your bar graph is only going to go up, not back down. For example, if your number of bars is 47, then 48 to 95 need to be blank spaces. I hope I am being clear enough.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top