Driving Digole Serial text lcd board with 8M2.

Zukjeff

New Member
Arvo' All,
What i thought would be a walk in the park took me three long nights to get working. So here is my code to save others a few hours.

8M2 driving a Digole serial driver board. The LCD is a 16x2.
The Digole boards always start up at 9600,8,n,1.
The 8M2 can do 9600 on the Hardware serial port when its clock is bumped up to 8 meg but i don't think there will be much time left to do other things.
I got the demo working at B9600_8 then put in a gear change back to B2400_4 so the 8M2 Hserout and the Digole both end up running at 2400.

Let me know via this thread if something is not clear .


Code:
'   Headers by Jeff Pethybridge  Aug 2013
'
'     _-_0_1_2_
'    |         |
'     )  8M2   |
'    |_________|
'     +  5 4 3
'
'C5 = (AXE027 Serial Out)	'
'C4 = Sw1 to +ve			'
'C3 = Sw2 to +ve			'
'C2 = NC				'
'C1 = NC		       	'
'C0 = (AXE027 serial Out)  / Digole-RX 9600

;Symbols:      Byte	Word	   Bits
{
symbol VarA   = b0 	'	bit7 : bit6 : bit5 : bit4 : bit3 : bit2 : bit1 : bit0
symbol VarB   = b1	'w0	bit15: bit14: bit13: bit12: bit11: bit10: bit9 : bit8
symbol VarC   = b2	'	bit23: bit22: bit21: bit20: bit19: bit18: bit17: bit16
symbol VarD   = b3	'w1	bit31: bit30: bit29: bit28: bit27: bit26: bit25: bit24
symbol VarE   = b4	'
symbol VarF   = b5	'w2
symbol VarG   = b6	'
symbol VarH   = b7	'w3
symbol VarI   = b14	'
symbol VarJ   = b15	'w4
symbol VarK   = b16     '
symbol VarL   = b17	'w5
symbol VarM   = b18	' 
symbol VarN   = b19	'w6
symbol VarO   = b20	'
symbol VarP   = b21	'w7
symbol VarQ   = b22	'
symbol VarR   = b23	'w8
symbol VarS   = b24	'
symbol VarT   = b25	'w10

symbol Timer  = time

'       Hardware aliases 
'symbol ???    = c.1
'symbol ???    = c.2
'symbol sw1    = pinc.4
'symbol sw2    = pinc.3
}

	'	pins = x : x : x : pin4 : pin3 : pin2 : pin1 : x
	'
	'	dirs = x : x : x : dir4 :   x  : dir2 : dir1 : x
	'
          dirsC = %00000100

	'  Initialise serial and Digole Serial HD44780 LCD board.
	'  Digole always boots up at 9600, N,8,1.
	'  9600 is about as fast as an 8m2 can go.
	'  So start the 8m2 at 9600_8, init Digole to 2400 
	'  then slam the 8m2 back to 4 meg, then set hserial down to 2400.
	'  This should divide the work needed by the M2 by 4 leaving time for other tasks.

	hsersetup B9600_8,%00	' Hardware serial port to 9600 @ 8meg, non inverted.
	setfreq m8			' 8M2 to 8 meg clock.
	pause 3000			' Pause 3 sec to read the Digole startup text.
	hserout 0,("CL")		' CLear LCD.
	hserout 0,("SB2400")	' Set Baud rate of Digole to 2400.
	
	pause 100			' We need time to change gears !
	
	setfreq m4			' 8M2 clock to 4 meg.
	hsersetup B2400_4,%00	' Hardware serial port now 2400 @ 4 meg , non inverted.
	hserout 0,("TP",0,0)	' Sets next character location 0,0 ( line 1 , character 1).
	hserout 0,("TT","Now 2400 Baud",0,10,13) '  "Now 2400 Baud" on LCD .
	Pause 2000
	hserout 0,("TP",0,1)	' 0= Character 1 , 1= line 2
	hserout 0,("TT","* <-CHR 0,line 2",0,10,13) ' text on LCD
	pause 2000
	hserout 0,("TP",0,0)	' next text will start from character 1, line 1.
	hserout 0,("TT","              ",0,10,13) ' 14 spaces to clear line 1.
	hserout 0,("TP",6,0)	' next text will start from character 7, line 1
	hserout 0,("TT","* <-C7,L1",0,10,13)  ' text on LCD.
	
	stop
	
	'   "Memory used = 192 bytes out of 2048"
end
 

Attachments

Last edited:

srnet

Senior Member
I dont understand why you are driving the Digole adapter at 2400, even the graphic version (text display on a 128x64 graphic LCD) works just fine at 9600 baud, so I would expect the character based displays to work as fast as you can drive them.

From the program;

' So start the 8m2 at 9600_8, init Digole to 2400
' then slam the 8m2 back to 4 meg, then set hserial down to 2400.
' This should divide the work needed by the M2 by 4 leaving time for other tasks.
Other way around I would think, slower baud rates take longer to send, leaving less time for other stuff.
 

Zukjeff

New Member
Thanx srnet, that through did enter my mind but being new to Picaxe ( 1 week now) i was not sure if the internal routines are interupt driven or not...per bit , per byte...

Oh well , forget it saving cycles, think of it as a working example of using the Digole on a picaxe.

ill talk to it with I2C next...
 

srnet

Senior Member
In general when you send a serial output to a serial device;

hserout 0,("TT","Now 2400 Baud",0,10,13)

Your program will wait until the whole line is sent before carrying on.

So the faster the baud rate the better, program spends less time sending stuff to the display.

Try the I2C if you want, but with the 08M2 running at 32Mhz, you can use serout up to 38400 baud, I would expect the Digole driver to cope.

I would be inclined to try hserout at 115200 baud, you would expect it to work, and not only would this likely be as fast (or faster) than the I2C, its a lot easier to send text strings to the LCD.

So if you try that whilst you have it on the bench, it would be useful information for others,
 

Goeytex

Senior Member
Congrats on getting it working .

However I agree with srnet in that it is certainly unnecessary and even counterproductive to "slam the 8m2 back to 4 meg" to operate the display at 2400 Baud as this only reduces the performance of both the Picaxe and the Display. There is more time to "do other things" when the Picaxe is operating at a higher speed.

For starters I would set the Picaxe to 32Mhz and hersetup to B9600_32. If all is well, then crank up the serial data rate as fast as it will go without data corruption. But remember that at 32MHz, "pause" will be ~8 times faster than at 4Mhz. So to get an ~100 ms pause you will need to use "pause 800" instead of "pause 100."

Once you get things optimized, maybe you could post final code in the Finished Projects area of the Forum. I'm sure it will be greatly appreciated since displays seem to be a stumbling block for many.

Side Note: The variable comments need to be corrected for B14 - B25. (Should be w7 - W12)

Also could you provide a link to the exact Digole adapter that you are using?
 

srnet

Senior Member
Also could you provide a link to the exact Digole adapter that you are using?
I know which one, I have a couple here yet to be tested.

The character LCD drivers are however a direct competitor to the AX133Y, and £3.34 delivered off eBay, so links might not be welcome.

The graphics version that turns a cheap 128x64 graphics LCD into a 21 character x 7 line display beats the pants off using a character display, as well as graphic drawing stuff you can use a smaller or larger font to get more or less characters on screen.
 
Top