Writing sensor data to a 25LC640 EEPROM
Robert@HCC
Posts: 80
I have a Microchip 25LC640 EEPROM I am learning to use with the BS2. So far, I have been able to R/W by storing a value in a variable, incrementing the value in the variable, while incrementing the address. I have been able to confirm what I am doing by using the debug window, as well as reading the stored value into StampDaq.
But for the life of me, I cant seem to get a hold on to how I can grab data from my sensors ( Sensirion SHT1x temp/humidity, Memsic accellerometer) and into the variable "EEPROM_data" and write it to the EEPROM.
For instance this is my code to write:
And what I get after processing the temp data in the subroutines :
Can anyone give me some pointers on how I can grab that data in the last SEROUT and write to the EEPROM?
I am trying to display the data during collection, but would also like to store the data for later processing in StampDAQ.
Aloha, and thanks for any replies!
Robert
But for the life of me, I cant seem to get a hold on to how I can grab data from my sensors ( Sensirion SHT1x temp/humidity, Memsic accellerometer) and into the variable "EEPROM_data" and write it to the EEPROM.
For instance this is my code to write:
WriteEEPROM: GOSUB EEPROMreadstatus IF EEPROM_Busy =1 THEN WriteEEPROM LOW CS SHIFTOUT SerData,SerClk,MSBFIRST,[noparse][[/noparse]WREN_EEPROM] HIGH CS LOW CS SHIFTOUT SerData,SerClk,MSBFIRST, [noparse][[/noparse]Write_EEPROM,Address\16,EEPROM_data\8] HIGH CS RETURN
And what I get after processing the temp data in the subroutines :
GOSUB SHT_Measure_Celcius PAUSE 500 SEROUT TxD, Baud48, [noparse][[/noparse] MoveTo, 0, 3] SEROUT TxD, Baud48, [noparse][[/noparse] "Deg C... ", DEC (info / 10), ".", DEC1 info, DegSym,CR]
Can anyone give me some pointers on how I can grab that data in the last SEROUT and write to the EEPROM?
I am trying to display the data during collection, but would also like to store the data for later processing in StampDAQ.
Aloha, and thanks for any replies!
Robert
Comments
Adding routines to a program given only a few select existing subroutines is difficult t best, but the fact that the routine labelled "SHT_Measure_Celcius" is missing, makes it all the more difficult. At least two variables (possibly more) are derived from that subroutine:
"MoveTo", and "Info", which lack sufficient self-documentation in naming, that I'm not sure what they are.
Try posting all of what you have either inline as you did, or as an attachment and we'll HELP you put the jigsaw puzzle together.
The basic program flow will be something like this:
All below, "if necessary"
Initialize variables
Initialize sensor(s)
Initialize LCD
Pause
Set-up sensor for a reading
Fetch sensor information
Manipulate retrieved information
Set-up EEPROM addressing information
Increment EEPROM store address
Store necessary information in EEPROM
Pause
Ensure write was completed
Set-up information to be displayed
Establish cursor position and data spacing
Write necessary data fields
Pause
Reset variables
Pause
Repeat next iteration when necessary
That should be most of it. I hope that's enough to get you started thinking about the structure of the soon-to-be program.
Regards,
Bruce Bates
I actually have all the sensors working - just want to add a datalogging function since I have some EEPROMS laying about. But like I said, still learning here....
I will post the complete code tommorow when I will be on a faster connect.
Aloha,
Robert
The only thing is, you will probably want to make EEPROM_data a Word variable, so that it can handle a full range of values including negative.
That is not essential but if you use bytes you have to be sure the data is compressed to fit.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
My main problem as I worked through ( and lost some hairs, but mostly grey ,so no prob) this was my variables for the sensors were word-sized, and my EEPROM routine wrote the data a byte at a time! I had setup code like your first example, but but could not grab the data properly.
I think I just had one... no two.. of those "AHA!! moments Jon Williams talks about in his NV articles- usually after pounding in " read th e datasheets, manuals, etc"
I figured out that part about :
and changing the 8 to 16 , but never figured out that I would have to increment address by two instead of one! makes perfect sense now, of course [noparse]:D[/noparse] Excellent!
I also figured out that I could write a subroutine that split my word-sized variable "info" into "info.HIGHBYTE" and "info.LOWBYTE" then send it to the Write_EEPROM subroutine for further processing like so:
All in all, and excellent learning experience, and I now have two ways to process my data - gonna test out your solution now, Tracy....iT seems much more..well, cleaner than mine!
Thank you!
and then I am off to play with some I2C EEPROMS for a change of pace. :O
Thank you one and all for your replies!
Robert Allen <
seems to be alot of those here
Post Edited (Robert@HCC) : 12/24/2005 10:56:14 AM GMT