Prop to character lcd problem
ihmech
Posts: 179
I'm having trouble with a character lcd display connected to my prop, everything on the display is garbled.
It worked great while everything was on my PPDB. I moved it to a prop proto board with an IDC connecter wired in. Currently it's wired directly, it's the same as I had it connected to the PPDB. I was thinking I was having trouble with voltage drops through poor connections. I checked each control and data line with a scope and I'm seeing aprox 3.3v.
I've been looking for anything I can find on 3.3v to 5v interfacing and it seems there are many ways of doing. I just don't know which is best.
It worked great while everything was on my PPDB. I moved it to a prop proto board with an IDC connecter wired in. Currently it's wired directly, it's the same as I had it connected to the PPDB. I was thinking I was having trouble with voltage drops through poor connections. I checked each control and data line with a scope and I'm seeing aprox 3.3v.
I've been looking for anything I can find on 3.3v to 5v interfacing and it seems there are many ways of doing. I just don't know which is best.
Comments
Before you do anything too drastic you might try an npn transistor to shift the level to 5V. Set the serial driver up to invert TX, put a 4.7K resistor between the output pin and the transistor base, emitter to ground, a 1K pullup from collector to +5V, and connect collector to LCD input.
Sometimes a few mV difference in the signal is all there is between working and not working.
Thanks for the tips. I thought about using a transistor, but I'm working with a parallel display. It would be a lot of transistors even with 4bit mode.
I did come up with a breakthrough tonight.
I just stripped the first proto board I built that didn't work at all and rebuilt it (a bigger failure than the second one!). Interestingly enough, I get the same garbled message as the second proto board. It's looking like it's a few just a few mV is causing my problems since they are now the same with two different proto boards. I'll just have to order a few buffers to keep on hand. My only local supply is Radio Shack....they don't even stock Parallax stuff. :-P
The only odd thing is that the display works just fine on my PPDB but not on a proto board. Can the 40 pin dip on my PPDB provide a slightly stronger output than the QFP chip on my proto boards?
Might be time to post some pics and code.
The HC family is likely to work too, but not guaranteed because input levels at 0.3Vdd and 0.7Vdd respectively.
[edit, just a thought, a simpler solution might be to drop the 5V supply to the LCD via a 1N4001 diode or similar - might make the difference]
Thanks,
I'll try and post a picture tonight and some code.
I've had bad joints cause me trouble in the past. That was the first thing I assumed and redone all of the joints. It didn't fix it. I have two boards built with a 14pin IDC socket wired in and a ribbon cable to the display and both produce the same garbled results. The first board I built (it was a total failure, didn't even work at all...built late with little sleep) is rebuilt with smaller wires with less crossing and shorter more uniform lengths. I had also hoped that would help too, but sadly it didn't.
I'm up for trying anything.
Toby,
You work like I do, I'm usually on a shoestring budget. I took apart a dead YMIU planter controller from work to see if it had a 4Mhz crystal I needed for a keypad encoder chip. It did and it worked. :-) I hate it when I need one small part and I have to order one. I usually just wait until I can put together a big order to make shipping worth it.
This display is new sealed in bag, but it is a 5v display. I know I'm flirting with a very small window of getting a solid high signal to the display. I have something to try tonight and see if it works. We'll see.
Mark_T
I bought a bag of diodes on my lunch break. RS did have those.
I'll try it out tonight and see if that .7v drop is enough.
I've got stupid questions: If my supply voltage is 5v and the logic threshold is 2.5v. Does that threshold change dependant on the supply voltage coming in?
With a supply of 4.3v cause the logic threshold to be 2.15v?
Also even if you are nominally within the threshold, but very close to it there will be two issues that might cause problems - lower noise-immunity and slower response. In general its good to have healthy margins for peace of mind!
I have had a Prop running at 4.2 Volts ( I know that some have tried 5 Volts) and nothing bad happened (but 9 Volts did have some effects, OOPS !!!!!!!!!!), this was when it was nuzzling up to a Z80.
I am afraid to say that the 3.3/5 Volt thing sometimes led me to the AVR way out of things.
The only things that are new in my trials are usually the PCB (toner), the solder, err, no thats it.
This is my playing with Jazzed AVR based I2C (so far)
I commented out most of the code for the screens so I could just take a picture of the APF2 logo. Nine times out of 10 it will load just the logo perfectly. I can add more code and it works and then it don't. What ever my problem is...it seems small and on the razors edge of working/not working.
I have included some pictures and code.
I'm open to any improvements or ideas anyone has.
It's the first time I have wrote a useful object. I know there are many lcd objects out there. I'm trying to learn and I wanted to write my own and know how it works.
The picture of the display is it running on my PPDB.
APF2_startup_screens.spin
Lcd_driver_4bit.spin
I have noticed that my lcd object or lcd is very sensitive to faster clock speeds. I had noticed it on the PPDB and slowed the clock down so things would work reliably.
Sorry for my lack of clarification. I've been very tired putting this together.
It is a Hitachi HD44780 4x20 parallel lcd running in 4bit mode with a prop proto board, it works just fine when connected to my PPDB. Just doesn't work with the proto board.
Here is the code I am working with, APF2_startup_screens.spin is the top object.
APF2_startup_screens.spin
Lcd_driver_4bit.spin
(I'm sure my coding is laughable and sad...but I'm just learning.)
I'm still looking at the code but the one thing that I always recommend with these LCDs which use a very ancient parallel style interface is that for modern practice that we forego the checking of the busy flag as this is the only read operation we bother doing but it is absolutely totally redundant. If you get rid of the reading you can then free up the I/O line that currently controls R/W and then just tie R/W low. The bonus for 3.3V systems like the Prop is that they don't have to worry about voltage levels. The LCDs are specified with TTL input levels, meaning that a high level only needs to be at least 2V, perfect for the Prop!.
Trying to read back on this long cable is also prone to be influenced by interference.
Make the changes as listed here in the code where we remove the check for busy and simply wait 5us after every instruction or 2ms for a clear display instruction. BTW, I've simplified the code a bit and you can always just leave the R/W line connected as it is now and just make sure it's low.
EDIT: Just noticed another function in the 4bit driver as it seems to be a totally replicated function that also check busy. Print2 (cchar) can be removed and reference made instead to Char_out
Thanks for your help!
The "Print2" was a left over from when I was trying to figure out how to work with custom characters. I figured out a while back that it was not needed, I just forgot to remove it. :-)
I put the display back on my PPDB and ran the original code to make sure everything worked. Then I tried several times plugging in the code you provided. Nothing was working, so after carefully studying your code I started working on mine.
I first worked on removing the "busy" calls and replaced them with large delays. After getting that working I kept making the delays smaller until it didn't work, then I backed off a bit so everything worked again. I'll work on simplifying the "command" and char_out" methods another night. I am including the modified code that now works on the proto board.
Thanks everyone for all of your help!!!!! This is why I love this forum!
BTW I was also able to bump the system clock from 5Mhz back up to 80Mhz. I don't have the clock speed sensitivity like I had before. Nice little added bonus. :-D
APF2_startup_screens_X.spin
Lcd_driver_4bit_X.spin