Shop OBEX P1 Docs P2 Docs Learn Events
How do I send variable data to my LCD Display? — Parallax Forums

How do I send variable data to my LCD Display?

MooneyguyMooneyguy Posts: 77
edited 2014-10-06 01:17 in General Discussion
I purchased a 2x16 Serical LCD Backlit, with Speaker (#27977-RT) for by Basic Stamp 2. I can make the sample display programs work from the Parallax site but have not idea how to send my results to the display from my application program.

I have a code like the following and want to send the mVoltsOutput and Gallons result to the display. I would like the output results to continually display in one spot and not scroll, etc. so it so I can see continual changes in the output in one position on the display. mVoltsOutput on the top line and Gallons on the bottom line. Can some one please help me?

DEBUG "Output (mv): ", DEC mVoltsOutput, " Output (Gallons): ", DEC Gallons, CR
LOW CS
SHIFTOUT DataIn, Clock, MSBFIRST, [Offset]
SHIFTIN DataOut, Clock, MSBPOST, [ADCoutput\13]
HIGH CS
mVoltsOutput = ADCoutput */ Cnts2Mv ' Convert ADC Output To Millivolts
Gallons = mVoltsOutput/2
GOSUB GetADC
RETURN

Incidentally, when I plugged the Rx lead from the display into P0 of the Basic Stamp 2, my mVoltsOutput read zero for some reason when I would run the debug. I was able to measure the mv with my dvm with good results but only 0 would show on my debug screen so it had to do with something in the Stamp. When I pulled the Rx out from the display and unplugged the Basic Stamp 2 input power and replugged the power back in, I was able to get my mV to read on the debug screen.

Other possibly helpful information is:
Dout from the Parallax 604-00062 (MCP3208) Analog to Digital Converter goes to P4 of the stamp, CS/SHIN goes to P5, DIN to P3.

mVoltsOutput VAR Word ' ADCoutput converted to mVolts.
Cnts2Mv CON $0139 ' x 1.22 convert to Millivolts (=5000mv/4096 in Hex)
ADCoutput VAR Word ' Analog to Digital Conversion results.

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2014-10-05 15:50
    Did you read the data sheet and look at the example code for the BS2? I don't have anything for that LCD right at hand, but I don't remember it being all that difficult to use. I will see if I can dig up some of my old programs that used the Parallax LCD though, in case you can't get it working.


    http://www.parallax.com/sites/default/files/downloads/27976-Serial-LCD-BS1-BS2-Code-RevF.zip

    http://www.parallax.com/sites/default/files/downloads/27979-Parallax-Serial-LCDs-Product-Guide-v3.1.pdf
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2014-10-05 16:36
    Talking to the serial LCD is just like talking to the debug terminal except you say
    SEROUT TxPin, Baud, [stuff to display]
    instead of
    DEBUG stuff to display.
    You can include set cursor commands with the other stuff. See Moving the Cursor on page 4 of the data sheet. See Command Set on page 7 of the data sheet.

    "For extensive code examples .... see "Smart Sensors and Applications" ...."
  • RDL2004RDL2004 Posts: 2,554
    edited 2014-10-05 16:53
    One thing I found confusing at first using LCDs is that once you write a character to the display, it stays until over-written. For example, if your displayed voltage goes up to say 12.8, then goes down to 5.5 the display will show 5.58, unless you pad the lower value with a leading blank space (this will also keep the decimal point in the same spot).
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-05 21:51
    Based on that, I would have expected the following code to work, but it didn't

    GetADC: ' Gets pressure output in mv.
    HIGH TxPin ' Set pin high to be a serial port
    PAUSE 100 ' Pause for Serial LCD to initialize
    DEBUG "Output (mv): ", DEC mVoltsOutput, " Output (Gallons): ", DEC Gallons, CR
    LOW CS
    SHIFTOUT DataIn, Clock, MSBFIRST, [Offset]
    SHIFTIN DataOut, Clock, MSBPOST, [ADCoutput\13]
    HIGH CS
    mVoltsOutput = ADCoutput */ Cnts2Mv ' Convert ADC Output To Millivolts
    Gallons = mVoltsOutput/2
    SEROUT TxPin, Baud19200, mVoltsOutput ' Display output in mV on LCD
    GOSUB GetADC
    RETURN
  • SapphireSapphire Posts: 496
    edited 2014-10-05 22:04
    The problem is your SEROUT command. The format isn't right. It should be like this:
    SEROUT TxPin, Baud19200,[DEC mVoltsOutput]
    

    The parameters you want to display have to be in brackets [ ] and preceded by a format specifier (i.e. DEC for DECimal)
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-05 23:10
    Ahhh, Got it.This works:
    GetADC: ' Gets pressure output in mv.
    HIGH TxPin ' Set pin high to be a serial port
    PAUSE 100 ' Pause for Serial LCD to initialize
    SEROUT TxPin, Baud19200, [12]
    SEROUT TxPin, Baud19200, [17] 'Turn display backlight on
    LOW CS
    SHIFTOUT DataIn, Clock, MSBFIRST, [Offset]
    SHIFTIN DataOut, Clock, MSBPOST, [ADCoutput\13]
    HIGH CS
    mVoltsOutput = ADCoutput */ Cnts2Mv ' Convert ADC Output To Millivolts
    Gallons = mVoltsOutput/2
    DEBUG "Output (mv): ", DEC mVoltsOutput, " Output (Gallons): ", DEC Gallons, CR
    SEROUT TxPin, Baud19200, [DEC mVoltsOutput, " mV"]
    SEROUT TxPin, Baud19200, [13] 'Carriage Return – For the two line LCD model, if on line 0 the cursor
    'is moved TO position 0 ON line 1. IF ON line 1, it wraps around TO
    'position 0 ON line 0.
    SEROUT TxPin, Baud19200, [DEC Gallons, " Gallons"]
    PAUSE 1000
    SEROUT TxPin, Baud19200, [12] 'Form Feed - The cursor is moved to position 0 on line 0 and the
    'entire display is cleared. Must PAUSE 5mS after this command.
    PAUSE 5
    GOSUB GetADC
    RETURN

    Thanks!!!
  • SapphireSapphire Posts: 496
    edited 2014-10-06 01:17
    Yes, and you can combine the commands and data in the same SEROUT too:
    SEROUT TxPin, Baud19200,[DEC mVoltsOutput," mV",13]  ' note CR is included here
    
Sign In or Register to comment.