LCD Bar Graph using Byvac BV4512

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
Harry Tuttle
Posts: 27
Joined: Sat Aug 01, 2009 3:15 pm
Has thanked: 2 times
Been thanked: 10 times
Contact:

LCD Bar Graph using Byvac BV4512

Post by Harry Tuttle »

LCD Bar Graph
Bargraph.jpg
(180.27 KiB) Downloaded 3813 times


Hardware

As before a 16f877a and Byvac BV4512 128x64 LCD Graphic controller is used.
http://www.matrixmultimedia.com/mmforum ... =26&t=8020
http://www.byvac.co.uk/downloads/datash ... aSheet.pdf

Usual I2C bus with pull up resistors, plus potentiometer connected to analogue input ADC(1).
You could change this to a temperature sensor etc.

Code

You might want to add a timer interrupt but allow plenty of time for the display to update as it can take quite a while. To keep things simple the main loop just runs as fast as the display can be updated.

Time delay
To let things settle down after power up.

Calculation
Set the I2C address of the LCD display and set some of the other variables to start values.

Component macro
Initialise the I2C bus.

Macro: ClearLCD
Clears the display

Macro: Text
Write some text to the display.

Macro: ZeroARRAY
Sets all 100 points of the variable ARRAY to 1, not 0 as this will not work in the position calculation later.

Time delay
To allow the Text to be seen

Macro: ClearLCD
Clears the display

Macro: DrawScale
Draws the permanent parts of the scale on the LCD.

Main Loop

Component macro
Read ADC(1)
Reads the voltage on the analogue input and returns a value of 0 to 255 as the variable Yinput.

Macro: MinMax
Update the minimum and maximum values

Macro: printInput
Set the row and column position for the input value Yinput
Go to Format to change the number into formatted ASCII and send to the display.

Macro: printMax
Same as above but for the Max value

Macro: printMin
Same as above but for the Min value.

Macro: Display
Re-uses the variables hundreds, tens and units.
Divide the input reading by 4 and set to a minimum of 1.
Update ARRAY with new reading.
Clear old values on the display by drawing a clear line
Draw new values as dark lines.
BV4512BarGraph.fcf
(31.33 KiB) Downloaded 617 times

singhdeol
Posts: 30
Joined: Sat Dec 18, 2010 6:07 am
Has thanked: 6 times
Been thanked: 2 times
Contact:

Re: LCD Bar Graph using Byvac BV4512

Post by singhdeol »

Great project thx for the post

Post Reply