Shop OBEX P1 Docs P2 Docs Learn Events
Displaying a changing numerical value on an LCD? — Parallax Forums

Displaying a changing numerical value on an LCD?

TurnbullTurnbull Posts: 7
edited 2007-09-15 16:48 in BASIC Stamp
How·would I display a process variable on an LCD display with a steady name of the variable next to it? Example: "VOLTAGE - 6.330" Obviously the voltage would change. Is this even possible??··

Comments

  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-09-12 13:42
    YES, Its possible. Which LCD are you using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-09-12 14:38
    How are you controlling the LCD? With a Stamp of some kind?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • TurnbullTurnbull Posts: 7
    edited 2007-09-12 14:40
    It is a parallel 2 X 16 that came with the PDB kit. I will eventually be using different and larger LCD's but for now I am trying to get the general theory down. Do you know where I might be able to find code examples?? Thanks for the quick reply.
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-09-12 15:25
    The SX/B help file has a demo on how to serially control an LCD.

    http://www.parallax.com/sx/sxb_examples_apps.asp

    I think the Stampworks 2 manual has a section on controlling a parallel LCDs

    http://www.parallax.com/dl/docs/books/sw/Web-SW-v2.1.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • smlcaerussmlcaerus Posts: 18
    edited 2007-09-12 17:46
    If I am not mistaken here, your problem is outputting the "digital value" which your are probibly storing as a variable which is decimal? So in a normal DEBUG you can use the DEC3 statement and such next a variable, and for SEROUT the same thing. But, if your using a parallel driven LCD whereby you are sending each character individually, you can not do this (at least that I am aware of).

    I basically had to write a sub in which stripped down the number in common holders. Meaning, I created 4 variables in the beginning of my program, HUNS, TENS, ONES, and INVAL then I would just GOSUB my CONVERT_TO_CHAR routing, which logically just went thru and computed the HUNS, TENS, and ONES of INVAL.

    Then I just sent those values + asc(31) i think, and that ended up printing my number.

    Every iteration thru, to just replace the number, send (3) backspaces in my case, and just reprint the new value.

    Was that it, or am I way off base?

    Shawn
  • smlcaerussmlcaerus Posts: 18
    edited 2007-09-12 17:50
    Here is a sample routine from Parallax MAR2002 Article:

    ' Convert a byte into three ASCII digits and display them on the LCD.
    ' ASCII 48 is zero, so the routine adds 48 to each digit for display on the LCD.
    BCD: let huns= BCDin/100+48 ' How many hundreds?
    let tens= BCDin//100 ' Remainder of #/100 = tens+ones.
    let ones= tens//10+48 ' Remainder of (tens+ones)/10 = ones.
    let tens= tens/10+48 ' How many tens?
    let char= huns ' Display three calculated digits.
    gosub wr_LCD
    let char = tens
    gosub wr_LCD
    let char = ones
    gosub wr_LCD
    return
  • TurnbullTurnbull Posts: 7
    edited 2007-09-12 18:07
    That sounds about where I am headed. I am new to this type of programming and I apppreciate your feed back. I will try what you have outlined.
  • TurnbullTurnbull Posts: 7
    edited 2007-09-12 21:50
    Thanks·Smlcaerus! That was exactly what I was looking for!!!
  • TurnbullTurnbull Posts: 7
    edited 2007-09-12 22:34
    Where did you find that March 2002 article? I would like to see more. Thanks.
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-09-13 11:29
    That code is actually from the Basic Stamp I application notes (see section 4), which will be helpful if you're using a Basic Stamp 1.

    However, you never did answer as to what you are using to actually control the LCD. The PDB is what you plug it into, not what controls it. On the PDB you have to use either a BS1, one of the many types of BS2s or an SX-28.

    More than likely, what you have is a plain old BS2, if that's the case please download and go through the StampWorks manual. It will tell you everything you need to know, and most of the info in it is easily adapted to any of the other flavors of BS2s.

    I really think you may be over-complicating this a bit [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick

    Post Edited (RDL2004) : 9/13/2007 11:34:16 AM GMT
  • TurnbullTurnbull Posts: 7
    edited 2007-09-13 13:22
    It is a plain BS2. I may be over complicating it, but that is what I am here to find out. I have been working with this code for about three weeks now. I already went through the Stampworks book but it didn't really help me with this issue unless I didn't know what I was looking at. I am used to working with PLC's so I am very green with this stuff. Thanks for the help!!
  • TurnbullTurnbull Posts: 7
    edited 2007-09-14 00:30
    I cant figure this out!! Can anyone give me a short example to work off of? Something is not sinking in for me here... What I want to have happen is to have a readout that looks like this- "METER 0.000 VOLTS" Meter and volts would be static and the numerical value will change. I am using an RCTIME to try to test the display. As the RCTIME increases or decreases the "VOLTS" number would change. HELP!!!!!!!!!! All I need is a very dumbed down example to work off of.
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-09-14 04:35
    Basically once you put a character onto the LCD display, it automatically stays there until you overwrite it with something else. You would first load the meter and volts part, then start sending and updating the numbers. I can't help you much more than that because I highly prefer the simplicity of using serial type LCDs with the Basic Stamps, so that's all I've ever used. Here is a web page that may help:

    www.myke.com/lcd.htm

    or maybe www.weethet.nl/english/basicstamp2_lcdcontrol.php

    Parallax sells a serial LCD, but if you want a serial controller (sometimes called a "backpack") that you can add to the LCD you already have, try here:

    www.wulfden.org/k107/index.shtml

    (I really wish Parallax would sell their serial controller separately - hint hint)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick

    Post Edited (RDL2004) : 9/14/2007 4:42:35 AM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-09-14 14:09
    The weethet page is good!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • mrtaylormrtaylor Posts: 1
    edited 2007-09-15 16:48
    Use the DIG command
    index = number to display
    char = char to display on LCD

    DisplayNum:
    char = index DIG 1 + 48
    GOSUB LCDwr
    char = index DIG 0 + 48
    GOSUB LCDwr
    RETURN

    LCDwr:
    OUTB = char.HIGHNIB ' output high nibble
    PULSOUT E, 1 ' strobe the Enable line
    OUTB = char.LOWNIB ' output low nibble
    PULSOUT E, 1
    HIGH RS ' return to character mode
    RETURN
Sign In or Register to comment.