Oled axe133y

bassbig

New Member
Hi

I have been trying to write a programme to scroll a 72 character message across the screen using my picaxe PICAXE-18M2 and picaxe editer software but have now given up and asking any member if they have a programme they can let me have that will do the job

I am 79 years old and have left it to late to learn new tricks so any help you can give would be greatly appreciated

John
 

The bear

Senior Member
@ bassbig,
Welcome to the forum.
You are not considered old on this forum, at least prior to 100.
More info = More help.

Go for it, its too technical for me.
Regards, bear..
 

hippy

Technical Support
Staff member
I thought there were examples on the forum but couldn't find them. Here's one way to do it. Not tested on real hardware but seems to work in simulation -

Code:
#Picaxe 18M2

#Define text     "This is a long line of text. "

Symbol LCD       = B.7
Symbol LCD_BAUD  = N2400

Symbol startChar = w0 ; b1:b0
Symbol textLen   = w1 ; b3:b2
Symbol index     = w2 ; b5:b4
Symbol column    = b6
Symbol char      = b7

Pause 1000
SerOut LCD, LCD_BAUD, (254,1)
Pause 1000

; Determine text length
textLen = 0
Do
  LookUp textLen,(text,0),char
  textLen = textLen + 1
Loop Until char = 0

; Scroll the text
startChar = 0
Do
  SerOut LCD, LCD_BAUD, (254,$80)
  For column = 0 To 15
    index = startChar + column // textLen
    LookUp index, ( text ), char
    SerOut LCD, LCD_BAUD, (char )
  Next
  startChar = startChar + 1
  Pause 250
Loop
The text can be any length you want; just edit the text definition at the top. Adjust the PAUSE at the end to adjust speed of scrolling.
 

bassbig

New Member
Hi

Thanks for your help worked well when first downloaded to my hardware.

The only problem I am having is when I turn the hardware off and back on I have on line 2 of the oled part of the the standard message www.picaxe.com. This is not there when first downloaded

I obviously need an instruction to clear line 2 but have not found a solution so can you please help again

Regards John
 

hippy

Technical Support
Staff member
A SerOut LCD, LCD_BAUD, (254,1) should clear the entire display.

Note there should be a half second or so PAUSE before that to allow the display to be ready for data and another short PAUSE after issuing that to allow time for the display to be cleared before any subsequent data is sent.
 

darb1972

Senior Member
Hello John

Welcome to the forum. Never too late to learn. Plenty of very helpful folk on this forum. No question is frowned upon. Separate to this enquiry, some helpful (future) advice is ensure you provide as much info as possible (often full code, schematics etc) so that those assisting have all the facts.

Further to the advice from Hippy and Westie, not sure if you are programming the 18M2 that handles the firmware and drives the display (the PICaxe on the piggyback board on the AXE133Y) or if you have a seperate 18M2?

If you are programming the piggyback 18M2 (the firmware chip) you can manipulate the firmware (with care) to clear and/or alter such messages. If for no other reason, download the firmware (from the PICaxe website) and take a look at the clever code used to run the display. For now, you don't need to understand all of (I still stuggle with complex code) but from a beginners perspective, looking at such code is an eye opener and you might learn a few things. In the code you will find the "message" section and you can make changes there and reload the firmware into the 18M2 firmware chip. Don't worry if you make a mistake, it can be corrected and learning is about doing. From memory the code is well commented so you can follow what the code is meant to do.

Good luck and let the forum members know if you need more help/assistance.

Regards
Brad
 

bassbig

New Member
Hi Brad

I am loading the programme into the Picaxe 18m2 starter pack and have the serial OLED connected to that. I have never tried loading a programme to piggyback board on the AXE133Y) What should I be doing.

Can you give me a link to download the firmware (from the PICaxe website)

Thanks for your help

John
 

darb1972

Senior Member
Hello John

Sorry, I wrote the last email on my tablet so adding links is a bit hard.

On the laptop now.

You can connect your programming lead directly to the 3.5mm programming port on the back of the display (on the piggyback board) to download the altered firmware.

Here's the link to the firmware. http://www.picaxe.com/Hardware/Add-on-Modules/Budget-Serial-OLED-Module/. Click on the resources tab. Download the firmware. Copy it into the Editor. Take a look at it. The firmware is really well commented and should make a great deal of sense to even a beginner (but don't be too concerned if some of it doesn't click).

Here's the code in full.

