Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:53 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : (MM) LCD 16X2 difficulties

     Page 1 of 2    
Author Message
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 12:54am 07 Dec 2011
Copy link to clipboard 
Print this post

Hello everyone. I think three days of trying to get one of these new LCD 16x2 displays to work is enough. I could use some help.

The program LCD.bas from Geoff loads, runs, and works fine on my first MM SM1, but when I connect any of my three new LCDs to any of my other four new MM SD1s it will not work. I have checked the pin connections and they are the usual 1-16. Believe me I’ve set this up at least 10 times through my Boiler add-on circuit board. This circuit board has been checked for shorts or incorrect wiring at least 10 times. Don’t seem to be any problems there. I used 10 K resistors between 5 Volts and each of the MM pins 11 through 16.

What I get from the 16 X 2 LDC display is a row of black boxes. Nothing more, nothing less. I’ve got the POT working, and it dims the intensity of the boxes, and for some of these tests I hooked up the back light through a 25 Ohm resistor and it works fine too. But I can’t get anything but solid black boxes on the top row. Nothing on the second row.

I tried changing the pause in the eight lines of code from 2 milliseconds to 100 milliseconds and various times inbetween. No luck.

Does this look like something familiar to anyone else for which there might be an easy fix.

I can’t substitute the only LCD the program works on for testing with other MM’s, as I hardwired it into my temperature data logger which was my first MM project.

Of the three new LCD’s I’m testing, all have the same standard wiring set up. Two of them have the connections listed on the back, and the third has a cable attached, did not have any schematic, but gives the exact same results as the other two new ones. The 3rd one displays a bit different in one way: It does show the second row as black boxes when contrast is turned way up. The others don't do this. When this LCD shows both rows of black boxes the upper row is always much darker than the lower row. As I mentioned, the other two LCDs never display the lower line (black boxes or anything else).

I’ve wired this so many times I can do it from memory.
LCD pins:
1, Ground
2, 5 volts
3, middle leg of the 10K POT for contrast control.
4, RS to MM connector Pin 11
5, RW jumped to Ground
6, EN goes to MM connector Pin 12
7, 8, 9 & 10 are jumped to Ground
11, D4 to MM connector Pin 13
12, D5 to MM connector Pin 14
13, D6 to MM connector Pin 15
14, D7 to MM connector Pin 16
15, Jumped from 5V through a 25 Ohm resistor for the Back light
16, Jumped from Ground for Back light
I also jumpered from the 5 Volt and Ground to the other two legs of the 10K POT used for contract control.
Any suggestions as to what I’m doing wrong?

This is driving me bonkers.

Pete in Hyder

Edited by pcaffalldavis 2011-12-08
We're all here 'cause we're not all there.
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 01:33am 07 Dec 2011
Copy link to clipboard 
Print this post


You have no shortage of spare lines on your Maximite. Have you tried 8 bit mode rather than 4 bit mode? All 8 data lines connected, rather than just 4? It would require a code change for this mode. Personally I prefer 8 bits of data to an LCD. I've found some are persnickety about 4 bit mode.

Do the data lines get 5V? Perhaps you need to investigate using open collector outputs and resistors pulled up to 5V for the data and command signals.


Micromites and Maximites! - Beginning Maximite
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 01:47am 07 Dec 2011
Copy link to clipboard 
Print this post

It looks like you've wired it up correctly.
You mentioned placing a pause in some of the code.
Do you have a pause just after the LCD initialize?
Talbit

I think Geoff's code makes all the pins open collector anyway. I'll check!

Yes, he sets all pins open collector.
Is the working one the same brand and type as the new ones?
TalbitEdited by Talbit 2011-12-08
Talbit
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 01:57am 07 Dec 2011
Copy link to clipboard 
Print this post

What is the distance between the MM and the LCD. And are you using flat cable crimped onto a quality IDC connector? I've found you can get garbage if things are not right in this area.
Talbit
Talbit
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 01:59am 07 Dec 2011
Copy link to clipboard 
Print this post

