Write Data to an I2C EEPROM 24LC256 and send Data thru Xbee modules
jmmb392
Posts: 22
in Propeller 1
Hello everybody,
My name is Jaime Montenegro, this is my first propeller project. I am writing a program that reads the optical ports of up to 6 power meters to create daily/monthly energy profiles. To accomplish that I first had to be able to detect and time stamp pulses coming from the optical ports; so I first had to setup a RTC clock DS1307 which I did with the help of some of you in a previous discussion.
I am currently using a propeller demo board, I have already programmed the propeller to use two cogs to read 2 optical ports coming from 2 power meters and store the values in variables. Now, I want to be able to save those values in a EEPROM for backup and also send those values wirelessly via Xbee, I have no clue on how to start doing any of the two tasks. I am attaching my latest code for your revisions and suggestions.
Thank you!!
My name is Jaime Montenegro, this is my first propeller project. I am writing a program that reads the optical ports of up to 6 power meters to create daily/monthly energy profiles. To accomplish that I first had to be able to detect and time stamp pulses coming from the optical ports; so I first had to setup a RTC clock DS1307 which I did with the help of some of you in a previous discussion.
I am currently using a propeller demo board, I have already programmed the propeller to use two cogs to read 2 optical ports coming from 2 power meters and store the values in variables. Now, I want to be able to save those values in a EEPROM for backup and also send those values wirelessly via Xbee, I have no clue on how to start doing any of the two tasks. I am attaching my latest code for your revisions and suggestions.
Thank you!!
Comments
You will need to decide how you want to organize the data in the EEPROM. Keep in mind that EEPROM locations can be written only a limited number of times. These days that limit might be 1,000,000 (see the datasheet for the EEPROM for specifics), but that can go by pretty quickly if you're not careful.
An xBee can be used as a "point to point" serial connection or a mesh network. You're probably going to use a pair of xBees to replace a wired serial connection. In that case, you can preconfigure the pair of xBees using their utility program and just use the FullDuplexSerial I/O driver to send and receive the serial data. Depending on what you plan to do on the PC end of the connection, you could send the data as decimal numbers or you could send the binary values. Look at the examples for FullDuplexSerial in the OBEX. Also look at the xBee object in the OBEX here.
Thank you Mike,
I will implement your suggestions. I will update you on my progress!!
Hello Mike, I will first give you an update/overview of my design:
RTC DS1307 (kit from adafruit https://www.adafruit.com/product/264 )
EEPROM 24LC256 (EXTERNAL, NOT THE ONE ON THE DEMO BOARD, I HAD TO DO THAT BECAUSE THE ONE IN THE DEMO BOARD USE P28 AND P29, BUT I DO NOT HAVE PHYSICAL ACCESS TO CONNECT THE RTC CLOCK TO THOSE PINS)
EEPROM ADDRESS = %1010000 (GIVEN IN THE SPECS OF THE EEPROM)
SCL = PIN 6
SDA = PIN 7
BAUD RATE = 57600
I am using P0 and P1 as the inputs for the optical pulses coming from the power meters (I am simulating the pulses using push buttons), I am also running individual cogs per meter, cog1 reads P0 and cog2 reads P1.
I am capable of detecting a pulse with the code and time stamp it. I am using the Basic driver that you recommended, but for some reason it does not work. I created an array pdata[9] to hold all my data, and then I send the data to the eeprom via i2c.WriteLong and to see if it works, I also created another array rdata[9] to save the values that (supposedly) I had already saved in the eeprom, but all I get is -1. I am attaching the entire project, please take a look at it, I must be doing something wrong but I do not know what.
Thank you for all our help!!