I'm no code guru, but I have highlighted (in RED) the section that you should REM/Comment out OR, alternatively, you can leave this section in play and change the comments stored in the EEPROM part of the PICaxe (see the messages section of the code). Others might have a better approach. This alters the messages "at the source" as opposed to clearing the display. Either will work.


Code:
; AXE133 Serial LCD/OLED using PICAXE-18M2
; Emulates basic serial operation of the popular AXE033 module
; CPS, May 2011
; v2 18/01/2012

#picaxe 18M2

; ********************************************
; Note you must uncomment just one of these two options
; depending on whether you have an LCD or OLED module
#define use_OLED
;#define use_LCD
; ********************************************


; Supported Commands
; 0-7, 8-15	CGRAM characters
; 16-252	normal ASCII characters, according to selected character map table
; 253, X	display 16 character pre-saved message from EEPROM memory, X can be 0-15
; 254, X	LCD command, X can be 0 to 255 
; 255, X	control outputs C.2, C.1, C.0 (via lower 3 bits of X)
;		So, if using a backlit LCD with the active low transistor driver
;		on output C.2, then 255,%000 switches backlight on and 255,%100 switches off


#define use_welcome	; display the welcome message upon power up
symbol line_length = 16	; change to 20 for displays with 20 character lines

symbol baud = N2400_16	; Serial baud rate 2400,N,8,1. Note main program runs at 16MHz

symbol spare0 	= C.0 ; spare output 0
symbol spare1 	= C.1 ; spare output 1
symbol spare2 	= C.2 ; spare output 2 (or optional backlight)
symbol backlight 	= C.2 ; optional backlight control for backlit LCDs, active low
symbol RX		= C.5	; serial receive pin
symbol enable 	= C.6	; LCD enable
symbol rs 		= C.7	; LCD RS 


; LCD data pins are on B.0 to B.7

; Store the 16 character user defined messages in EEPROM data memory
; First two messages are optionally used as welcome message

; If using a display with 20 characters you will need to edit 
; the start addresses to be multiples of 20 (currently at 16) 
; and add 4 characters to each message.
; Please remember 4 line displays always use the strange 1-3-2-4 layout.

#ifdef use_OLED		
EEPROM $00, ("  Serial OLED   ") 	; store msg in the EEPROM memory
#else
EEPROM $00, ("   Serial LCD   ") 	; store msg in the EEPROM memory
#endif


EEPROM $10, (" www.picaxe.com ") 	; store msg in the EEPROM memory

EEPROM $20, ("This is msg 2   ") 	; store msg in the EEPROM memory
EEPROM $30, ("This is msg 3   ") 	; store msg in the EEPROM memory
EEPROM $40, ("This is msg 4   ") 	; store msg in the EEPROM memory
EEPROM $50, ("This is msg 5   ") 	; store msg in the EEPROM memory
EEPROM $60, ("This is msg 6   ") 	; store msg in the EEPROM memory
EEPROM $70, ("This is msg 7   ") 	; store msg in the EEPROM memory
EEPROM $80, ("This is msg 8   ") 	; store msg in the EEPROM memory
EEPROM $90, ("This is msg 9   ") 	; store msg in the EEPROM memory
EEPROM $A0, ("This is msg 10  ") 	; store msg in the EEPROM memory
EEPROM $B0, ("This is msg 11  ") 	; store msg in the EEPROM memory
EEPROM $C0, ("This is msg 12  ") 	; store msg in the EEPROM memory
EEPROM $D0, ("This is msg 13  ") 	; store msg in the EEPROM memory
EEPROM $E0, ("This is msg 14  ") 	; store msg in the EEPROM memory
EEPROM $F0, ("This is msg 15  ") 	; store msg in the EEPROM memory

;initialise LCD
init:
	gosub LCD_init 		; initialise LCD

; display welcome message if desired
[COLOR="#FF0000"]#ifdef use_welcome	
	let b1 = 0			; message 0 on top line
	gosub msg			; do it

	low rs			; command mode
	let pinsB = 192		; move to line 2, instruction 192
	pulsout enable,1  	; pulse the enable pin to send data.
	high rs			; character mode again
	
	let b1 = 1			; message 1 on bottom line
	gosub msg			; do it
#endif		[/COLOR]
		
; main program loop, runs at 16MHz