Did you make up the MM Pin Tester? That'll tell you if the MM is okay.
Talbit.
Talbit
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 02:00am 07 Dec 2011
Copy link to clipboard 
Print this post

I am new to this. I don't know how to convert to 8 bit, though I assume it means all Data lines 0-7 get their own MM Pin line? I'm not sure how to alter Geoff's LCD.bas program either. I only have three more pins available on the MM so if 8 bit means I need four more I'm already over committed.

I think the 5 volt connection through a 10K resistor means the data lines are getting 5 volts like you suggested, though I'm not sure that is what you mean. I also thought these were set up like open collector as that is what the Sparkfun article showed in their schematic which is what I followed.

It is not actually all fun for me to spend this much time on something so simple. I need this boiler program with all the temperature sensors, relays and LCD display working by spring because I won't have time to do it when the weather warms up.

I do enjoy learning though.

It's now or never! Thanks!

Pete in Hyder
We're all here 'cause we're not all there.
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 02:01am 07 Dec 2011
Copy link to clipboard 
Print this post

I'm suggesting that you test the LCDs first with 8 bits of data to make sure that they work. Or to show that they don't work in 4 bit mode. Experimentation.

Most LCD data sheets describe the series of 8 bit commands you need to send to a display.

Micromites and Maximites! - Beginning Maximite
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 02:40am 07 Dec 2011
Copy link to clipboard 
Print this post

  pcaffalldavis said   Hello everyone. I think three days of trying to get one of these new LCD 16x2 displays to work is enough. I could use some help.

The program LCD.bas from Geoff loads, runs, and works fine on my first MM SM1, but when I connect any of my three new LCDs to any of my other four new MM SD1s it will not work.



Hi Pete,

try setting the pins to Digital output - Not open collector.. I couldnt get Geoffs code to work as open collector, The pins would need pull up resistors to work as OC...

Set as digital (,8 instead of ,9) and see how it goes,

otherwise try this code (dontronics demo)... just edit line 210 to suit the pins you connect to the maximite

Regards,

Mick



