Menu

Strange bevavior of ssd1306 Display

bed
2017-08-27
2017-08-28
1 2 > >> (Page 1 of 2)
  • bed

    bed - 2017-08-27

    EDITED BY ANOBIUM.

    This is caused by an error in the Linux version of the compiler. This error is not happening in the Windows version of the compiler.

    Note: Only v0.98.00 support the 128*32 SD1306 OLED devices.

    See https://sourceforge.net/p/gcbasic/discussion/579125/thread/9750951c/?limit=25&page=1#3480
    **** END OF EDITS *****

    My Display is an 128x32 pixel Oled Display.
    But I have a strange bevaior with it
    This is my Demo for showing the issue:

    '''A demonstration program for GCGB and GCB.
    
    ; ----- Configuration
      #chip 18f25k20,16
      #option explicit
      #include <glcd.h>
      ; ----- Define Software settings
      ' Define I2C settings - CHANGE PORTS
       #define I2C_MODE Master
       #define I2C_DATA PORTC.4
       #define I2C_CLOCK PORTC.3
       #define I2C_DISABLE_INTERRUPTS ON
       'Optionally, you can reduce the I2C timings.
       #define I2C_BIT_DELAY 0 us
       #define I2C_CLOCK_DELAY 0 us
       #define I2C_END_DELAY 0 us
    
    ; ----- Define GLCD Hardware settings
      #define GLCD_TYPE GLCD_TYPE_SSD1306
      GLCDfntDefaultsize =2
      GLCDFontWidth= 6
        #define GLCD_WIDTH 128
        #define GLCD_HEIGHT 64
      #define GLCD_I2C_Address 0x78
    
    ' ----- Define variables
      Dim BYTENUMBER, CCOUNT,ii as Byte
    
      CCount = 0
      dim longNumber as long
      longNumber = 123456 ' max value = 4294967290
      dim wordNumber as Word
      dim outstring as string
      wordNumber = 0
      byteNumber = 0
    
    ' ----- Main program
    
     GLCDCLS
        GLCDPrint (0, 16, "DarkDau")
     GLCDPrint ( 72,  0, ChipMhz)                                   ' Print chip speed
     wait 5 s 
     GLCDCLS
      line 0,10,10,63
      line 0,0,127,63
      circle(25,25,8)  'center
      for ii = 0 to 63
        pset 63,ii,1
      next
      for ii = 0 to 31
        pset 80,ii,1
      next  
    
       line 0,15,120,15
    
      end
    

    I draw two lines with pset for 64 an 32 pixels.
    Normally I expect the 32 pix will go over the whol height, but watch the picture.

    The second point is, the Program does not restart with reset it do run after flash when both, pickit and external power is on. I can do a reset, when i diconnect the pickit and reconnet it.
    Other programs are working normally, it seems something to do with my code or with the lib for the display

     

    Last edit: Anobium 2017-08-28
  • bed

    bed - 2017-08-27

    Picture.
    I forgot, using the default font is unreadable, max. 4 pixel hight.
    in whole the problem seems the displays behaves like 128x64 but has physically only 128x32
    Is this strange?!

     

    Last edit: bed 2017-08-27
  • Anobium

    Anobium - 2017-08-27

    Look in the Help.

    You need to use the _32 define for that display.

    And, look at Help to prevent how to prevent glcd screen out of bounds writing. Either your program must ensure the screen parameters are not exceeded or use glcd protect.

     
  • bed

    bed - 2017-08-27

    This is, what I tested first. Then there is nothing, but I will try it again with 0.98 Rc01
    edit: Yes with #define GLCD_TYPE GLCD_TYPE_SSD1306_32
    Nothing is doisplayed, no Reset action.
    Yes I commented out everything with addresses >31

     

    Last edit: bed 2017-08-27
  • Anobium

    Anobium - 2017-08-27

    I have just taken a new 128x32 OLED SDD1306 display from my post bag. Never used this 128x32 before.
    Attached to microcontroller - four wires.
    Used the test program - all worked very well.
    I have updated the demo to support Low Memory Mode - see attached. I will include this demo in the formal release of v0.98.00

    Note: I have no (nothing) attached to the I2C lines. My device has pullups fitted by manufactor. All my SDD1306's have pull-up fitted by the manufactor. Please remove the ones shown in your photo.

    Tested using Great Cow BASIC v0.9.00 RC 1

     

    Last edit: Anobium 2017-08-27
  • Anobium

    Anobium - 2017-08-27

    Specific analysis your code

    You need to review the following:

      #define GLCD_TYPE GLCD_TYPE_SSD1306_32 'not   #define GLCD_TYPE GLCD_TYPE_SSD1306
    
      'Not sure why you are setting these...
    '      #define GLCD_WIDTH 128
     '     #define GLCD_HEIGHT 32           'this WAS 64!!
    
      'Consider using
     #define GLCD_PROTECTOVERRUN
    
      line 0,10,10,63                     'this exceeds Y pos limit of 31
      line 0,0,127,63                     'this exceeds Y pos limit of 31
      circle(25,25,8)  'center            'this exceeds Y pos limit of 31
      for ii = 0 to 63                    'this exceeds Y pos limit of 31
        pset 63,ii,1
      next
    

    If I change the GLCD type and remove the size, add protect overrun - all works as expected.

    And, finally... not sure if release before the v0.98.00 RC1 support 128 * 32.... so, I am surprised it worked. :-)

     
  • bed

    bed - 2017-08-27

    I used this as well:

    #define GLCD_TYPE GLCD_TYPE_SSD1306_32  'for 128 * 32 pixels support
    #define GLCD_I2C_Address 0x78
    ; ----- Configuration
    #chip 18f25k20,16
    #option explicit
    #include <glcd.h>
       'Optionally, you can reduce the I2C timings.
       #define I2C_BIT_DELAY 10 us
       #define I2C_CLOCK_DELAY 10 us
       #define I2C_END_DELAY 10 us
      ; ----- Define Software settings
      ' Define I2C settings - CHANGE PORTS
    #define I2C_MODE Master
    #define I2C_DATA PORTC.4
    #define I2C_CLOCK PORTC.3
        GLCDCLS
        GLCDPrint 0, 0, "Great Cow BASIC"
        GLCDPrint (0, 16, "Anobium 2017")
    

    With GLCD_TYPE GLCD_TYPE_SSD1306_32 No Function at all
    with GLCD_TYPE GLCD_TYPE_SSD1306 it works, but Displayed text is aprox 4 pixel high, of course as I think.

    The pullup Resistors are needed, because my StartPic18 does not have any on board.

    I tried another one of Oled display, same result.

     
  • Anobium

    Anobium - 2017-08-27

    What of version of Great Cow BASIC?

    Any version prior to v0.98.00 does not support this device. Any version of the Linux distribution prior to v0.98.00 RC1 does not work or support this device.

     
  • bed

    bed - 2017-08-27

    $ gcbasic
    Great Cow BASIC - A BASIC compiler for microcontrollers
    Version: 0.98.00 RC01 2017-08-25

     
    • Anobium

      Anobium - 2017-08-27

      Post your ASM and the HEX file from your project, as a ZIP.

       
      • bed

        bed - 2017-08-28

        Will do, today in the late evening

         
  • Anobium

    Anobium - 2017-08-27

    Odd.... Must be chip related.

    I have 18f's working here in hardware and software i2c to the OLED display. If you want them demos I can send.

    Meanwhile, try this....

    ; ----- Configuration
        #chip 18f25k20, 4
        #option explicit
    
        'Set internal clock speed to 4 MHz:
        Set IRCF0 = 1
        Set IRCF1 = 0
        Set IRCF2 = 1
    
        #define I2C_MODE Master
        #define I2C_DATA PORTC.4
        #define I2C_CLOCK PORTC.3
    
        #include <glcd.h>
        #define GLCD_TYPE GLCD_TYPE_SSD1306_32  'for 128 * 32 pixels support
        #define GLCD_I2C_Address 0x78
    
        #define GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
    
        GLCDCLS
        GLCDPrint 0, 0, "Great Cow BASIC"
        GLCDPrint 0, 16, "Anobium 2017"
    
     
    • bed

      bed - 2017-08-28

      Furthermore, I tried a new one never used display yesterday ... it does not work wether _32 or without :-)
      Could it be, that my Displays are somewhat different or defect?

       
  • Joseph Realmuto

    Joseph Realmuto - 2017-08-27

    I have SSD1306_32s working fine with a PIC18F2420. Might want to double check all your connections. On occasion I've had solder joints to resistors break and it caused me a lot of grief because I was checking for software issues instead of hardware issues.

     
  • Anobium

    Anobium - 2017-08-27

    And, try this HEX. Produced by the Windows compiler.

        #chip 18f25k20, 64
        #option explicit
    
        #define I2C_MODE Master
        #define I2C_DATA PORTC.4
        #define I2C_CLOCK PORTC.3
    
        #include <glcd.h>
        #define GLCD_TYPE GLCD_TYPE_SSD1306_32  'for 128 * 32 pixels support
        #define GLCD_I2C_Address 0x78
    
        #define GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
    
        GLCDCLS
        GLCDPrint 0, 0, "Great Cow BASIC"
        GLCDPrint 0, 16, "Anobium 2017"
    
     
  • stan cartwright

    stan cartwright - 2017-08-27

    Hi bed,I notice #define glcd_height 64 in your code. The ssd1306.h should work for a 128x32 if the screen display layout is the same just remember it's less pixels. You could change the buffer_alias to 512 in the include. There's been a lot of changes in glcd recently so probably sorted.
    I've had the problem of the display initing on flash but not on reset but I seems to have resolved itself.
    I'd be interested to know if they use the same display codes and it's "just" display size difference.

     
    • Anobium

      Anobium - 2017-08-27

      @Stan. Please read the release notes.

      DO NOT change the buffer. We know what we are doing.
      We have changed the INIT. Look in the release note for this change.
      It is NOT just display difference. We have extensively change the GLCD SH1106 and SDD1306 driver. Memory can be 0, 128, 512 or 1024 bytes.
      Changing the library at this stage of root cause analysis is not the to find the core issue.

       
    • bed

      bed - 2017-08-28

      I played with glcd_height because of my trouble with the display, also tried some others.
      Sometimes the brightness is far lower than normal, when powered with usb. So my claim "ITS RUNNING WITH USB POWER and PICKIT ONLY" is not correct

       
  • Joseph Realmuto

    Joseph Realmuto - 2017-08-27

    I've had also had the problem where the program doesn't restart if you turn the power off and then turn it back on shortly after. It will restart after it's been sitting a while. The reason is that the PIC draws very little power once the voltage drops low enough for the oscillator to stop. Therefore, the registers stay in whatever state they were in, and when you power it back up it often doesn't initialize because it hasn't really shut down completely. Solution is to short GND and Vcc after you turn the power off to ensure the voltage drops to zero. Or you can put something like a 10K resistor between GND and Vcc. This won't draw much power when the circuit is operating, but it will drain the voltage when the device is turned off.

     
    • bed

      bed - 2017-08-28

      Looks like a good plan. In my dev Board there is an 100nF Capacistor to reset parallel which is not recommended by microchip IIRC, will tkae it out.
      But I am short of time these days, so it could last a few days

       

      Last edit: bed 2017-08-28
  • Joseph Realmuto

    Joseph Realmuto - 2017-08-27

    @Stan-The initialization routine is practically the same for both the SSD1306 and SSD1306_32 other than buffer size and a few parameters which tell the chip the display is 128x32 instead of 128x64.

     
    • Anobium

      Anobium - 2017-08-27

      In all cases. Do not change the buffer without asking Joe or me. We will advise whether the change is recommened.

       
  • stan cartwright

    stan cartwright - 2017-08-27

    Well I hope bed gets it working.I was going to ask if he was using latest ssd1306 lib.
    Joseph Realmuto, thanks for saying the init is much the same...ish.
    I think you like these displays like I do. No harm in changing lib for own use but can't publish or it would like arduino... many libs for same device..each "improved". fnarr

     

    Last edit: stan cartwright 2017-08-27
  • Anobium

    Anobium - 2017-08-28

    For those following along... @Bed is testing an additional constant in the user program. Awaiting result of tests.

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.