Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT not LCDOUT ? — Parallax Forums

SEROUT not LCDOUT ?

greengluegreenglue Posts: 22
edited 2011-11-10 18:21 in BASIC Stamp
Hi!
I have a OLED display from another microcontroller and all is working fine, but is there a way to clear the screen with SEROUT? It is connecting to my BS2 with 1 wire (on pin 0) and the ground and 5V. Also, why wouldn't I be able to use LCDOUT on the BS2, it says it needs at least a BS2p?

Thanks!
Michael

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 04:36
    I believe you are trying to interface with the PICAXE AXE133 OLED correct?

    If so, that is a serial device not a standard Hitachi 44780 parallel LCD. The BASIC Stamp LCDOUT command is for use with parallel displays.

    You need to use serout with a serial LCD and various serial LCD displays have different command sets.

    The AXE133 uses an ascii 254 followed by a an ascii 1 and a 30 millisecond pause - see page 3 http://www.picaxe.com/docs/axe133.pdf
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-10 10:03
    The BS2 does not have an LCDOUT statement. Only the BS2p, BS2pe, and BS2px have the LCD statements. The Basic Stamp Syntax and Reference Manual, at the beginning of each chapter on each of the PBasic statements, shows which models of the Stamp have that statement.
  • sylvie369sylvie369 Posts: 1,622
    edited 2011-11-10 12:10
    Similarly, the PBASIC help files have alphabetical and by type lists of PBASIC commands, with color-coded indicators off to the left of the lists that show which of the Stamp modules each can be used on.
  • greengluegreenglue Posts: 22
    edited 2011-11-10 12:50
    I believe you are trying to interface with the PICAXE AXE133 OLED correct?

    If so, that is a serial device not a standard Hitachi 44780 parallel LCD. The BASIC Stamp LCDOUT command is for use with parallel displays.

    You need to use serout with a serial LCD and various serial LCD displays have different command sets.

    The AXE133 uses an ascii 254 followed by a an ascii 1 and a 30 millisecond pause - see page 3 http://www.picaxe.com/docs/axe133.pdf

    Yes! It is the PICAXE AXE133Y OLED! How did you know?! Anyways, I type this code into my editor and upload it to the BS2, but, no success:
    SEROUT 0,16780,[254,1]
    PAUSE 30
    SEROUT 0,16780,[254,128]
    SEROUT 0,16780,["Test!"]
    
    any idea why?
    Thanks!
    Michael
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 13:27
    greenglue wrote: »
    Yes! It is the PICAXE AXE133Y OLED! How did you know?!

    Because I am a member of the PICAXE forum also.

    The test code in the AXE133Y manual is
    [B][FONT=Courier-Bold][SIZE=1][COLOR=#001cb8][FONT=Courier-Bold][SIZE=1][COLOR=#001cb8][FONT=Courier-Bold][SIZE=1][COLOR=#001cb8] [LEFT][FONT=arial][SIZE=2]init: pause 500 ; wait for display to initialise[/SIZE]
    [SIZE=2]main: serout B.7,N2400,(254,128) ; move to start of first line[/SIZE]
    [SIZE=2]serout B.7,N2400,(“Hello!123”) ; output text[/SIZE][/FONT][/LEFT]
    
    [FONT=arial][SIZE=2]end
    [/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/B]
    

    The N2400 in the PICAXE code means inverted 2400 baud and the16780 in the BS2 code also is correct for inverted 2400 baud.

    Maybe you need to insert a PAUSE 500 like the example. I that doesn't try 396 for True serial rather than inverted...
  • greengluegreenglue Posts: 22
    edited 2011-11-10 13:37
    Doesn't seem to be working:
    PAUSE 500
    SEROUT 0,16780,[254,1]
    PAUSE 30
    SEROUT 0,16780,[254,128]
    SEROUT 0,16780,["Test!"]
    PAUSE 10
    

    I've tried with both baud rates...
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 13:46
    Are you powering it from the same 5 Volt power supply as the BS2? If not, you need a common ground between the BS2 and the LCD for serout to work...
  • greengluegreenglue Posts: 22
    edited 2011-11-10 13:53
    Looks like there is some sort of problem with the OLED, looking into it now....it seems to not turn on the screen but yet I can program the PICAXE 18M2 on it with the PICAXE software...
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 13:56
    greenglue wrote: »
    Looks like there is some sort of problem with the OLED, looking into it now....it seems to not turn on the screen but yet I can program the PICAXE 18M2 on it with the PICAXE software...

    If you program the 18M2 you are overlaying the program code used to drive the LCD!! Did they provide you with the code orginally loaded to the 18M2?
  • greengluegreenglue Posts: 22
    edited 2011-11-10 13:57
    Yep, the screen part is broken I think, since I can still program the onboard microcontroller (18M2). Any ideas why this could happen? I am powering it with direst power so it's not like the serial data is now being outputted...
  • greengluegreenglue Posts: 22
    edited 2011-11-10 13:59
    Nono!! I am keeping the sample code from the PICAXE site on the 18M2, the code that I have been using above is being put into the BS2. The code cam originally loaded and it worked fine, it showed serial oled picaxe.com, etc... But now it doesn't work...
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 14:10
    Again - the PICAXE 18M2 on the LCD board has (or had) a special program that controls the display. You should NOT load your own program onto the PICAXE.

    Do you have the original code which was loaded onto the PICAXE when you received it?
  • greengluegreenglue Posts: 22
    edited 2011-11-10 14:11
    Yes I know, I am reloading the ORIGINAL program on it, the one that came with it. I found it through the PICAXE site. Here is the code that is on the 18M2:
    ; AXE133 Serial LCD/OLED using PICAXE-18M2; Emulates basic serial operation of the popular AXE033 module
    ; CPS, May 2011
    
    
    ; Supported Commands
    ; 0-252	normal ASCII characters
    ; 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
    
    
    #picaxe 18M2
    
    
    #define use_welcome	; display the welcome message upon power up
    #define use_OLED		; enable this line for Winstar OLED modules
    
    
    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
    #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		
    		
    ; 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 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 = %00111001 	; 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 = %00000011	; Entry mode
    	pulsout enable,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 into b1
    		let pinsB = b1 		; output the data
    		pulsout enable,1  	; pulse the enable pin to send data.
    	next b4				; next loop
    	return
    
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 14:19
    Good! I was afraid you loaded some other code which clobbered the display driver code...

    What BS2 board are you using? (e.g Board of Education, Carrier Board, HomeWork Board, Professional Development board. etc).
  • greengluegreenglue Posts: 22
    edited 2011-11-10 14:22
    Board of Education USB - Rev. D
    It doesn't even work wehen I connect it to direst power, not through the Board of Education...
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 14:40
    I would make sure the PICAXE programming cable is not connected while you are using the display with the BS2.
    So you have the display V+ and ground connected to the Board of Education 5V+ and ground and the display "IN" wire connected to pin 0 on the BS2 - right?

    If so, I don't know what else to try. Did you ever test the display with a serial connection to second PICAXE chip (not the 18M2 on the display board)?

    What did you mean you connected it to direct power - batteries (nothing greater that 5 volts I hope)
  • greengluegreenglue Posts: 22
    edited 2011-11-10 14:44
    Yup, all connections are good. I have even tried with another PICAXE and doesn't work. The weird thing is it worked with the PICAXE yesterday but doesn't work at all today. The programming cable is also unplugged. I guess I will need to buy a new screen. :(
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 14:57
    greenglue wrote: »
    Yup, all connections are good. I have even tried with another PICAXE and doesn't work. The weird thing is it worked with the PICAXE yesterday but doesn't work at all today. The programming cable is also unplugged. I guess I will need to buy a new screen. :(

    If you hooked it up to the Board of Education VIN connection instead of the 5V, you might have burned it out (the display and/or 18M2).
  • greengluegreenglue Posts: 22
    edited 2011-11-10 15:27
    I don't remember connecting it to VIN I have always connected it to VDD. Maybe all of the baud rate testing and SEROUT testing from last night messed it up. I guess I will need to buy a new one. Recommend any good ones compatible with the SEROUT command, and hopefully can be somewhat out of the box so all I need to type is SEROUT PIN,BAUD,["It works!"] and no 254,1 stuff like that?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 15:36
    greenglue wrote: »
    I don't remember connecting it to VIN I have always connected it to VDD. Maybe all of the baud rate testing and SEROUT testing from last night messed it up. I guess I will need to buy a new one. Recommend any good ones compatible with the SEROUT command, and hopefully can be somewhat out of the box so all I need to type is SEROUT PIN,BAUD,["It works!"] and no 254,1 stuff like that?

    I have several serial LCD modules - they all use control codes to clear the screen, control and place the cursor, etc, etc.

    I like NewHaven displays but be careful - some "serial" displays are SPI not RS232.

    Not sure where you bought your AXE133Y but PHANDERSON http://www.phanderson.com/picaxe/ sells them.
  • greengluegreenglue Posts: 22
    edited 2011-11-10 17:21
    Thanks for the link of NewHaven! I might just order more OLED screens from PICAXE or even just LCD w/o the backlight since it's cheaper. But the good thing is that it comes with a backpack so no need to use 14 or 16 wires to program the screen, use 1 wire and 0V.

    Do you know if this screen comes with some sort of backpack like on the 133Y? http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/52/Default.aspx
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-10 17:27
    greenglue wrote: »
    Thanks for the link of NewHaven! I might just order more OLED screens from PICAXE or even just LCD w/o the backlight since it's cheaper. But the good thing is that it comes with a backpack so no need to use 14 or 16 wires to program the screen, use 1 wire and 0V.

    Do you know if this screen comes with some sort of backpack like on the 133Y? http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/52/Default.aspx

    Just go to that link and scroll down to find the docs link...
  • greengluegreenglue Posts: 22
    edited 2011-11-10 18:21
    Just go to that link and scroll down to find the docs link...

    Looks like I will be ordering a couple of those! Especilly since they have a backpack, with a peizo!!!
Sign In or Register to comment.