10 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''
20 ' LCD driver for standard 16 x 2 LCDs
30 ' Originally by Geoff Graham, March 2011,
40 ' Modified for Arduino by Mick Gulovsen July 2011
43 '
45 ' For example: futurlec.com LCD16X2
50 ' altronics.com.au Z7001
60 ' jaycar.com.au QP5512
70 '
80 ' To use:
90 ' - execute GOSUB 5000 to initialise display and Maximite
100 ' - then load the text strings into the
110 ' variables LCD_line1$ and LCD_line2$
120 ' - execute GOSUB 12000 to display the text
125 ' - To send an LCD Command load Variable LCD with the Command byte
130 ' - Execute GOSUB 6000
135 ' - To send a character to the LCD load Variable LCD with the Character byte
137 ' - Execute GOSUB 7000
138 '
140 ' See the file lcd.pdf for the schematic.
150 ' Maximite pin 19 is RS, pin 20 is EN
160 ' pins 15 to 18 are D4 to D7. R/W is grounded
200 ' Define Variables and pin Numbers
210 RS=19 : EN=20 : D4=15 : D5=16 : D6=17 : D7=18
220 GOSUB 5000 ' Initialise Display and Maximite
225 LCD_line1$ = " *Dontronics* "
230 LCD_line2$ = " DonDuino Cross "
300 GOSUB 12000
400 PAUSE 5000
410 LCD = &B00000001 : GOSUB 6000 ' clear display
413 GOSUB 4000: ' Get Keypress Status
415 PRINT pin(1):GOSUB 12000: PAUSE 500 ' display on Console the voltage read for Keypress .. delay 0.5 sec
420 goto 413
500 END
4000 IF PIN(1) < .2 THEN LCD_line1$=" Right ": RETURN
4010 IF PIN(1) < 1 THEN LCD_line1$=" Up ": RETURN
4020 IF PIN(1) < 1.6 THEN LCD_line1$=" Down ": RETURN
4030 IF PIN(1) < 2.2 THEN LCD_line1$=" Left ": RETURN
4040 IF PIN(1) < 2.91 THEN LCD_line1$=" Select ": RETURN
4050 LCD_line1$=" None ": RETURN
5000 ' ------------------------------------------------------------ -----
5010 'Initialise the LCD
5020 SETPIN 1,1: SETPIN D4,8:SETPIN D5,8:SETPIN D6,8:SETPIN D7,8:SETPIN EN,8:SETPIN RS,8
5030 LCD = &B0011 : GOSUB 6000 ' reset
5040 LCD = &B0011 : GOSUB 6000 ' reset
5050 LCD = &B0011 : GOSUB 6000 ' reset
5060 LCD = &B0010 : GOSUB 6000 ' 4 bit mode
5070 LCD = &B00101100 : GOSUB 6000 ' 4 bit, 2 lines
5080 LCD = &B00001100 : GOSUB 6000 ' display on, no cursor
5090 LCD = &B00000110 : GOSUB 6000 ' increment on write
5100 LCD = &B00000001 : GOSUB 6000 ' clear display
5110 RETURN
6000 ' - ------------------------------------------------------------ -----
6005 ' Send Command Byte
6010 PIN(RS)=0 : PIN(EN)=0 : delay=5
6020 GOSUB 13000 ' send byte
6030 RETURN
7000 '-- ------------------------------------------------------------ -----
7005 ' Send Data Byte
7010 PIN(RS)=1 : delay=1
7020 GOSUB 13000 ' send byte
7030 RETURN
12000 '- ------------------------------------------------------------ -----
12010 ' send the two lines to the LCD
12020 ' the text is in LCD_line1$ and LCD_line2$
12030 '
12040 LCD = &H80 : GOSUB 6000 ' select the 1st line
12050 FOR X= 1 TO 16
12060 LCD = ASC(MID$(LCD_line1$, X, 1))
12070 GOSUB 7000 ' send the character
12080 NEXT X
12090 LCD = &B11000000 : GOSUB 6000 ' select the 2nd line
12100 FOR X = 1 TO 16
12110 LCD = ASC(MID$(LCD_line2$, X, 1))
12120 GOSUB 7000 ' send the character
12130 NEXT X
12140 RETURN
12150 '
12160 '
13000 ' ------------------------------------------------------------ -----
13010 ' Send a byte to the LCD
13020 ' the data to be sent is in LCD
13030 '
13040 PIN(D4) = LCD AND &B00010000 ' output the 1st 4 bits
13050 PIN(D5) = LCD AND &B00100000
13060 PIN(D6) = LCD AND &B01000000
13070 PIN(D7) = LCD AND &B10000000
13080 PIN(EN) = 1 : PAUSE 1:PIN(EN) = 0 : PAUSE DELAY ' tell lcd to accept data
13090 ' Entry point to send just 4 bits to the LCD
13100 PIN(D4) = LCD AND &B00000001 ' output the 2nd 4 bits
13110 PIN(D5) = LCD AND &B00000010
13120 PIN(D6) = LCD AND &B00000100
13130 PIN(D7) = LCD AND &B00001000
13140 PIN(EN) = 1 : PAUSE 1: PIN(EN) = 0 : PAUSE DELAY: ' tell lcd to accept data
13150 RETURN



Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 03:16am 07 Dec 2011
Copy link to clipboard 
Print this post

I will try these tonight and report back.

Thank you!

Pete in Hyder
We're all here 'cause we're not all there.
 
James_From_Canb

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 265
Posted: 03:59am 07 Dec 2011
Copy link to clipboard 
Print this post

Talbit mentioned the Pause after the initialise.

I had all sorts of grief with gibberish on the screen until I put in a Pause command.

Try adding the following line to the code above:

5105 Pause 2

It won't do any harm, and will give the LCD controller time to finish its setup.

James

BTW - if it does make a difference, we should get the sample code changed.Edited by James_From_Canb 2011-12-08
My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention.

Hedley Lamarr, Blazing Saddles (1974)
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 04:23am 07 Dec 2011
Copy link to clipboard 
Print this post

Hello Mick, Talbit, everyone.

