I want to start using a 512k EEPROM on my i2c bus and I'm finding the page size instruction a little vague. The only information I can find on the EEpromPageSize definition is that it is commented 16, 32, 64 or 128.
I'm taking that refers to the EEeprom size in Kb. So if that is the case would I simple change the Page Size to read 512 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You don't specify which 512k EEPROM you are using but if it is a Microchip device it will be a page size of 128 Bytes.
The Page size is not the total size of the device, it is the smallest block that can be erased and written in a write instruction.
Here is the data sheet for the Microchip EEPROM http://ww1.microchip.com/downloads/en/devicedoc/21754m.pdf
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was thinking the same.. what is the target EEPROM device?
What chip are you using? 512 buffer will need a lot of RAM.
Where are looking for the EEPromPageSize?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Morning, the device is a Microchip 24LC512-I/SN, 512kbit Serial EEPROM but Chris Roper has kindly given me some clarification and a pdf to absorb.
I am going to need some more help as my next little project with my TinyBL SBC is to use the EEprom storage to keep a temperature data log which I want to be able to read the contents on the SSD1306 GLCD Display.
I have followed Evan's You Tube tutorial on storing ASCII characters on EEProm but that is still quite a bit above my pay scale at the minute.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
my 16F18326 TinyBootloader Module has the facility to read a 1DSB20 Temperature sensors with ports both on and off board, it has a battery backed RTC device , the 512k EEProm and 5 individual I/O lines.
In this instance, partly as a learning curve to discover more about using EEProms but more as an application. What I want to end up with is a module which will measure the temperature hourly or otherwise and store the time and temperature in the EEProm .as a Data Logger. I want to be able to access the stored data as a downloadable file into a terminal program (GCB has a great Terminal program as part of the package) Also, I want to shew the date, time and temperature of the SSD1306 display.
This is probably very basic to most of you guys here but believe me this is mammoth to my limited knowledge set.
Hope this makes sense.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You do not need a huge buffer. The code you will write (in the future) will be making calls the EEProm and then you will be displaying as your receive (in smaller blocks).
:=)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm back again, and I have made what I feel are some major inroads into my project. I have the RTC up and running, the Temperature Sensor up and running and I have roughly grafted in some code which allows me to read and write to the EEProm on hitting the Mode Pressel.
The object is once per hour measure the temperature and date/time stamp both sets of information into the EEProm to where I can download it into a terminal or individually display each entry on the display.
I feel I am at the very limit of my novice knowledge and well out of my depth with handling arrays and string data, to where some help and guidance would come as really welcomed and greatly appreciated.
The code so far is quite lengthy hence the reason I have attached it as text file with some video of the job thus far.
I have spent best part of today trying to research what I need to be able to save my hourly temperature readings and a date/time stamp into the EEProm and I think what I need to do is set up an array then convert my data in a string and save it. I'm not sure how to go on with this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I created an array of bytes to store the temperatures and times
I have defined each index of the array with the name of the field to be stored.
Example:
See if this helps. Now I see where you are heading with the project.
Well done. You have achieved a lot. To do this on a PIC would be the envy of most MicroChip IDE users! :-)
A string is an array. So, you can pass the string (must be a fixed length) to the eeprom update function.
Some thoughts on writing the log values to EEPROM.
Think on this approach. The EEPROM is a large storage device and the management of this is the key in your solution. Use a number of EEPROM locations to store an index (a pointer) to the next writeable location.
EEPROM 0 - 3. Next Write location. This is a LONG number. So, writing takes four operations.
EEPROM 4 - 7. First Write location. This is a LONG number. So, writing takes four operations.
When you want to log. Your program reads the Next Write location, writes the data, then updates the Next Write location ( = Next Write location + length of your log entry) . Next time you write the Next Write location is pointing to the next available location.
You will need to initialise the EEPROM. So, in your program read locations 0-3 and if all 0xFF you know to initialise the EEPROM. So, write the Next Write Location[0..3] (I would choose location 0x0020 32d) and write the First Write location [4..7]. Now you can write to the Next Write location when you log.
Why First Write location? Because when you dump the data you will need to know where data starts (and ends). You will know this. First Write location thru to Next Write location.
When you clear the log. Reset Next Write location to First Write location.
Using this type of pointer method you can store all manner of data and you can adapt as required.
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For fixed-length data you can also calculate a pointer (location of the eeprom) relative to the record number.
For example, if the array is 10 bytes long you can create a function that gives you the pointer to the record.
FunctionGetPointer(inNumRecordasbyte)aswordGetPointer= [word] (NumRecord-1)*10'10 = length of the recordEndFunction
In this way it is very easy to read and write on the eeprom.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HSerPrint" Read Array from EEProm results"'set EEProm start address for reading the arrayeepAddr=0eeprom_rd_array(eepDev, eepAddr , TempInt(), 6)HSerPrintCRLFHSerPrint" TEST -:"HSerPrintTempInt
End Sub
It Returns in the Terminal the Temperature Integer but I don't know if what it is displaying is the data from the EEProm or the value floating in the program variable.
I'm not too sure where to go from here or how to write and read multiple entries as addition data readings
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm back again, and thank you again Jack for what looked like a simple solution and that perhaps I was overthinking what was a simple task. Needless to say I couldn't get it to work in the way that I wanted it to.
What I have so far is two sub routines simply called Save_Data which is intended to save the date and time alongside of the temperature. the first six lines are commented out and are there purely to sure what they are called.
This works fine, maybe needs a little tweaking but this works okay and saves the Date Time and Temperature every 30 minutes to the EEProm.
Then we come to the tricky bit. This works fine too. (See the image below) it reads the EEProm contents and displays them on the Terminal program.
This is where I am becoming completely unstuck. What I want to do is to store the readings in an array so that I have a full record of saved data in blocks of 48 if reading every 30 minutes or blocks of 24 if reading every hour. I'm thinking along the lines of a loop with an incremental variable something similar to what Jack put forward but I'm going around in circles trying to work out how to do it.
HSerPrintCRLFHSerPrint" TEST "HSerPrintCRLFHSerPrintReadDateHSerPrint"/"HSerPrintmonthHSerPrint" - "HSerPrinthour;TempIntHSerPrint":"IfMin<=9ThenHSerPrint"0"HSerPrintminElseIfMin>9ThenHSerPrintminEndifHSerPrint" - "HSerPrintTempIntHSerPrint"."HSerPrintTempDecHSerPrint"'C"HSerPrintCRLFHSerPrint" END TEST"
Keith,
I am trying to understand where you are at in this project. It looks like you have the date/time and temperature working according to your picture. So now you have the variable names of the things you are storing and you need to assemble them into an array. How do you create an array? Dimension it.
Now you have a record. Now you are going to write the record to eeprom. You chose you eeprom to be the Microchip 24A512 , so you need a data sheet to figure it out. 64k bytes, 127 byte page, address in going to be a word(2 bytes),
I2C address is 1 0 1 0 A2 A1 A0 0
A2,A1,A0 are the physical address pins on the chip. Are theyconnected to gnd? then they are 0.
So maybe your write address is "A0"
First Include the eeprom routines at the top includes of the program
#include<i2ceeprom.h>
'eeprom_wr_array(in eepDev as byte, in eepPageSize as byte, in eepAddr as word, in eepArray() as byte, in eepLen as byte)
eeprom_wr_array(0xA0,127, eepAddr,buffer(),6)
As you can see we need the eepAddr. Anobium explained what you must do in a previous post. Look above. You are have an "index" pointing to the "NextWrite" spot. After you write the array then you will update the "NextWrite" location by adding 6 to it and writing to it's location in eeprom. This is so when you have power outages ,you maintain the integrity of you data.
Every hour(or interval) you will assemble the data and write it to eeprom and update the "NextWrite".
That's all for now. See if you understand this much?
GL
Mike
PS.
Attached is a datalogger that I used in 2017 to log some temp and hum readings every hour during and drying batch. I already had the 16f1705's hooked up before I realized i only had 128 HEF non volatile memory ,no eeprom.. argh. So I could record 4 bytes 30 times which was enough to record the part I wanted. I communicated to them through bluetooth and as you can see a very basic menu. 'S' status sent what it was reading now, 'E' erase the memory for clean start, 'M' dump the memory to the bluetooth and I would have the blutooth logging it into a file which I would send in email to my PC. Basically I am doing what you want to do with smaller equipment.
Thank you so much for the help Mike, it is really appreciated. I would be lying if I said I understand how it works as this is way above my level of understanding and payscale. I am going to have to put my head into gear and knuckle down until I can make my sense of it.
Yes you are right it is a datalogger and this bit is I think the last link in the puzzle, however there is a delete routine to create after I get this array business under my belt.
I'll get back to you once I managed to get it to work (or otherwise) [8>(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot test but this compiles. I have removed the reference to the old library, defined all the missing variables then change the use the function for HEFREAD.
When I change the chip type to what is in the project (16F18326) it doesn't compile and tells me HEF is not supported on this device. Changing the chip type back to 16F1705 allows me to compile, needless to say it refuses to do anything. The only thing in the terminal is a solitary accented carat symbol.
I don't have a 16F1705 to test with.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to start using a 512k EEPROM on my i2c bus and I'm finding the page size instruction a little vague. The only information I can find on the EEpromPageSize definition is that it is commented 16, 32, 64 or 128.
I'm taking that refers to the EEeprom size in Kb. So if that is the case would I simple change the Page Size to read 512 ?
You don't specify which 512k EEPROM you are using but if it is a Microchip device it will be a page size of 128 Bytes.
The Page size is not the total size of the device, it is the smallest block that can be erased and written in a write instruction.
Here is the data sheet for the Microchip EEPROM http://ww1.microchip.com/downloads/en/devicedoc/21754m.pdf
I was thinking the same.. what is the target EEPROM device?
What chip are you using? 512 buffer will need a lot of RAM.
Where are looking for the EEPromPageSize?
Morning, the device is a Microchip 24LC512-I/SN, 512kbit Serial EEPROM but Chris Roper has kindly given me some clarification and a pdf to absorb.
I am going to need some more help as my next little project with my TinyBL SBC is to use the EEprom storage to keep a temperature data log which I want to be able to read the contents on the SSD1306 GLCD Display.
I have followed Evan's You Tube tutorial on storing ASCII characters on EEProm but that is still quite a bit above my pay scale at the minute.
I am not sure you need the huge buffer. We need a lot more information to help.
my 16F18326 TinyBootloader Module has the facility to read a 1DSB20 Temperature sensors with ports both on and off board, it has a battery backed RTC device , the 512k EEProm and 5 individual I/O lines.
In this instance, partly as a learning curve to discover more about using EEProms but more as an application. What I want to end up with is a module which will measure the temperature hourly or otherwise and store the time and temperature in the EEProm .as a Data Logger. I want to be able to access the stored data as a downloadable file into a terminal program (GCB has a great Terminal program as part of the package) Also, I want to shew the date, time and temperature of the SSD1306 display.
This is probably very basic to most of you guys here but believe me this is mammoth to my limited knowledge set.
Hope this makes sense.
Good insights.
You do not need a huge buffer. The code you will write (in the future) will be making calls the EEProm and then you will be displaying as your receive (in smaller blocks).
:=)
I'm back again, and I have made what I feel are some major inroads into my project. I have the RTC up and running, the Temperature Sensor up and running and I have roughly grafted in some code which allows me to read and write to the EEProm on hitting the Mode Pressel.
The object is once per hour measure the temperature and date/time stamp both sets of information into the EEProm to where I can download it into a terminal or individually display each entry on the display.
I feel I am at the very limit of my novice knowledge and well out of my depth with handling arrays and string data, to where some help and guidance would come as really welcomed and greatly appreciated.
The code so far is quite lengthy hence the reason I have attached it as text file with some video of the job thus far.
Oop's This should go with above
(What's happening here, I can't upload, something to do with a passport.bldx)
Last edit: Keith 2020-12-05
I have spent best part of today trying to research what I need to be able to save my hourly temperature readings and a date/time stamp into the EEProm and I think what I need to do is set up an array then convert my data in a string and save it. I'm not sure how to go on with this.
I created an array of bytes to store the temperatures and times
I have defined each index of the array with the name of the field to be stored.
Example:
When I have to write a value, I write it like this:
TempInt = Value
.To store all values, I store the entire array.
See if this helps. Now I see where you are heading with the project.
Well done. You have achieved a lot. To do this on a PIC would be the envy of most MicroChip IDE users! :-)
A string is an array. So, you can pass the string (must be a fixed length) to the eeprom update function.
Some thoughts on writing the log values to EEPROM.
Think on this approach. The EEPROM is a large storage device and the management of this is the key in your solution. Use a number of EEPROM locations to store an index (a pointer) to the next writeable location.
EEPROM 0 - 3. Next Write location. This is a LONG number. So, writing takes four operations.
EEPROM 4 - 7. First Write location. This is a LONG number. So, writing takes four operations.
When you want to log. Your program reads the Next Write location, writes the data, then updates the Next Write location ( = Next Write location + length of your log entry) . Next time you write the Next Write location is pointing to the next available location.
You will need to initialise the EEPROM. So, in your program read locations 0-3 and if all 0xFF you know to initialise the EEPROM. So, write the Next Write Location[0..3] (I would choose location 0x0020 32d) and write the First Write location [4..7]. Now you can write to the Next Write location when you log.
Why First Write location? Because when you dump the data you will need to know where data starts (and ends). You will know this. First Write location thru to Next Write location.
When you clear the log. Reset Next Write location to First Write location.
Using this type of pointer method you can store all manner of data and you can adapt as required.
:-)
For fixed-length data you can also calculate a pointer (location of the eeprom) relative to the record number.
For example, if the array is 10 bytes long you can create a function that gives you the pointer to the record.
In this way it is very easy to read and write on the eeprom.
Oh Wow ! this is really fantastic ! Thank you so much everyone, this is a GREAT BIG Help !
It's head down and try to absorb how this works.
Well, my head hurts !
What I have so far is in the two Sub Routines Save_Data and Read_Data
Sub Save_Data
; ReadDate ArrayTemp (1)
; month ArrayTemp (2)
; hour ArrayTemp (3)
; min ArrayTemp (4)
; TempInt ArrayTemp (5)
; TempDec ArrayTemp (6)
; ReadDate = date
; TempInt = Whole
; TempDec = DIG
eeprom_wr_array( eepDev, EEpromPageSize, eepAddr, TempInt(), 6 )
End Sub
Sub Read_Data
HSerPrintCRLF 2
ifdef I2C_DATA
HSerPrint "SW I2C Operational"
endif
ifdef HI2C_DATA
HSerPrint "HW I2C Operational"
endif
HSerPrintCRLF 2
End Sub
It Returns in the Terminal the Temperature Integer but I don't know if what it is displaying is the data from the EEProm or the value floating in the program variable.
I'm not too sure where to go from here or how to write and read multiple entries as addition data readings
I'm back again, and thank you again Jack for what looked like a simple solution and that perhaps I was overthinking what was a simple task. Needless to say I couldn't get it to work in the way that I wanted it to.
What I have so far is two sub routines simply called Save_Data which is intended to save the date and time alongside of the temperature. the first six lines are commented out and are there purely to sure what they are called.
This works fine, maybe needs a little tweaking but this works okay and saves the Date Time and Temperature every 30 minutes to the EEProm.
Then we come to the tricky bit. This works fine too. (See the image below) it reads the EEProm contents and displays them on the Terminal program.
This is where I am becoming completely unstuck. What I want to do is to store the readings in an array so that I have a full record of saved data in blocks of 48 if reading every 30 minutes or blocks of 24 if reading every hour. I'm thinking along the lines of a loop with an incremental variable something similar to what Jack put forward but I'm going around in circles trying to work out how to do it.
Sub Save_Data
; ReadDate ArrayTemp (1)
; month ArrayTemp (2)
; hour ArrayTemp (3)
; min ArrayTemp (4)
; TempInt ArrayTemp (5)
; TempDec ArrayTemp (6)
ReadDate = date
TempInt = Whole
TempDec = DIG
hour = DS_Hour
min = DS_Min
'eeprom_wr_array( eepDev, EEpromPageSize, eepAddr, Readdate hour TempInt(), 6 )
End Sub
;;; **********
Sub Read_Data
HSerPrintCRLF 2
; HSerPrint " Read Array from EEProm results"
; eepAddr = 0
; eeprom_rd_array( eepDev, eepAddr , Readdate hour TempInt(), 6 )
;
HSerPrintCRLF
End Sub
Last edit: Keith 2020-12-13
Keith,
I am trying to understand where you are at in this project. It looks like you have the date/time and temperature working according to your picture. So now you have the variable names of the things you are storing and you need to assemble them into an array. How do you create an array? Dimension it.
Fill the buffer with data
Now you have a record. Now you are going to write the record to eeprom. You chose you eeprom to be the Microchip 24A512 , so you need a data sheet to figure it out. 64k bytes, 127 byte page, address in going to be a word(2 bytes),
I2C address is 1 0 1 0 A2 A1 A0 0
A2,A1,A0 are the physical address pins on the chip. Are theyconnected to gnd? then they are 0.
So maybe your write address is "A0"
First Include the eeprom routines at the top includes of the program
'eeprom_wr_array(in eepDev as byte, in eepPageSize as byte, in eepAddr as word, in eepArray() as byte, in eepLen as byte)
eeprom_wr_array(0xA0,127, eepAddr,buffer(),6)
As you can see we need the eepAddr. Anobium explained what you must do in a previous post. Look above. You are have an "index" pointing to the "NextWrite" spot. After you write the array then you will update the "NextWrite" location by adding 6 to it and writing to it's location in eeprom. This is so when you have power outages ,you maintain the integrity of you data.
Every hour(or interval) you will assemble the data and write it to eeprom and update the "NextWrite".
That's all for now. See if you understand this much?
GL
Mike
PS.
Attached is a datalogger that I used in 2017 to log some temp and hum readings every hour during and drying batch. I already had the 16f1705's hooked up before I realized i only had 128 HEF non volatile memory ,no eeprom.. argh. So I could record 4 bytes 30 times which was enough to record the part I wanted. I communicated to them through bluetooth and as you can see a very basic menu. 'S' status sent what it was reading now, 'E' erase the memory for clean start, 'M' dump the memory to the bluetooth and I would have the blutooth logging it into a file which I would send in email to my PC. Basically I am doing what you want to do with smaller equipment.
Thank you so much for the help Mike, it is really appreciated. I would be lying if I said I understand how it works as this is way above my level of understanding and payscale. I am going to have to put my head into gear and knuckle down until I can make my sense of it.
Yes you are right it is a datalogger and this bit is I think the last link in the puzzle, however there is a delete routine to create after I get this array business under my belt.
I'll get back to you once I managed to get it to work (or otherwise) [8>(
@Anobium -- This is as far as my "dung for brains" could handle !
I see... using the deprecated HEF library.
I cannot test but this compiles. I have removed the reference to the old library, defined all the missing variables then change the use the function for HEFREAD.
Try... nothing to lose.
When I change the chip type to what is in the project (16F18326) it doesn't compile and tells me HEF is not supported on this device. Changing the chip type back to 16F1705 allows me to compile, needless to say it refuses to do anything. The only thing in the terminal is a solitary accented carat symbol.
I don't have a 16F1705 to test with.
18326 does not have HEF memory, it has EEPROM. So, use EPWRITE and EPREAD ( these support EEPROM)