main:

	serin RX,baud,b1			; wait for the next byte

	; NB keep character mode test as first item in this list to optimise speed
	if b1 < 253 then
		let pinsB = b1 		; output the data
		pulsout enable,1  	; pulse the enable pin to send data.
		goto main			; quickly loop back to top
	else if b1 = 254 then
		low rs 	     		; change to command mode for next character
		serin RX,baud,b1		; wait for the command byte
		let pinsB = b1 		; output the data
		pulsout enable,1  	; pulse the enable pin to send data.
		high rs			; back to character mode
		goto main			; quickly loop back to top
	else if b1 = 253 then
		serin RX,baud,b1		; wait for the next byte
		gosub msg			; do the 16 character message
		goto main			; back to top
	else ; must be 255
		serin RX,baud,b1		; wait for the next byte
		let pinsC = b1 & %00000111 | %10000000
						; output the data on C.0 to C.1, keep RS high
		goto main			; back to top
	end if


; power on LCD initialisation sub routine
LCD_init:
	let dirsC = %11000111	; PortC 0,1,2,6,7 all outputs
	let dirsB = %11111111	; PortB all outputs
	

	
#ifdef use_OLED
	; Winstar OLED Module Initialisation
	; according to WS0010 datasheet (8 bit mode)

	pause 500 			; Power stabilistation = 500ms

	; Function set - select only one of these 4 character table modes
	;let pinsB = %00111000 	; 8 bit, 2 line, 5x8 , English_Japanese table
	let pinsB = %00111001 	; 8 bit, 2 line, 5x8 , Western_European table1
	;let pinsB = %00111010 	; 8 bit, 2 line, 5x8 , English_Russian  table
	;let pinsB = %00111011 	; 8 bit, 2 line, 5x8 , Western_European table2
	
	pulsout enable,1  	; 
		
	let pinsB = %00001100	; Display on, no cursor, no blink
	pulsout enable,1 	

	let pinsB = %00000001 	; Display Clear
	pulsout enable,1
	pause 7			; Allow 6.2ms to clear display

	setfreq m16			; now change to 16Mhz

	let pinsB = %00000010 	; Return Home
	pulsout enable,1

	let pinsB = %00000110 	; Entry Mode, ID=1, SH=0
	pulsout enable, 1


#else	
	; Standard LCD Module Initialisation
	pause 15 			; Wait 15ms for LCD to reset.

	let pinsB = %00110000 	; 8 bit, 2 line
	pulsout enable,1  	; Send data by pulsing enable
	pause 5 			; Wait 5 ms
	pulsout enable,1 	 	; Send data 48 again
	pulsout enable,1  	; Send data 48 again
	
	setfreq m16			; now change to 16Mhz

	let pinsB = %00111000 	; LCD  - 8 bit, 2 line, 5x8  
	pulsout enable,1
			
	let pinsB = %00000001	; Clear Display
	pulsout enable,1 	
	pause 8			; 8 = 2ms at 16MHz
	
	let pinsB = %00000010 	; return home
	pulsout enable,1

	let pinsB = %00000110	; Entry mode
	pulsout enable,1 	
	pause 1			

	let pinsB = %00001100	; Display on, no cursor, no blink
	pulsout enable,1 	
#endif
	
	high rs			; Leave in character mode
	return


; display message from EEPROM sub routine
; message number 0-15 must be in b1 when called
; uses (alters) b1, b2, b3, b4
msg:
	let b2 = b1 & %00001111 * line_length
						; EEPROM start address is 0 to 15 multiplied by 16
	let b3 = b2 + line_length - 1 ; end address is start address + (line_length - 1)
	for b4 = b2 to b3			; for 16 times
		read b4,b1			; read next character from EEPROM data memory into b1
		let pinsB = b1 		; output the data
		pulsout enable,1  	; pulse the enable pin to send data.
	next b4				; next loop
	return
	
; Check end user has defined just one type of display
#ifndef use_OLED
#ifndef use_LCD
#error "Oops - no OLED / LCD type defined at top of program!"
#endif
#endif

#ifdef use_OLED
#ifdef use_LCD
#error "Oops - both OLED / LCD types defined at top of program!"
#endif
#endif
 

bassbig

New Member
Hi Darb

Did as you said and loaded the prog you sent and all appeared to work well but was picking up from a previous prog a message that I had used..

Then big problem the screen went blank.

I could still load other programmes but screen still blank

Have checked wires and all looks ok so do not know what to do from here

Regards confused John
 

darb1972

Senior Member
Hello John

I'm confused too. Let's clarify and simplify a few things. I'm not sure I follow your comment about "picking up from a previous prog a message that I had used.."?

