OLED 20*4 Display

Bill.b

Senior Member
Hi

is to possibe to change the baud rate to then 18m2 on then axe 133 board.

the frequency is set at 16meg this should allow a baud rate of 9600

I find the updating of the display to slow for the application I require.

regards

Bill
 

nick12ab

Senior Member
Click here for the code and do a find-and-replace for setfreq m16 replacing with setfreq m32.

Other members have reported that using the module at 9600 baud even at 32MHz doesn't work very well so first see if 4800 baud at 32MHz is good enough.
 
Last edited:

marks

Senior Member
I do prefer using 4800 baud with the m2's no need for any pauses

Try this if your game to try 9600 bps on your OLED .
You do need to play with the pauses but if you can live with it lol!
We can send a stream of upto 20 characters with this example.
Code:
#picaxe 18m2  ' version 2.A * Testdrive OLED 20x4 Serial driver * marks
SETFREQ M32
 pause 360                     ' powerup delay
 serout b.0,n9600_32,(254,1)   ' Command Clear Display
 pause 4 
                                 
Main:
 
serout b.0,n9600_32,(254,192)   ' Command Line 2 Cursor Position
 pause 4                         
serout b.0,n9600_32,("* *   9600 bps. * * ") 'send upto 20 characters
 'pause ?                       ' pause may be required if only sending a few characters
serout b.0,n9600_32,(254,$21)   ' Control C0 high
 pause 33                       ' seems to be minimum needed after we control an output
              
serout b.0,n9600_32,(254,192)   ' Command Line 2 Cursor Position
 pause 4
serout b.0,n9600_32,(" * *  9600 bps.  * *") 

serout b.0,n9600_32,(254,$20)   ' Control C0 low  
 pause 33
goto main
Code:
	#picaxe 18m2    'version 2.A  * 8 BIT SERIAL DRIVER OLED/LCD FRIENDLY 9600 baud * marks							
	#terminal off   'version 2.D  * tested O.K. also *	
'            DB7  = B.7	
'            DB6  = B.6	
'            DB5  = B.5	
'            DB4  = B.4	
'            DB3  = B.3	
'            DB2  = B.2	
'            DB1  = B.1		
'            DB0  = B.0
      SYMBOL Rx   = C.5
      SYMBOL E    = C.6			                  
      SYMBOL RS   = C.7			                  
	SYMBOL senddata    = b0	 SYMBOL sentdata    = b0
	SYMBOL index       = b1
	SYMBOL batV        = b2 
	SYMBOL ADCval      = b3
        SYMBOL D1          = b4 
	SYMBOL D2          = b5 
	EEPROM 0 ,($38,$38,$38,$C,$1,$2,$6)'(Function 8bit/2line/5x8)(Display On)(Clear Display)(Return Home)(Entry Mode Set)   
	                                   '                                                       16  8  4  2  1 
      EEPROM 10,(6 ,9 ,9 ,6 ,0 ,0 ,0 ,0) ' load custom character (o) =0                           *  '  '  '  *  17
      EEPROM 18,(14,17,17,31,17,17,0 ,0) ' load custom character (A) =1                           *  *  '  *  *  27
      EEPROM 26,(30,17,17,30,16,16,0 ,0) ' load custom character (P) =2                           *  '  *  '  *  21
      EEPROM 34,(17,27,21,17,17,17,0 ,0) ' load custom character (M) =3                           *  '  '  '  *  17
      EEPROM 42,(14,17,16,16,17,14,0 ,0) ' load custom character (C) =4                           *  '  '  '  *  17
      EEPROM 50,(30,16,16,28,16,16,0 ,0) ' load custom character (F) =5                           *  '  '  '  *  17
      EEPROM 58,(0 ,31,1 ,31,16,16,31,0) ' load custom character (2) =6                           '  '  '  '  '  0
      EEPROM 66,(14,10,14,0 ,14,10,10,0) ' load custom character (on)=7                           '  '  '  '  '  0
                                         '                                                     custom character example (M)=3
	CALIBADC10 ADCval
      SETFREQ M32
 	dirsB = %11111111			
 	dirsC = %11001111			
 	batV = 10475 / ADCval
      BinToAscii batV,D2,D2,D1 
      
