20M2 to16 x 2 lcd help

johnrelph

New Member
I have connected a 16x2 display to a 20M2 picaxe on a axe118 project board as per the picaxe manual 3, page 36 "Connnecting The LCD (OPTION 3)"
and loaded the following programe
Code:
EEPROM 0,("Hello there everybody!") ; store the text in the EEPROM memory
		gosub init ‘ initialise LCD
start:
		 let b1 = 1 	; set b1 to ;clear display’ instruction
		gosub wrins 	; send instruction to LCD

	for b3 = 0 to 22 		; setup a for...next loop
		read b3, b1 	; read letter from EEPROM into variable b1
		gosub wrchr 	; send character to LCD
	next b3 			; next loop
	
		let b1 = 12 	; set b1 to ‘hide cursor’ instruction
		gosub wrins 	; send instruction to LCD
main:
		let b1 = 24 	; set b1 to ‘scroll display left’ instruction
		gosub wrins 	; send instruction to LCD
		pause 250 		; pause for 0.25s
		goto main 		; loop
		
		
init: 	let pins = 0 	; Clear all output lines		
		let b4 = 0 		; Reset variable b3
	                 [COLOR="#FF0000"] let dirs = 252 	; Set pins 2-7 as output lines (Stamp only).[/COLOR]
	 	pause 200 		; Wait 200 ms for LCD to reset.
		let pins = 48 	; Set to 8-bit operation.
		pulsout 3,1		; Send data by pulsing ‘enable’
		pause 10 		; Wait 10 ms
		pulsout 3,1 	; Send data again
		pulsout 3,1 	; Send data again
		let pins = 32 	; Set to 4-bit operation.
		pulsout 3,1 	; Send data.
		pulsout 3,1 	; Send data again.
		let pins = 128 	; Set to two line operation
		pulsout 3,1 	; Send data.
		let b1 = 14 	; Screen on, cursor on instruction
		gosub wrins 	; Write instruction to LCD
		return
wrchr:
		let pins = b1 & 240 	; Mask the high nibble of b1 into b2.
		high 2 			; Make sure RS is high
		pulsout 3,1 		; Pulse the enable pin to send data.
		let b2 = b1 * 16	 	; Put low nibble of b1 into b2.
		let pins = b2 & 240 	; Mask the high nibble of b2
		high 2 			; Make sure RS is high
		pulsout 3,1 		; Pulse enable pin to send data.
		return
wrins: 
		let pins = b1 & 240 	; Mask the high nibble of b1 into b2.
		pulsout 3,1 		; Pulse the enable pin to send data.
		let b2 = b1 * 16 		; Put low nibble of b1 into b2.
		let pins = b2 & 240 	; Mask the high nibble of b2
		pulsout 3,1 		; Pulse enable pin to send data.
		high 2 			; Back to character mode
		return
		
#no_data

and get no responce on the LCD screen just the top row of 16 black squares :confused:
I have checked the wiring several times and is correct

any help would be appreciated :
 
Last edited:

PaulRB

Senior Member
Have you tried adjusting the contrast pot? If set too far, the black blocks will appear, although I would expect both lines to show blocks.

Paul
 

johnrelph

New Member
I havent got a pot yet, I have tried it with a 150 ohm resister which gives black squares, or a 680 ohm and can only just make out the squares.

I have just noticed this note in the manuel "NB. The | character is ‘SHIFT + \’ (next to Z on a UK layout keyboard)." which is odd as this charictor is not used in the listing ??
 
Last edited:

SAborn

Senior Member
The pot is set up as a voltage divider with the wiper to the contrast pin of the LCD, so i fail to see how a single resistor will control the contrast.
 

inglewoodpete

Senior Member
Unfortunately, the example in Manual 3 was intended for the 18X (now superceded by the 18M2). The pinout for the 20M2 is quite different from the 18X and will not work without careful translation. On top of the chip-model issue, the example uses port addressing which must be carefully configured for each model of PICAXE on order to work.

As others have mentioned, you will not get far without getting the contrast potentiometer fitted. Playing around with individual resistors to get the contrast right will prove to be quite futile.

Given that you are not using an 18X (or even an 18M2), I suggest you have a read this thread that I started a few months ago: Universal Test Code for LCDs. But fit a pot first:).
 

nick12ab

Senior Member
Just a top row of black squares suggests that the LCD hasn't been initialized. Read the datasheet and make sure that you are correctly initializing the display.
 

hippy

Ex-Staff (retired)
The program sets its outputs using "let pins=" which is fine for an older PICAXE where pins were output by default, but for more recent PICAXE you need to set those pins as output using "let dirs=", and you should (likely) be using "let pinsB=" and "let dirsB="
 

johnrelph

New Member
Thanks for all your help :)
I just had to alter 1 line " highligted in red" to "let dirsb = %11111111".
Contrast is just right with a 150 ohm resister from vdd to v0,
just got to figure out how to change the message from "Hello there everybody"
Thanks again for all the replies
 

westaust55

Moderator
just got to figure out how to change the message from "Hello there everybody"
Remove the line:
#no_data​

located near/at the bottom of the program. That line prevents new data being laoded into EEPROM so your message will stay the same
See the directives section in PICAXE manual 2
 

johnrelph

New Member
Thanks for that westaust55,
I read someware that "#no_data" just marked the end of the programme to save time when downloading.
 
Top