IT WORKS now. It was the open as digital 8's instead of 9's. I don't know how it got referenced as 9's, but it worked first time out as ditital 8's.


WHEW! My wife said I should have asked two days ago but I'm stubborn.

My data logger and daily high, low and current temperature program works on the new LCD display too, just change the Setpins to 8. Yes!

Thank you everyone.

Yes I have about 3' of ribbon cable and IDC connectors but they were professionally installed (HA, by me in a woodworkers vise). I have a 12" 26 pin ribbon from MM to the Boiler component and junction board, then about 3' of 10 pin ribbon from that board to the LCD. That is so I can put the LCD on the front of the boiler once it is built.

Since I've got everyone's attention, and since my smaller breadboards for making the MM pin tester are just been ordered from China (not here for three weeks) is it possible to run two 16 x 2 LCD's off the same feeds? I'm wondering if I can have one outside the firebox door, and another in the house. It would be nice if each showed all the info, like Boiler water temp, house air temp, Circulating pump status (on or off) and each of the zone flow control valves (open or closed).

As you can see, I don't have enough pins to drive a second LCD 16 x 2, but was wondering if two would accept data from the same pins. I'll test this latter, but I can't until my smaller bread boards arrive.

Oh, and my 10 Ohm resistors I need for all the relays didn't arrive so I can't finish up the Boiler Board just yet. I wonder if I could use 25 Ohm instead of 10 Ohm on the MOSFET relay circuits? Hum...

Thanks everyone!

Pete in Hyder
We're all here 'cause we're not all there.
 
camfab
Newbie

Joined: 10/09/2011
Location: Australia
Posts: 13
Posted: 04:33am 07 Dec 2011
Copy link to clipboard 
Print this post

"WHEW! My wife said I should have asked two days ago but I'm stubborn."

Tell your wife that if men started looking for advise, from wiser men, everytime they were confused, then there would be no more marriages! Edited by camfab 2011-12-08
Fre Sprky
///...///

 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 05:33am 07 Dec 2011
Copy link to clipboard 
Print this post

Camfab

I think I might pass on telling her that. She feeds me pretty often and I don't want to put that in jeopardy. Good point though.

Hey, I just tested two LCD's by shorting a second one across a header and initializing them both. IT works too! What a night.

Now, if I can just learn if it is acceptable to use a 25 Ohm resistor instead of a 10 Ohm resistor in the Mosfet relay control circuit for the MM as shown in the May 2011 Issue of Sparkfun. I think it was the third issue on the MM, but it might not have been the May issue. It was the one that showed how to control relays and line voltage items... The schematic shows a 10 Ohm resistor as well as a 10K resistor in each MOSFET circuit. Anyone have any thoughts on substituting a 25 Ohm for the 10 Ohm?

It could be another week or two before these 10 Ohm resistors arrive and I'd kind of like to get this phase of the project completed!

Pete in Hyder
We're all here 'cause we're not all there.
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 03:33pm 07 Dec 2011
Copy link to clipboard 
Print this post

Hi,

I don't know the circuit you are planing on, but if you use 2x 25 Ohm resistors in parallel then you get 12.5 Ohms, pretty close and probably close enough, depending on what you are doing of course.

rgds,

Andrew
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 11:23pm 07 Dec 2011
Copy link to clipboard 
Print this post

  pcaffalldavis said   Hello Mick, Talbit, everyone.

IT WORKS now. It was the open as digital 8's instead of 9's. I don't know how it got referenced as 9's, but it worked first time out as ditital 8's.


is it possible to run two 16 x 2 LCD's off the same feeds? I'm wondering if I can have one outside the firebox door, and another in the house.


Hi Pete,

Glad you got it going, The ,9 was in Geoffs original code and would work if the data lines had internal (or external) pullup resistors. mine obviously dont. I had to modify the ,9 to ,8 to get it to work.

Two LCDs in parallel should be ok as the LCDs are programmed by WRITEs only (The R/W line is Grounded) so you should be able to drive several displays,. The back screen might need to be considered for current draw on multiple displays is all.