Initialise: 	
	FOR  index = 0 to 6                                               
          READ index, senddata : pinsB = senddata : PULSOUT E,1 ' Initialise OLED/LCD	
 	NEXT index : PAUSE 10
 	
DisplaySupply:
	HIGH RS
	
      FOR  index = 0 TO 15
 	    LOOKUP index,("     Supply ",D2,".",D1,"V"),senddata 
 	                           pinsB = senddata : PULSOUT E,1 ' sending characters to line one 
      NEXT index

LoadCustomCharactersFromEEPROM:
       LOW RS : senddata = $40 : pinsB = senddata : PULSOUT E,1 : HIGH RS ' Load Characters to LCD
       	
 	FOR  index =10 TO 73                 
 	    READ index, senddata : pinsB = senddata : PULSOUT E,1 ' sending characters to LCD      
 	NEXT index    
 
 TestCustomCharacters:
       LOW RS  :senddata = 192 : pinsB = senddata : PULSOUT E,1 : HIGH RS '(192-211) Line 2 Cursor Position
 
      FOR  index = 0 TO 14
 	    LOOKUP index,("Test ",0,1,2,3,4,5,6,7,32,223),senddata 
 	                           pinsB = senddata : PULSOUT E,1 ' sending characters to line two 
      NEXT index

Main:
     bptr=28
   SERIN Rx,N9600_32,@bptr
   IF @bptrinc = 254 THEN Commands
   SERIN [10],Rx,N9600_32,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc
    @bptr = 254
     bptr = 28
       do until @bptr = 254
         pinsB = @bptrinc : PULSOUT E,1
       loop
   GOTO Main
   
Commands:
   SERIN Rx,N9600_32,sentdata
   pinsB = sentdata 
   index = sentdata / 16: IF index = $2 then Control
   LOW RS
    PULSOUT E,1
   HIGH RS 
    GOTO Main
    
Control: 
   SELECT CASE sentdata
   case  $20  low c.0
   case  $21 high c.0
   case  $22  low c.1
   case  $23 high c.1
   case  $24  low c.2
   case  $25 high c.2
   END SELECT
    GOTO Main
 

srnet

Senior Member
the frequency is set at 16meg this should allow a baud rate of 9600
Or maybe not, it can only do what it can do.

One issue that you will run into is that as the clock speed of the sending device rises, the gaps between characters falls, and its this gap (and not the baud rate in particuilar) that the AXE133 has to send the character to the OLED and get back in time to be ready for the start of the next character.

Thus if the sending device is a PICAXE there will be a clock speed (for the sending PICAXE) at which point the AXE133 cannot keep up, regardless of baud rate.
 

g6ejd

Senior Member
Has anyone tried compiling the same code to a lower level, that should (I have not studied the compiler yet) remove the interpreter overheads. Although some compilers still use a pseudo code and run that interpreted, so maybe no advantage.
 

srnet

Senior Member
I did make some timings recently, although I cant remember if they were from the trailing edge of one bit to the leading edge of the next, or if they are from the last stop bit sample time to the next start bit sample time.

Anyway, these timings are indicitive of the gaps between chartacters, which is the time the AXE133 has to write a character, these are for an 08M2 sender.

Frequency, Baud, Character gap time

4Mhz, 4800, 1810uS
8Mhz, 4800, 1090uS
16Mhz, 4800, 780uS
32Mhz, 4800, 590uS

8Mhz, 9600, 910uS
16Mhz, 9600, 550uS
32Mhz, 9600, 380uS

Thus I hope you can see that a PICAXE sender running at 32Mhz and using 4800baud leaves only 590us to process the character, whilst a PICAXE sender running at 8Mhz and using the faster 9600baud has more time, 910uS, for the AXE133 to process the character.
 

srnet

Senior Member
Has anyone tried compiling the same code to a lower level, that should (I have not studied the compiler yet) remove the interpreter overheads. Although some compilers still use a pseudo code and run that interpreted, so maybe no advantage.
I did a replacement for the 18M2 in compiled Mikrobasic.
 

srnet

Senior Member
The Modified OLED is working quite happily in my portable morse decoder, whilst being driven by a 64Mhz 28x2 at 38400baud.
 
Top