Help with LCD display initialisation

Brian M

Member
Need an expert to look at this piece of code (not my original, just bits cobbled together) and can you spot my mistake.

The timed switching works fine but the serial output to the LCD display doesn't at initial switch on.

If I disconnect the power supply lines to the display and re-connect then the display works in sympathy with
the switching. Any ideas please.



Code:
 picaxe08m2

'Repeating timer for blowdown.

'Picaxe Basic code for a repeating ON/OFF timer
'with the following ON and OFF timings:
'ON for 0 hours, 0 minutes, and 30 seconds.
'OFF for 0 hours, 0 minutes, and 20 seconds.

symbol relay = C.1
symbol relayb = C.2
debug	ONmessage
debug OFFmessage
debug main

main:
   'start ON cycle - energise relay.
   high relay
   gosub OFFmessage

   'Pause for 30 seconds.
   for b2 = 1 to 30
      gosub pauseONEsecond
      
   next b2

   'Finish the ON cycle - de-energise the relay.
   low relay
   
   'Start the OFF cycle.
   high relayb
   gosub ONmessage
   
   'Pause for 20 seconds.
   for b1 = 1 to 20
      gosub pauseONEsecond
      
   next b1
   
   'Finish relay2 cycle
   low relayb

   'Repeat the cycles
   goto main

pauseONEhour:
   'Pause for one hour.
   for b0 = 0 to 0 'minutes
      gosub pauseONEminute
   next b0
   return

pauseONEminute:
   'Pause for one minute.
   for b1 = 0 to 0 'seconds
      gosub pauseONEsecond
   next b1
   return

pauseONEsecond:
   'Pause for one second.
   '1000ms (milliseconds) is one second.
   pause 1000
   return

ONmessage:
	'pause 500 ; wait for display to initialise
	serout B.0,N2400,(254,1) ; clear display
	Pause 30
	serout B.0,N2400,(254,128) ; move to start of first line
	serout B.0,N2400,("MESSAGE 1") ; output text
	serout B.0,N2400,(254,192) ; move to start of second line
	serout B.0,N2400,("MESSAGE 2") ; output line 2 text
	Pause 1000
	return

OFFmessage:

	'pause 500 ; wait for display to initialise
	serout B.0,N2400,(254,1) ; clear display
	Pause 30
	serout B.0,N2400,(254,128) ; move to start of first line
	serout B.0,N2400,("MESSAGE 1") ; output text
	serout B.0,N2400,(254,192) ; move to start of second line
	serout B.0,N2400,("MESSAGE 3") ; output line 2 text
	Pause 1000
	return
I'm running this on an AXE091 board and the display is an AXE133 budget LCD
 
Last edited:

Brian M

Member
Once I get my mind round this. I'm going to run it using a RTC. The application is to enable a solenoid valve three times a day for 20 seconds at pre-determined times (Alarm on RTC to initiate 20 sec activation). So the final coding will look nothing like this, but this gives me some practice.

Still learning PicAXE coding and what the capabilities of the chips are.
 

hippy

Ex-Staff (retired)
You have the PAUSE for LCD power-up initialisation commented out in the two LCD display routines, so perhaps you need a PAUSE adding at the start of your program to provide that delay ?
 

g6ejd

Senior Member
Most LCD screens need at least 500mS so PAUSE 500 to enable them to start before they receive any data/commands.

You could simplify your code by using more of the PAUSE command like PAUSE 60000 waits for 1-minute, it feels easier than FOR i = 1 to 60 PAUSE 1000 Next.
 

Brian M

Member
Thanks Hippy and G6EJD .. Didn't spot the commented out initial pause. The eventual timing will be approximately 4 hrs off then 20sec enable repeated at least 3 times a day, and seeing as how I am hoping to use the RTC chip/alarm to initiate the 20 sec enable, the timing on this is only for my convenience.

Still having some problems, think I need to just run the LCD part of the programme and bottom that problem first. The timing/enable I have no problems with anyway.

Thanks again.
 
Top