LCD Display basics

Anonym

Active member
Hi everyone!

First of all, this is my first thread here, so pretty please excuse my inexperience. Also, feel free to correct me if something is wrong. Thanks a bunch!


So, I have soldered an LCD display to my 20M2 PICAXE using the diagram found at the bottom of page 36, manual 3 (direct connection). This means pin 2 on the diagram is connected to my B.2, pin 3 to B.3 and so on. Now I would like to test if the circuit works, but the code fo operating a display seems really complicated. I tried looking up forum posts about it, but every one of those seems to be using different things, so it's hard to get a picture of what is going on. Is there any chance one of you could post a really basic program for the direct connected LCD, say one that simply prints out "Hello"? I am hoping I would be able to understand how it works thanks to it. Or help me get to that point at least...

Thank you.
 

lbenson

Senior Member
Welcome to the forum.

The code is irreducibly complex, because with only 4 lines to transmits 8 bits of data or control information, bytes must be sent in "nybble" format--4 bits at a time. To my mind, the best source is hippy's code for the 14M, post 4, here:
Should work for you with the pins appropriately designated.

If that doesn't solve it for you, ask again.
 

Anonym

Active member
Thank you, I'll try it out! Though you said "only 4 lines to transmit 8 bits of data" - is that implying that there is a way to connect all the 8 lines? I do not need to limit myself to the 20M2, I can change my circuit as well... I only need my serial lines for something else, so I can't use them for the display. Thanks again!
 

inglewoodpete

Senior Member
A few years ago, I shared your frustration with connecting a PICAXE to an alphanumeric LCD. I developed a solution and posted a thread on a simple interface that, apart from a few definitions for pins, provided a reliable method of getting an LCD to work quickly with all but the smallest PICAXE. Have a look at this code.
 

Anonym

Active member
So, I have been exploring both programs recommended to me, and it seems they are indeed quite hard to understand. This lead me to a thought: Is possible to program any of the C pins as a serial output? As I stated above, I need my default serial output for something else. If I could use another pin as a serioul output, that'd make things so much easier!
 

marks

Senior Member
Hi Anonym,
I don't have a 20m2 at the moment
but I did write this bit of code for a lcd shield to try with one some time ago.
 

inglewoodpete

Senior Member
So, I have been exploring both programs recommended to me, and it seems they are indeed quite hard to understand.
The beauty of the code that I posted in the link in my post #4, above, is that you don't have to fully understand the code: just allocate 6 pins with Symbol statements according to your wiring between the PICAXE and LCD.
This lead me to a thought: Is possible to program any of the C pins as a serial output? As I stated above, I need my default serial output for something else. If I could use another pin as a serioul output, that'd make things so much easier!
It depends on what you mean by "Serial Output".

If you want to reallocate the SerialOut pin (specifically used for programming the PICAXE, SerTxd or Debug commands), then the answer is NO.

If you want to set a pin on Port C up to output serial data for your application, then YES, easy: have a look at the SerOut command.
 

hippy

Senior Member
Attached is my latest generic code for interfacing an LCD in 4-bit mode, which can have pins allocated however one wants, non-sequentially and even across ports.

Written for the 18M2, and should run on the AXE133 unchanged, and should work with any PICAXE with the pin definitions adjusted as appropriate.
 

Attachments

Aries

New Member
Is possible to program any of the C pins as a serial output?
Assuming you mean (as InglewoodPete said) to allocate a C-pin for ordinary output of serial data, then you can use any C-pin except C.6, which is "input-only"
 

Anonym

Active member
So, I finally got the time to test my set-up. Aand... doesn't work. I decided to try Hippy's code, only modifying it for my pins. When I turn the circuit on, nothing lights up. The voltage on my power supply drops to zero, spiking at around 1.5V every half a second or so. I double checked my wiring and everything seems to be connected correctly. How should I proceed?
 

hippy

Senior Member
The voltage on my power supply drops to zero, spiking at around 1.5V every half a second or so. I double checked my wiring and everything seems to be connected correctly.
That sounds like the power supply is trying to come up, going into over-current shutdown and turning off, repeating indefinitely. That would usually be a case of wiring error.

This is why we recommend the use of the AXE133 range of display products because it saves most of the effort of making things work. Plus they are good platforms to check one's own code is working before moving it to a self-designed circuit. Having a known working circuit helps identify what problems there may be.

The best way to proceed is with a circuit digram of what you have and photographs of your actual boards and wiring, plus the code you are actually using so that can be compared to the wiring you have.