The sample code I posted was to demonstrate the LCD modules that Don sells on an Arduino footprint and displays the button presses (up, down, left, right, select) on the LCD and the voltage divider voltages on the console (the buttons set up different dividers depending on which one is pressed).

I have been meaning to clean up the code and turn it into a `LCD Module' driver as opposed to a demo program. But there are never enough hours in the day.


Regards,

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 05:44am 08 Dec 2011
Copy link to clipboard 
Print this post

Mick,
I’m running an LCD off 5 volts. Each input pin is expecting a 5 volts input. I’m not sure what LCD modules people have but do you think it’s possible to leave out the resistors altogether and just set the pins to digital out. This would only give a 3.3 volts (or lower) drive to the LCD which would otherwise expect a full 5 volts via the pull-up resistor. Is the 3.3 volts enough or would it be border line? Has anyone tried it for reliable operation?
Talbit

Talbit
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 07:29am 08 Dec 2011
Copy link to clipboard 
Print this post

Mick,

I don't know, but I'm hoping to hear what others say about this too. Last night my LCD was running okay with digital outs setpin 8, but after a time it started messing up again and often displays the full black boxes again. It is totally sketchy. At least it now works some of the time which is better than what I had with SetPins at 9.

My Boiler connection Board is already wired up with 10K resistors for the LCD, and my only experimental breadboard is tied up with another sample set up waiting for the 10 Ohm resistors for the MOsfet circuits so I can't test a different LCD set up right now.

I will try running the MOSFET circuits using the 22 Ohm resistors and if necessary use two like Viking Boy suggested. So perhaps I'll know better in a day or two after the breadboard is available if the LCD's can be run without the resistors and being fed with digital outputs.

I'll keep you posted.

It sure was frustrating to see the newly working digital Setpin x,8 to work and then slowly stop working. I was wondering if this was due to a voltage drop as when I had two LCD hooked up the problems were more pronounced, making me think they were not getting sufficient voltage... Hum...I'm such a novice.
At this point I don't even know enough to know what I don't know. HA!

Pete in Hyder


We're all here 'cause we're not all there.
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 10:16am 08 Dec 2011
Copy link to clipboard 
Print this post

Pete,
I think you've answered my qestion to Mick. I recon you need the pins set as open collector and use the pull up resistors. That should fix your scrambled screen. The idea of the resistors is to ensure a good solid 5 volts on the LCD input pins.
Talbit
Talbit
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 10:26am 08 Dec 2011
Copy link to clipboard 
Print this post

By using the open collector mode (9) and 10k pullups, the idea would be to help with the interface between the 3.3V micro and the 5V LCD. It's likely that this would work OK if you have the LCD and micro on the same PCB, but with longer cable runs, the cable capacitance would start to dominate and round the edges off you signals to the LCD, thus corrupting the data sent to the LCD. By using the digital out mode (8) you will only get 3.3V when the data lines go high, which is probably close to the logic high threshold of the LCD. Again, probably ok for short connections, but increase that cable length and watch the data corruption start to appear.

Try lowering the pullup resistors to 1k and use the open collector mode. Decreasing the data rate would also help. You might need to have a look with a CRO to check if the data signals have nice square edges. You could probably lower the pullup resistors to as low as 100ohms, but at the sacrifice of increased current consumption.

The line of black sqaures generally indicates that the LCD has not initialised.
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 10:50am 08 Dec 2011
Copy link to clipboard 
Print this post

100 ohms is too low. Each pin can only source or sink 10mA and a 100 ohm resistor will try and sink 33 mA i.e. 3.3V/100ohms = .033A. Besides, you need the pin to go to the full 5 volts so you don't want a lower resistor. You only get current throught the resistor when you are driving the O/C pin low. But it's still needed when driving the pin high because it effectively "pulls" the pin to 5 volts.
So you need the pins set to O/C and the 10K resistors in circuit for it to work reliably.
The lowest you can make the resistor is 330ohms. 3.3/330 = .01A (10 mA)
TalbitEdited by Talbit 2011-12-09
Talbit
 
     Page 1 of 2    
Print this page
© JAQ Software 2024