Controlling 4x20 LCD with 24volt PLC on BS2px
jeffjohnvol
Posts: 197
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
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
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
·
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
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.
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
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
#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
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?
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.
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.
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?
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
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).
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
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
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
Thanks.
Jeff
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