The best way to develop a project is to start simple, just a PICAXE and its power supply, running an "I'm alive" SERTXD loop, then expand on that.
 

Anonym

Active member
That sounds like the power supply is trying to come up, going into over-current shutdown and turning off, repeating indefinitely. That would usually be a case of wiring error.

This is why we recommend the use of the AXE133 range of display products because it saves most of the effort of making things work. Plus they are good platforms to check one's own code is working before moving it to a self-designed circuit. Having a known working circuit helps identify what problems there may be.

The best way to proceed is with a circuit digram of what you have and photographs of your actual boards and wiring, plus the code you are actually using so that can be compared to the wiring you have.

The best way to develop a project is to start simple, just a PICAXE and its power supply, running an "I'm alive" SERTXD loop, then expand on that.
Thank you very very much for the advice hippy! I'll post all of that once I get home
 

Anonym

Active member
Alright, here it comes...

THE PROBLEM: Nothing lights up when I turn it on. To quote Hippy: "power supply is trying to come up, going into over-current shutdown and turning off, repeating indefinitely"

(Side note: Yes, there is a temperature sensor in the circuit, wanted the display to show a temperature, but since it doesn't even light up, I have not put any code for that yet)

Circuit diagram: https://i.imgur.com/wOoZaTq.jpg

Circuit picture front: https://i.imgur.com/YkSJ8PY.jpg

Circuit picture back: https://i.imgur.com/JSajBwT.jpg

The code is attached. As I said, I just took Hippy's code and modified it for my pins.
 

Attachments

Anonym

Active member
After some though, I have come up with the conclusion that I wired the potentiometer wrong... will attempt a quick fix.
 

Anonym

Active member
Progress! So, I cut off all the thermometer related stuff and re-wired my potentiometer. When I turn it on now, the 2nd and 4th line of the screen light up with black squares, and about a second or so afterwards the 1st and 3rd line light up with squares too. Now, if it just were to actually show text...
 

inglewoodpete

Senior Member
First, your circuit diagram is wrong: there is no +5v line going to the LCD module. However, if you're getting black boxes, your actual wiring +5v must be correct.

Black boxes usually indicate that the LCD is powered but not initialised. Can you make the black squares disappear and reappear by turning the potentiometer?
 

Anonym

Active member
First, your circuit diagram is wrong: there is no +5v line going to the LCD module. However, if you're getting black boxes, your actual wiring +5v must be correct.

Black boxes usually indicate that the LCD is powered but not initialised. Can you make the black squares disappear and reappear by turning the potentiometer?
Yep, there is a line missing in the circuit diagram, but more importantly the potentiometer was wired wrong altogether. Yes, I can make them disappear and reappear by turning it now.
 

hippy

Senior Member
When I turn it on now, the 2nd and 4th line of the screen light up with black squares, and about a second or so afterwards the 1st and 3rd line light up with squares too.
Looking at the photos you posted, the pin numbering of the LCD, I suspected the LCD may be upside down as you have photographed it, and the above would appear to confirm that. Your LCD and control board would seem to be assembled as below -
Code:
  .----------.
  |   ___    |
  |  |___|   |
  |          |
 (O)         |
  |          |
.--------------.
| Line 1       |
| Line 2       |
| Line 3       |
| Line 4       |
`--------------'
When a four line LCD is initially powered up it will normally put solid blocks on lines 1 and 3 ( lines 2 and 4 counted the other way ), After initialisation in "2 line mode", lines 2 and 4 will also become blocks ( 1 and 3 counted the other way ).

So, apart from the LCD likely being the wrong way up from how you expected it to be, this is good news because it appears to indicate the PICAXE is talking to the LCD at least enough to configure it as such.

The issue then seems to be that it's not sending data beyond that.
 

hippy

Senior Member
and it works!
That's excellent news.

Two things which might be worth bearing in mind if building more -

1) The inline resistors are not an absolute necessity and can usually be left off. So long as the R/W pin is pulled down to 0V the LCD should never put any output on the D4-D7 pins.

2) The D0-D3 connections on the LCD can usually be left floating, don't need to be connected to 0V.
 

Anonym

Active member
That's excellent news.

Two things which might be worth bearing in mind if building more -

1) The inline resistors are not an absolute necessity and can usually be left off. So long as the R/W pin is pulled down to 0V the LCD should never put any output on the D4-D7 pins.

2) The D0-D3 connections on the LCD can usually be left floating, don't need to be connected to 0V.
Thanks a lot! Now that this works, I might revive my I2C threat, hehe...
 
Top