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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 !!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@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:
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.
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.
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).
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
Starting afresh. Nothing connected.
I just took an 1937 and connected up my Pk3. Checked out out. I can program and read = I have a working chip.
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?
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Should work. It is a SSD1306.
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 !!
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
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!!
share the ebay listing! Don't keep to yourself. :-)
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
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.
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.
where... 1 set equals 2 resistors. :-)
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....
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
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 thei2c_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
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.
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?
Rename your existing
glcd_SSD1306.h to glcd_SSD1306.ba
k (or similar)Copy the
glcd_SSD1306.h
that I've attached into your includes folderAdd 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 commandsPRINT
,LOCATE
andCLS
you will need to useGLCDINIT
,GLCDPRINT
andGLCDCLS
.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.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
@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:
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.
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
Well, I have parsed the code down to a few lines as thus. It now compiles but still nothing on the display:
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
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).
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
^^ See my reply above :)
It just took longer to finish and post than expected.
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.
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
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.