Menu

Some help please with GCB RTC demo (Evan's) using MCP9740N and Serial Display

Help
Keith
2016-09-08
2016-10-01
1 2 > >> (Page 1 of 2)
  • Keith

    Keith - 2016-09-08

    Back on knowledge quest again and what I am aiming to do is to build a RTC 7 Day timer with multiple outputs and I am hoping to use the Demo code 'i2c_MCP7940N_16F1937_Serial.gcb' as a foundation start-up.

    my first question is about the display. I have a couple of these which are serial and I believe them to be Graphic :
    IIC Serial 128X64 OLED LCD Display Module from FleaBay, the item number is 261570644800

    Will they work? if so are there any specific corrections in the GCB code to change?

    Connection wise all looks good as there is only VCC GND Serial Clock and Serial Data.
    I also have a couple of 12864 128x64 Dots Graphic LCD Display Modules but I think these will probably need an adaptor to take the serial data to parallel.

    I have tried to identify the two displays mentioned but everything points me to the Italian Ice Cream People (Just One Arduino!) which frankly send a cold shiver down my spine.

    Please bear in mind I am still a programming code newbie with the skills of a pet chimp and this is going to be the biggest project I have ever tackled, but before you say 'I can buy one ready built' This is to be an enormous learning curve for me with I2C Bus, Graphic Displays and a host of other fringe disciplines.

    Many thanks in advance.

     
  • Anobium

    Anobium - 2016-09-09

    Should work. It is a SSD1306.

     
  • Keith

    Keith - 2016-09-09

    Great -Thank you Evan.

    Another Question, is your code example in the i2c_MCP7940N_16F1937_Serial.gcb file reading the Alarm Outputs from the RTC device? If so do you think it will be a straightforward task to make it give multiple programmable outputs over a seven day cycle.

    Of the Top of my head is an idea along the lines of using one of the RTC Alarm outputs to signify AT = 00:00 and allow the uPC to trigger an output at AT + P1 (P1 being a preset duration of say 430 minutes )

    Is this making sense or am I shooting at rats on the moon (again!)

    Finally, the features on the MCP7940 MicroChip AN1355 I have read that this chip has an onboard 32,768 kHz Xtal Oscillator but the schematic in Fig 1shows an Xtal and 10pF padders in situ. - very confusing !!

     
    • Anobium

      Anobium - 2016-09-09

      Oh yes. Anything is possible. Just depends on your patience.... You could the RTC clock as the 'next alarm' signal and then keep changing the RTC alarm setting - a round robin setting process.

      Before... you start... design your User Interface.. how will that work. That is the challenge I always hit. One Display, two switches? How many menus? etc etc

       
  • Keith

    Keith - 2016-09-09

    Oh. Forgot to mention I found several of the serial to analogue display converters on Fleabay - cheap as chips at 99p each. Going to have some fun with this project. Huge learning curve ahead!!

     
    • Anobium

      Anobium - 2016-09-09

      share the ebay listing! Don't keep to yourself. :-)

       
  • Keith

    Keith - 2016-09-09

    Good Thinking BatMan... The menu structure should be straightforward I hope!

    The Serial adaptor is a follows:

    1Pcs IIC/I2C Serial VC best Board Module For Arduino LCD1602 LCD2004 Display

    FleaBay item number:271932174190

    Do you have any thoughts on the MCP 79450 onboard 32,768 kHz Xtal Oscillator query?

     

    Last edit: Keith 2016-09-09
  • Keith

    Keith - 2016-09-09

    This is probably a dopey question but I gather both RTC Device and the GLCD display are on the same I2C bus? Sharing the same SCL and SDA Lines. If so does the pull-ups not affect the display.

    That Data sheet is confusing the issue for me.

     
    • Peter

      Peter - 2016-09-12

      Yes they will work on the same I2C bus and share the SDA and SCL lines provided that the devices have different addresses which is usually the case
      You  only need 1 set of pullup resistors for the whole bus.

       
      • Anobium

        Anobium - 2016-09-12

        where... 1 set equals 2 resistors. :-)

         
  • Keith

    Keith - 2016-09-12

    Thanks Peter and Evan - Them datasheets are as bad as the notes in a box of pills - fill you (me) full of cr@p and rubbish.

    Chips arrived late afternoon and I'm itching to spark this up....

     
  • Keith

    Keith - 2016-09-14

    Could you please tell me what I am doing wrong. I have prgrammed the 12F1937 and on the Breadboard I have connected up VDD, VSS, CLK and DAT to both the Display and the RTC (with the Pull-Ups) and I was half expecting to see something on the display, but nothing, ziltch, zip, no'wt.

    Occasionally on Power-Up I see the current rise to about 6mA but nothing on the display. Does anyone have any scratch code or something diagnostic to check my circuit with?

    Am I missing an enable pin/port or is there something in the code I need to do.

    I could post the code but it is quite a lengthy script, besides everyone has it in the GCB Demo's directory.

     

    Last edit: Keith 2016-09-14
  • Peter

    Peter - 2016-09-14

    I just started a big long reply detailing how to do this, then noticed a couple of things:
    - You're trying to use the i2c_MCP7940N_16F1937_Serial.gcb file - this outputs the results to a serial port, not a graphical LCD like the SSD1306. There is no demo for an MCP7940N with GLCD, so you would need to start with the i2c_MCP7940N_16F1937_LCD.gcb demo and modify it.
    - The graphical LCD driver requires 1K of RAM, plus whatever your program needs.
    - I can't find details of the 12F1937 - did you mean 16F1937? This only has 512 bytes of RAM so you will struggle to get the SSD1306 to work, even with a hacked glcd_SSD1306.h.

     

    Last edit: Peter 2016-09-14
  • Peter

    Peter - 2016-09-14

    Just for info, here's a hacked glcd_SSD1306.h which allows it to be used with low memory PICs. Simply add #define SSD1306_Buffer xxx to your code where xxx is the size of the buffer in bytes that you want to use.
    If you don't include this, then the default 1024 byte buffer is used.
    Reducing the buffer reduces the area of the display which can be used.

    As per an old post, I'm using a 768 byte buffer on a PIC16F1825 (1K RAM) which gives enough space for my program code to run.

     
  • Keith

    Keith - 2016-09-14

    Thank you Peter, in one respect I'm pleased that it is not something simple highlighting my novice programming skills.
    I have some of those parallel to serial converters on order but as usual when you are waiting for something from the Far East it takes Eons to arrive.

    Yes, this is a 16F1837 I am playing around with and not a 12F device as initially mentioned.

    Do I just add the #define SSD1306_Buffer xxx line to my code as you say, do I also need to include the glcd_SSD1306.h also?

     
  • Peter

    Peter - 2016-09-15

    Rename your existing glcd_SSD1306.h to glcd_SSD1306.bak (or similar)
    Copy the glcd_SSD1306.h that I've attached into your includes folder
    Add the line #define SSD1306_Buffer 384 to your program code. This will let you use around 1/3 of the display.

    You can use your SSD1306 display with i2c_MCP7940N_16F1937_LCD.gcb but instead of using the parallel LCD commands PRINT, LOCATE and CLS you will need to use GLCDINIT, GLCDPRINT and GLCDCLS.

    I'd suggest testing your GLCD first just with a GLCDPRINT(0,0,"Hello World") before trying to get the MCP7940N working - if you have no output you won't know where the problem is.

     
  • Keith

    Keith - 2016-09-15

    Thank you Peter. I will try that this morning. I really feel that I after the initial tests with the RTC I should put this aside until those parallel to serial converters turn up or look for a uPC with the same features but with a larger RAM capacity more suited to driving a GLCD (any suggestions?)

    On those Parallel to Serial display converters there is one little diamond on FleaBay selling 10 for 5.04GBP (50p each!) including P&P that's crackers man!! FleaBay item number: 172308197092 Fill your boots Gents ! (and Ladies)

    I'll let you know how I get on.

    Keith

     
  • Keith

    Keith - 2016-09-15

    @Peter, I think the expression 'Failed miserably' fits the bill entirely. I followed your instructions to the letter but I cannot get the code to compile.
    This is my config where I have added the incude:

                  #chip 16F1937, 32
                  #config Osc = intOSC, MCLRE_ON, PLLEN_ON, VCAPEN_OFF
                  #include <glcd_SSD1306.h>    (your modified file)
                  #include <MCP7940N.h>
    

    It also has a problem recognising GLCDINIT and looking through the GCB Help files could this be initGLCD ?

    I'm really struggling with this, I am not a "quitter type person" I don't like giving up without a fight but I feel I am causing a lot of problems for other people when I should be playing with the right toys from the box.
    I have had a look at the other GCB GLCD simple demo solutions but there doesn't seem to be anything there which talks to 16F1937 or 16F1939 and an SSD1306 to where I can experiment with as a stimulus or a nucleus to let me go forward.

     
    • Peter

      Peter - 2016-09-15

      You need to #include <glcd.h>, not <glcd_SSD1306.h>.

      Add
      ; ----- Define GLCD Hardware settings
      #define GLCD_TYPE GLCD_TYPE_SSD1306
      #define GLCD_I2C_Address 0x78
      to your code and it will load the SSD1306 driver.

      See http://gcbasic.sourceforge.net/help/_ssd1306_controllers.html for more information on using the GLCD.

       

      Last edit: Peter 2016-09-15
  • Keith

    Keith - 2016-09-15

    Well, I have parsed the code down to a few lines as thus. It now compiles but still nothing on the display:

    ;Chip Settings
     #chip 16F1937, 32
     #config Osc = intOSC, MCLRE_ON, PLLEN_ON, VCAPEN_OFF
    
    ; ----- Define GLCD Hardware settings
    
      #include <glcd.h>
    
          #define SSD1306_Buffer 384
        #define GLCD_TYPE GLCD_TYPE_SSD1306
        #define GLCD_I2C_Address 0x78
    
    Main:
     initGLCD 0,0
      GLCDPRINT 0,0, "Hello"
      initGLCD 1,0
      GLCDPRINT 1,0,"Great Cow Basic"
      wait 5 S
    
      GLCDCLS
    
     wait 5 S
    
    goto main
    

    Either I have a duff device or display but this is beginning to make Recreational Chemistry look like a sensible move

    BTW I cannot get your link to the help reference work also... 8(

    Recreational Chemistry – Converting Fine Wines, Ale and Spirits into urine.

     

    Last edit: Keith 2016-09-15
    • Peter

      Peter - 2016-09-15

      I've updated the help link in my post above (underscore missing).

      Your code does not include anything to setup the I2C. I've added this and tested your code, albeit with a different PIC and using software I2C and it works fine. I cannot get hardware I2C to work on my PIC (I think I'm cursed).

      ;Chip Settings
      #chip 16F1825, 32
      #config Osc=intOSC, MCLRE_ON, PLLEN_ON
      
      ; ----- Define GLCD Hardware settings
      #include <glcd.h>
      
      'OLED settings
      #define SSD1306_Buffer 384
      #define GLCD_TYPE GLCD_TYPE_SSD1306
      #define GLCD_I2C_Address 0x78
      
      'Software I2C required for the OLED
      #define I2C_DATA PORTC.1
      #define I2C_CLOCK PORTC.0
      #define I2C_BIT_DELAY 0 us
      #define I2C_CLOCK_DELAY 0 us
      #define I2C_END_DELAY 0 us
      #define I2C_DISABLE_INTERRUPTS ON
      #define I2C_MODE Master
      
      Main:
       initGLCD 0,0
        GLCDPRINT 0,0, "Hello"
        initGLCD 1,0
        GLCDPRINT 1,0,"Great Cow Basic"
        wait 5 S
      
        GLCDCLS
      
       wait 5 S
      
      goto Main
      
       
  • Keith

    Keith - 2016-09-15

    There must have been some sort of server glitch when I tried the link to the SSD1306 help files as the page would not resolve. It is working properly now - my faith is also restored without the assistance of something in a glass..

     

    Last edit: Keith 2016-09-15
    • Peter

      Peter - 2016-09-15

      ^^ See my reply above :)
      It just took longer to finish and post than expected.

       
  • Keith

    Keith - 2016-09-23

    I put this project aside last week as I was simply getting nowhere and decided to wait until my serial to parallel adaptors arrived and give it my best shot. My adaptors arrived this morning so I got stuck back in.

    On my breadboard I have the following,

    16F1937 with a fresh instance of Evann’s i2c_MCP7940N_16F1937_LCD.gcb compiled and programmed,

    MCP7940N and a 3v backup battery, connected to the I2C bus

    The Serial to parallel adaptor connected to the I2C bus and connected to a 2 x 16 LCD display

    2 x 4k7 pull-ups to the I2C bus

    finally, Buttons to pull down the b0 and b1 ports

    And guess what – still NOTHING !!

    I have adjusted the display contrast in case there was anything hiding in the background.

    This is frustrating the hell out of me. Am I missing something ? The code is straight out of the Demos folder, should I be editing anything?

    I changed the line #define LCD_IO 10 to #define LCD_IO 12 as in the header text but that still did nothing for me so I changed it back.

    As an overview it seems to be lacking connectivity as it only has the I2C lines, VDD and VSS and a pair of buttons. Is that right?

    Once again and as always, immense gratitude to all for any help with this.

     
    • Anobium

      Anobium - 2016-09-24

      Morning.

      Let us break this down into modules of capability.
      1. Basic communications - the circuit
      2. the LCD and the i2c circuit
      3. the switches
      4. the sensor

      1. Starting afresh. Nothing connected.
      2. I just took an 1937 and connected up my Pk3. Checked out out. I can program and read = I have a working chip.
      3. I took the 16f1939 I2C LCD demo and change for the 1937 and the I2C LCD I have. Connected up the LCD, added the pull-up resisistors and tested. This works for me. Does this work for you?

      When we know step 2 works we can complete step 3.

      I just posted my 1937 demo code to here

      If step 2 fails. Do you have a serial terminal ? and, serial connectivity between you pic and your PC? Because, we would need to validate your I2C setup and using I2C discovery is a great to do this.

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.