LCD BARgraphs


Closed Thread
Results 1 to 40 of 233

Thread: LCD BARgraphs

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Bar Graph

    This is my version of the bar graph.
    Code:
    '****************************************************************
    '*  Name    : Bargraph.BAS                                      *
    '*  Author  : Chris Bezuidenhout                                *
    '*  Notice  : Copyright (c) 2005 Micro Developments             *
    '*          : All Rights Reserved                               *
    '*  Date    : 2005/07/19                                        *
    '*  Version : 1.0                                               *
    '*  URL     : http://www.patenttrade.net                        *
    '*  E-mail  : [email protected]                             *
    '*  Mobile  : +27-72-795-0107                                   *
    '*  Notes   : This is a bargraph demo for a 2X20 LCD Display    *
    '*          : it is free to use and distribute by any one       *
    '*          : as long as this Copyright note is not altered or  *
    '*          : removed, can be used as an analog meter.          *
    '*  Device  : PIC16F877 can be altered to work on other devices *
    '****************************************************************
    	INCLUDE "Modedefs.Bas"
    
    DEFINE 	OSC 4		' Set Xtal Frequency 		
    DEFINE LCD_DREG PORTA     ' Set LCD Data port
    DEFINE LCD_DBIT 0         ' Set starting Data BIT (0 OR 4) IF 4-BIT bus
    DEFINE LCD_RSREG PORTA    ' Set LCD Register Select port               
    DEFINE LCD_RSBIT 4        ' Set LCD Register Select BIT                
    DEFINE LCD_EREG PORTE     ' Set LCD Enable port, for other devices, use PORT A or B                           
    DEFINE LCD_EBIT 0         ' Set LCD Enable BIT                         
    DEFINE LCD_BITS 4         ' Set LCD bus side (4 OR 8 bits)             
    DEFINE LCD_LINES 2        ' Set number of lines ON LCD
    
    ' md Declare the Variables md
    
    	counter		VAR		BYTE
    	Text		VAR		BYTE[20]
    	X			VAR		BYTE
    	Y			VAR		BYTE
    PAUSE 500
    Main:	
    '*********Modefy first 5 characters in LCD character generator to display bargraph**********
    		LCDOut $fe,%1000000           'SET CG RAM ADD.
    		FOR X =1 TO 8                 
    		LCDOUT %10000
    		next x
    		FOR X=1 TO 8
    		LCDOUT %11000
    		NEXT X
    		FOR X=1 TO 8
    		LCDOUT %11100
    		NEXT X
    		FOR X=1 TO 8
    		LCDOUT %11110
    		NEXT X
    		FOR X=1 TO 8
    		LCDOUT %11111
    		NEXT X
    		LCDOut $fe,%10000000             'SET DD RAM ADD.
    '		FOR X = 0 TO 255
    '		LCDOUT $FE,1,#X,X
    '		PAUSE 100
    '		NEXT X
    LOOP1:		LCDOUT $FE,1,"This is a test"
    		
    		LCDOUT $FE,$C0          'clear second line and display bar graph
    		LCDOUT 0                'print first character
    		for X= 0 TO 19	        'change 19 to 15 for 16 character display
    		PAUSE 100
    		LCDOUT $FE,$10,1        'move curser back and overprint previous character
    		PAUSE 100
    		LCDOUT $FE,$10,2        'move curser back and overprint previous character
    		PAUSE 100
    		LCDOUT $FE,$10,3        'move curser back and overprint previous character
    		PAUSE 100
    		LCDOUT $FE,$10,4        'move curser back and overprint previous character
    		PAUSE 100
    		LCDOUT $FE,$14          'print next character
    		LCDOUT $FE,0
    		NEXT X
    
     		
     		GOTO LOOP1
    		
     END
    Last edited by ChrisMicro; - 9th January 2008 at 17:26.
    You can't teach an old dog new tricks, but I'm always willing to try.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Chris,

    The Note says "can be used as an analog meter".

    How would you do that?
    <br>
    DT

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    It's a slight variation of Les Johnson's bargraph routine, which is in his PBP book. You load the "graphics" of the bar graph into lcd memory, then print solid bars (or blocks) until the final one which is printed as the mod of 3. The above bar graphs use a resolution of five, which has the disadvantage of a space between each five. Les' uses three, because it makes the space between the characters an unnoticed and integral part of the graph. If you don't have Les' book, then look for one of the Proton samples, because they ship with it.

  4. #4
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Analog meter

    Quote Originally Posted by Darrel Taylor View Post
    Chris,

    The Note says "can be used as an analog meter".

    How would you do that?
    <br>
    You have to use a chip with AD channels like the 16F818/819 then say for 1 volt you send your 5th character and for 1.4 volt you will send the 5th and the second character for 2.2 volt you will send the 5th character twice and then your first character so your 5th character is your integer and the first four is your decimals after the point, it give you a .2 resolution .2, .4, .6, .8
    Last edited by ChrisMicro; - 22nd January 2008 at 12:35.
    You can't teach an old dog new tricks, but I'm always willing to try.

  5. #5
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Sprites

    You can even draw little 5X7 sprites, like a walking man or any 5X7 picture. I have a small basic compiler with some handy tools, where you can create the picture and get the data for your picture. there is also a seven segment tool, it is free to download from my site, but you can only use the compiler with the programmer from Mikro Elektronika, but the tools is handy. look in the right border for free downloads it is the first item
    Last edited by ChrisMicro; - 22nd January 2008 at 13:02. Reason: spel
    You can't teach an old dog new tricks, but I'm always willing to try.

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts