Shop OBEX P1 Docs P2 Docs Learn Events
Controlling 4x20 LCD with 24volt PLC on BS2px — Parallax Forums

Controlling 4x20 LCD with 24volt PLC on BS2px

jeffjohnvoljeffjohnvol Posts: 197
edited 2008-07-18 18:04 in BASIC Stamp
Newbie question here.· I purchased the 4x20 LCD to use on my Stamp PLC.· The specs are at:
http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/SerialLCD-v2.0.pdf

The Stamp PLC specs are at:
http://www.parallax.com/Portals/0/Downloads/docs/prod/indl/StampPLC.pdf


(BTW, I found if you buy that product, it costs about $9 to ship UPS (default) but if you switch to USPS its only $0.99)

It hasn't gotten here yet, but here's my concern:· I have the digital outputs on my PLC to drive 24 volt outputs, but the LCD looks as though it is expecting 5V.· Can someone recommend an idiot-proof method of dumbing the digital output to something that won't fry the LCD?

Thanks.
Jeff

Edit: added bs2px to title

Post Edited (jeffjohnvol) : 7/9/2008 8:43:54 PM GMT

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2008-06-30 16:45
    The LCD you describe is a serial device which is expecting to be connected directly to a stamp pin.

    So, because the Stamp PLC has some extra hardware to give 24 volt capability, you can either open up the case and get connected directly to a pin on the processor module OR use a transistor to allow the 24 volt output to switch a 5 volt level. You will likely need to use the inverted SEROUT parametr which is described in the help file for the development environment.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-30 17:00
    The best way to connect this serial LCD to your Stamp PLC is to use the serial port on the PLC (normally used for programming) rather than one of the digital outputs. You should be able to directly connect the LCD serial input to the Sout connection on the PLC. If you want to "play it safe" (recommended), use a 1K series resistor between the LCD and the cable to the PLC. This will protect the LCD if you accidentally connect it to the wrong PLC terminal.

    If you set the LCD for 9600 Baud, you should be able to use the DEBUG statement for output. You can always use the SEROUT statement with port #16. See the Stamp manual for details. If you use a BS2px module, the DEBUG Baud is 19200.

    Post Edited (Mike Green) : 6/30/2008 5:06:18 PM GMT
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-06-30 17:29
    Tom and Mike, thanks, that's good info. I do have the BS2px, so I'll make note of the 19200 baud.

    I like being able to use the serial port, but I'm concerned about losing my only access to download to it and view the runtime output that I currently used for debug. I may test it in the lab with a transistor first and then try using the serial pin once I put it "in the field" for actual use once I get a comfort factor. It would also be nice to get an output back later on.

    For a transistor, just use an npn with a 1K between the PLC output and the base, and 5V to the top of the transistor and the other output (the arrow side) to the LCD? I don't remember which is which on the BCE, so sorry about sounding stupid by refering it to as the arrow side.
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-06-30 17:46
    Maybe this should be a different thread, but I hate to waste a new thread on a silly question, but the PLC doesn't have enough current on the 5V output to drive the LCD. I need a different source to power the LCD.

    I have an extra 7805 5 volt regulator I could use. I checked a datasheet, and it says that the max input voltage is 30 volts, so the 24V powersupply should be fine, but do any of you see a problem with doing that? On page 21 it recommends a .33pF and 0.1uF capacitors. Should I use electrolitic caps, or are there any other suggestions? The PS I'm feeding it with is already regulates, so there shouldn't be any need for ripple rejection. the datasheet below is for a generic 7805, I doubt its for the one I have, but they should be the same (I assume).

    http://www.datasheetcatalog.org/datasheets/228/390068_DS.pdf

    Sorry for the silly electronics questions. Its been 17 years (college) since I have done that stuff. I remember enough to be dangerous, but not enough to be confident.


    Nevermind, my dad has an extra 5V PS I can use.· Although if someone wants to answer, I would love to hear the answer.

    Post Edited (jeffjohnvol) : 6/30/2008 5:51:42 PM GMT
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 00:51
    Mike Green said...
    The best way to connect this serial LCD to your Stamp PLC is to use the serial port on the PLC (normally used for programming) rather than one of the digital outputs. You should be able to directly connect the LCD serial input to the Sout connection on the PLC. If you want to "play it safe" (recommended), use a 1K series resistor between the LCD and the cable to the PLC. This will protect the LCD if you accidentally connect it to the wrong PLC terminal.

    If you set the LCD for 9600 Baud, you should be able to use the DEBUG statement for output. You can always use the SEROUT statement with port #16. See the Stamp manual for details. If you use a BS2px module, the DEBUG Baud is 19200.
    Mike, I finally got my LCD in the mail, have it hooked up to a seperate 5V PS, and am going to try your suggestion, because I don't want to use any of the 24 volt outputs nor do I want to solder anything directly within the PLC and risk damaging it.

    Is it safe to have the sout connection connected to the PC as well as the LCD at the same time, or should I swap them out each time?· I've gotten pretty dependant on those debug statements, so I would hate to lose the output to my screen.

    Thanks.
    Jeff
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-09 01:37
    If you connect the PC and the LCD at the same time, you'll get the same stuff on both. That's not that useful. Use a SPDT switch or a jumper to select either the PC or the LCD to connect to SOUT. If the LCD accepts 9600 Baud, you can use the DEBUG statements with it. Some of the control codes are different. For example, I think the positioning codes are different (goto row y and column x ...).
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 02:56
    Okay, I'm striking out. First off, I see this in the PLC sample code, which doesn't include my stamp, the BS2PX, so I don't know whether I should use the "32" or the "110". I tried both and neither seem to work.

    #SELECT $STAMP
    #CASE BS2, BS2E, BS2PE
    T1200 CON 813 ' for programming port
    T2400 CON 396
    T9600 CON 84
    T19200 CON 32
    #CASE BS2SX, BS2P
    T1200 CON 2063
    T2400 CON 1021
    T9600 CON 240
    T19200 CON 110
    #ENDSELECT

    I download the program, switch pin 16 to my IO line of my LCD and when I hit an external switch it executes:
    HIGH TxPin······ ' TxPin = 16
    PAUSE 100
    SEROUT TxPin, T19200, [noparse][[/noparse]"Hello world"]

    LCD just stays blank, sometimes I get a "w" near the bottom of the display.

    When I power down and back up with the LCD IO line disconnected, I do see a "cursor" at the top left of the LCD, so I don't think it is the contrast. Any suggestions?

    Edit:· I also tried setting the LCD setting to 9600 and tried using the debug statement without any luck either.· Also, I put the LCD in test mode (OFF-OFF) and it shows the test text fine.

    Post Edited (jeffjohnvol) : 7/9/2008 3:19:58 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-09 03:46
    Download the supplement to the Parallax Basic Stamp Manual for the BS2px (www.parallax.com/Portals/0/Downloads/docs/prod/stamps/BASICStamp2px.pdf). Page 10 has the values up through 9600 Baud for the BS2px. The DEBUG statement on the BS2px uses 19200 Baud. I don't know offhand what the constant is for 19200 Baud for the BS2px.
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 13:16
    Thanks Mike. Your quick replies are always nice to read. You must be aiming for that 10,000 post mark [noparse];)[/noparse].

    I'm pretty sure I tried the 19,200 setting witht he debug statement, but I'll try again when I get home tonight.

    I sent an email to technical support on the constant question.

    Is it possible that the io pin I am using, pin 16, needs to have a direction value or something set? I have it hooked to the PC initially, otherwise the program won't download (and start fresh). Then I redirect it to the RX line of the LCD. It says in the PLC manual that the programming pins are open for use after the system is started. I'm just wondering if in that startup mode, it is setting the pin to some mode that is incompatible with the LCD?
  • kelvin jameskelvin james Posts: 531
    edited 2008-07-09 16:04
    from stamp editor 2.4 under serout command


    #CASE BS2PX
        T1200       CON     3313
        T2400       CON     1646
        T4800       CON     813
        T9600       CON     396
        T19K2       CON     188
        T38K4       CON     84
    
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 17:09
    Kelvin, Thanks! I didn't think about checking the online help. I can't wait to try that at home tonight.

    I'm surprised the LCD manual doesn't show the different values for the different BS2's. That manual needs to be updated anyway because the 3 links it has for sample code aren't valid addresses on the parallax site anymore. They do have sampel code on the product page though, although it doesn't have code that represents the BS2PX.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-09 17:17
    "pin" 16 is treated specially for SERIN/SEROUT since it doesn't really exist as such. You don't have to set direction, etc. Even with the other pins, SERIN/SEROUT implicitly sets the pin direction (read the description in the Manual). If you use the DEBUG/DEBUGIN statements, these have an implied I/O pin (16) and implied Baud (19200 on the BS2px).

    HIGH TxPin ' with TxPin = 16
    This will probably affect pin zero. I'm not positive, but I think that the interpreter only looks at the least significant 4 bits of the pin number.
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 17:22
    Okay, thats good to know about the direction thing. Just grasping at straws.

    I hadn't copied the entire section of code, but TxPin was defined as

    TxPin CON 16

    It does seem to throw stuff on that pin though when I try to write. Hopefully Kelvin's suggestion will help. Do you know what those numbers actually translate to? I mean, on a BS2PE, 19200 translates to 110. What is that 110 represent?
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 20:42
    FWIW, Joshua at tech support gave me the proper link that includes the new values for bs2px. Its probably easy to find on the site, but here it is for those that find this thread

    http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

    Post Edited (jeffjohnvol) : 7/9/2008 8:52:07 PM GMT
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-10 13:04
    Back to the drawing board.· I still can't get it to work.· I only had an hour to work on it last night (date night).· Next chance I get which will be after the weekend I'm going to try two different things:

    1) Run sample code by itself (away from my program)
    2) And if 1 doesn't work, pull the 2px out of my PLC and put it on a breadboard and try with sample code.

    Any other suggestions are welcome (and appreciated).
  • MinimumWageMinimumWage Posts: 72
    edited 2008-07-10 15:31
    Jeff,

    I'm not sure about the 4x20 LCD, but I had a similar problem with the Parallax 2x16 LCD and I would bet it's the same situation. If I remember the details correctly, the serial out from the PLC inverted the output but the Parallax LCD needed to see a non-inverted signal. It drove me nuts because I had a Seetron LCD that worked either way but none of my Parallax LCDs worked with a PLC.

    I wish I could find my old thread because it had the full explanation from Chris Savage and a drawing of a simple transistor circuit to re-invert the signal, but it was from a couple years ago and I couldn't find it even with the forum Google search. Hopefully Parallax tech support will chime in, if not I can draw out the schematic and upload it when I get home from work.

    Mike
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-10 15:39
    I think there are different numbers I can try that would make it a 9600 inverted (no parity). I'll try that. Thanks.
  • MinimumWageMinimumWage Posts: 72
    edited 2008-07-10 17:12
    Jeff,

    I think I tried the software adjustment·and it didn't work, but I can't remember exactly why. My notebook from that project got lost in a move.·Hopefully you'll have better luck. I was able to draw out the schematic that worked for my LCD and attached it just in case it helps. It's really simple, I built one on Radio Shack perfboard and tucked it inside the enclosure I built for the LCD readout.

    Mike
    308 x 225 - 18K
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-10 17:37
    Thanks Mike, I'll give that one a shot!
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-11 17:50
    Mike, would I be able to just use a 7404 (hex inverter) to do the same thing?
  • MinimumWageMinimumWage Posts: 72
    edited 2008-07-11 19:33
    Jeff,

    I haven't tried using a hex inverter, but I can't think of a reason why it wouldn't work. I just used the transistor circuit because I could make it really quickly out of parts I had in my junkbox.

    Mike
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-11 19:52
    I may try that first since I have one of those. I can probably put pin 16 to an inverter input, then split that output between the LCD and another inverter input. The 2nd inverter input I can put to my PC connection, saving me the trouble of switching cables each time I download/start.

    Thanks.
    Jeff
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-18 18:04
    I thought I had one, can't find it.

    Sillly me. I thought I could go down to radio shack and purchase a 7404. they don't carry those in the stores anymore [noparse]:([/noparse]

    They cost 40 cents online but shipping is 7 bucks. I may end up using the transistor circuit after all.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    End dependance on foreign oil.· www.pickensplan.com
Sign In or Register to comment.