LCD BARgraphs


Closed Thread
Results 1 to 40 of 233

Thread: LCD BARgraphs

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    The DEFINEs don't match the comments. Might be the prob.

    Defines show RS on PORTB.2, and Enable on PORTB.3

    But, your comment says...
    <pre>'This setup will tell PBP a 2-line LCD is connected in 4-bit mode with the data bus on the<br>'top 4 bits of PORTB, Register Select on PORTB.1, and Enable on PORTB.0.</pre>
    DT

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Now, I am really confused. How come this program worked but the other one didn't?

    DEFINE OSC 20
    INCLUDE "LCDbar_INC.bas" ' Include the BARgraph routines
    ' Set LCD Data port
    DEFINE LCD_DREG PORTB
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTB
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 2
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 3
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 100.

    DEFINE ADC_BITS 8 ' Number of bits in ADCIN result
    ADCON1.7 = 1 ' Right Justify AD result

    Value VAR WORD ' Must be a WORD even though AD is 8bit
    pause 1000
    LCDOUT $FE, 1, " "
    loop1:

    adcin 2,value

    LCDOUT $FE,2,"Value = ",DEC Value," "

    ; syntax- BARgraph Value, Row, Col, Width, Range, Style
    @ BARgraph _Value, 2, 0, 16, 255, lines

    goto loop1


    The only thing I adjusted was the pause commands and I moved the include file to the top of the program. I'm happy that it's working but I'd like to know for future reference incase it happens again. Thanks for the help Darrel.

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


    Did you find this post helpful? Yes | No

    Default

    You probably have an LCD that is very slow starting up and requires more than 500 ms before receiving it's first command.

    Being that you also have DEFINE LCD_DATAUS 100, it's seems reasonable.
    Most LCD's are happy with LCD_DATAUS 50, and only 250 ms power-up delay. But there are some that aren't.

    Try leaving the INCLUDE where it was, with the longer pauses. Just to see what happens.
    <br>
    DT

  4. #4
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Found the problem!

    Well, after searching for a while, I found the problem and it's strange. At the tops of both programs, look at the OSC commands. One is in CAPS and the other isn't. I guess it has to be in CAPS or PBP won't know what it is. I wonder why it doesn't give you an error when compling?

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's been already mentioned a lot of time since the Forum birth.

    DEFINEs must be WRITTEN AS STATED in the manual. Case not, they will never be considered by the compiler
    http://www.picbasic.co.uk/forum/show...light=spelling
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Ha, that's funny. Didn't even see it.

    >> I wonder why it doesn't give you an error when compling? <<

    You can DEFINE almost anything you want

    <pre>DEFINE GreatGoogly Moogly</pre>But it only has an effect if it matches up with something the program is expecting to see.
    And, when using MPASM the case has to match too.

    Well, now that you've got things going, I hope the BarGraphs work out for you.
    <br>
    Last edited by Darrel Taylor; - 11th July 2006 at 03:46. Reason: oops, ya beat me Steve.
    DT

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup, i guess the MPASM AND PM IFDEF can't be bypassed like Variable and Labels.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Hi guys,

    does this work with a pic 16F84A ??

    I get many strange errors !

    .

  9. #9
    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.

  10. #10
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Wink Nice Work

    DT,
    Really nice work! I will be using this on several of my A2D projects!!
    Padawan-78

  11. #11
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Can I pick someone's brain please?
    I'm at the moment trying to make an auto switchover gadget to change from running on Diesel to Veg Oil once certain temperatures have been reached, and to try and work this out I'm using the easypic5 development board.
    So far: I have a 16f877A programmed so it will switch certain outputs when certain inputs go high all and well
    It even displays what it's doing on the LCD display

    What I'd like to incorporate if its possible is this? or a variation of it the Bargraph but use it as a fuel level sensor, i.e. changing position depending on the level of the fuel in the tank (variable resistor)

    Does anyone know any code that will do that or give me a starting place to play with?
    I know I've got 2 A/D converter inputs on the developement board I can play with that have a 10K pot connected and are configured so I can change the input on either of the RA0, RA1, RA2, RA3, RA4, or RA5 pins and measure the voltage on them ( unfortunatly I'm only just learning about Pic's at the moment and know nothing about A/D and how to use it, I am learning by trying and experimenting But I am a quick learner), so IF anyone has any code they could share with me to show me how to get started with this I'd be grateful Thanks

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