First, disconnect EVERYTHING from the AXE033Y and only load the above program into the piggyback board. If you have commented out the section I highlighted in RED then I believe that a blank screen is CORRECT (no welcome screen). If you then remove the REM/comments from that same section of code, you should get the welcome message back. If you do this does the welcome screen return???

The only reason/function of altering the firmware on the AXE033Y might be to clear or change the welcome screen. I have done this numerous times (without issue). Advanced users can take it a step further and use the 3 spare pins on the 18M2 for additional functions, but I wouldn't recommend that for you at this stage.

Your comment "I could still load other programmes but screen still blank" makes me wonder if you then loaded another program into the 18M2 on the piggyback board. Is that correct? If so, you need to reload the board with the firmware ONLY. You only want to load the altered 18M2 firmware into the piggyback board, then, once it is functioning as intended, connect other circuitry (such as your 18M2 starter board) and then (and only then) should you load YOUR program (not the firmware) into YOUR 18M2 starter kit.

Does that make sense?

If you are still having trouble, I can scratch around and see if I have an AXE033Y floating around and connect it to verify my advice.

Regards
Brad
 

bassbig

New Member
Hi Brad

When I say the screen went blank,it was like turning the power off.

Replaced batteries and wiring but still no sign of life

Is this a case of failure of the screen,

Will have a go at your suggestions and see what happens

John
 

hippy

Technical Support
Staff member
Is this a case of failure of the screen
It would seem unlikely. I would suspect you have ended up with the AXE133Y programmed to do nothing beyond initialising the display.

Re-download the original AXE133Y firmware into the AXE133Y module, and go back to controlling it how you were doing, regardless of whether that was working entirely or not. Then you'll be on a firm foundation to move forward from.

I would suggest getting the PICAXE program which communicates with the AXE133Y via serial working exactly how you want it before taking the leap into modifying and running that code on the AXE133Y itself.
 

bassbig

New Member
Hi hippy

Downloaded the firmware to the AXE133Y and the screen lights up and displays first line " SERIAL OLED" and second line "WWW.PICAXE.COM "
Thanks for your instructions

Now back to try and display a long message scrolling across the screen. Any suggestions????

Regards

John
 

hippy

Technical Support
Staff member
Now back to try and display a long message scrolling across the screen. Any suggestions????
I thought the code in post #3 was working, the only problem being in post#5 that it was leaving the "www.picaxe.com" text on screen after power-on.

If that's the case then simply increasing the PAUSE time at the start of the program, before clearing the screen, should solve that.
 

darb1972

Senior Member
Hello John.

Sorry to hear you encountered issues. Glad to see that Hippy has managed to get you back up and running. Reloading the firmware was what I was suggesting in earlier posts but I probably didn't explain this with sufficient clarity. As Hippy suggested, stick to your original approach as reprogramming the AXE133Y is probably a big leap forward for someone just starting out.

I shouldn't have led you down that path, but at the time thought it was the best solution. I'll still have to connect up an AXE133Y (if I have one) and see if the suggested firmware modification works correctly and, if not, post a correction so I don't lead others astray (should this thread be found in a search).

I hope you get the remainder of your project sorted out. All the best John.

Regards
Brad
 

bassbig

New Member
Hi All

Have followed all the suggestions and now have a prog that scrolls a large message

Copy of prog for anyone interested

#Picaxe 18M2

pause 300
#Define text "All trains are running 45 minutes late due to adverse weather conditions in the mountain passes "

Symbol LCD = B.7
Symbol LCD_BAUD = N2400

Symbol startChar = w0 ; b1:b0
Symbol textLen = w1 ; b3:b2
Symbol index = w2 ; b5:b4
Symbol column = b6
Symbol char = b7

Pause 250
SerOut LCD, LCD_BAUD, (254,1)
Pause 30

; Determine text length
textLen = 0
Do
LookUp textLen,(text,0),char
textLen = textLen + 1
Loop Until char = 0

; Scroll the text
startChar = 0
Do
SerOut LCD, LCD_BAUD, (254,$80)
For column = 0 To 15
index = startChar + column // textLen
LookUp index, ( text ), char
SerOut LCD, LCD_BAUD, (char )
Next
startChar = startChar + 1
Pause 1
Loop

There are probably improvements that can be made but that is something to work on

Thanks again for all the help I have received through the Forum

John
 
Last edited:
Top