Shop OBEX P1 Docs P2 Docs Learn Events
PE Kit Lab Applications – EEPROM Datalogging and I2C — Parallax Forums

PE Kit Lab Applications – EEPROM Datalogging and I2C

edited 2013-09-11 13:38 in Propeller 1
PE Kit Lab Applications – EEPROM Datalogging and I2C··
Attached is the first application installment for the next Propeller Education Kit lab – EEPROM Datalogging and I2C.· Test Propeller Eeprom v0.677...zip is a HyperTerminal application for testing the Propeller Eeprom object’s VarBackup, VarRestore, FromRam, and ToRam methods.· It allows you define values stored by selected array elements and then copy the array from main RAM to EEPROM and visa versa.·
·
Example:
·
VAR
· long values[noparse][[/noparse]32]
·
OBJ
· eeprom : “Propeller Eeprom”
·
PUB Main
· ...
· eeprom.VarBackup(@values, @values[noparse][[/noparse]31] + 3)··· ‘ Backup
· ...
· eeprom.VarRestore(@values, @values[noparse][[/noparse]31] + 3)······· ‘ Restore
·
One interesting and particularly useful application of the Propeller Eeprom object’s VarBackup method is that values that were copied from the main RAM’s variable memory to EEPROM are automatically restored to variable memory on reboot.· (Thanks and kudos to Jeff Martin for suggesting this approach!)· The VarRestore method can also be used to programmatically restore variable memory to an earlier state that was copied to EEPROM by VarRestore.
·
The zip’s Propeller Eeprom object also has FromRam and ToRam methods for datalogging values to portions of EEPROM not used for program and variable storage.·
·
Example:
·
·· ...
·
·· ‘ Copy array to EEPROM starting at eeAddr to eeAddr + 127.
·· eeprom.FromRam(@value, @value[noparse][[/noparse]31] + 3, eeAddr)
·
·· ...
·
·· ‘ Copy from eeAddr to eeAddr + 127 to value[noparse][[/noparse]0]..value[noparse][[/noparse]31].
·· eeprom.ToRam(@value, @value[noparse][[/noparse]31] + 3, eeAddr)
·
Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.
·
PE Kit Labs that have already gone through the review process are available for download from the Propeller Education Kit page.· You can also find discussions for each lab along with the latest drafts in progress on the Propeller Education Kit Labs thread.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay

Education Department
Parallax, Inc.

Post Edited (Andy Lindsay (Parallax)) : 8/24/2010 6:32:19 PM GMT

Comments

  • RaymanRayman Posts: 14,662
    edited 2007-09-26 12:29
    This is very nice! This way I can easily save settings of my app to the eeprom.

    For datalogging though, I just ordered some extra 24LC128 chips to add to the I2C bus... Do you think that "Propeller Eeprom.spin" will work with this chip too? I guess it depends on if the page boundaries are the same, right? But, I see the number 64 in this line:

    page := addr+64-eeAddr//64<#endaddr+1 ' Find next EEPROM page boundary

    So, I guess it has the same 64 byte page boundary.

    I wish you had the chip address as a variable, but it looks like these lines send the address:

    SendByte(%10100001) ' EEPROM I2C address + read operation
    ackbit := SendByte(%10100000) ' Write command with EEPROM's address

    I think this means the built in eeprom is assumed to have all chip select pins low for address #0. Is there anything else to do to talk to a different chip?
  • rjo_rjo_ Posts: 1,825
    edited 2007-09-26 18:58
    Andy...

    Very timely.

    I hope the discussion section includes pointers to I2C links and a brief discussion of I2C vs SPI.

    Rayman... you asked the question better than I could have[noparse]:)[/noparse]



    Rich
  • edited 2007-09-26 23:01
    Hi Rayman and Rich,

    This app is the foundation for the first part of the lab which is about memory architecture, and datalogging. The Propeller Eeprom object for this first part is supposed to be as light as possible. It's currently 93 longs, and I will be whittling away to make it smaller and faster before the lab comes out.

    The second part of the lab will be about I2C. It will start by adding the 10 k pullup resistor to the 24LC256’s SCL line. Then, it will develop an I2C object step-by-step. It'll be a good exercise in starting with a timing diagram and specification and writing code implements it. It'll also be a good exercise in breaking a coding problem into its elements. For example, after the start condition and address byte have been written, test to see that the Propeller's EEPROM replies to its own address with an acknowledge (0) and to a different address with a no acknowledge (1). Stuff like that…

    Here are links to I2C drivers that you can currently use for your projects. (Just did a search.) Most of them should work for your (Rayman’s) requests.

    Existing I2C Objects
    (Everybody: Please PM me with entries that need to be added to this list! Thanks.)
    ·- Mike Green’s Basic I2C Driver on Propeller Object Exchange·-> Data Storage
    ·- James Burrows’ i2c Object Examples, also on Propeller Object Exchange -> Data Storage
    ·- Eric’s tiny_i2c (Forum post)
    ·- Beau Schwabe’s I2C (Forum post)
    ·- Andre' LeMothe’s Hydra Game System Kit (EEPROM Product page)

    Looks like I might need to add a third section…something like, now that you understand I2C from the inside out, let’s apply the nomenclature we picked up along the way to do the same job with an I2C driver from the object exchange.

    Andy

    P.S. Rich, good idea about the I2C vs. SPI.· Will-do

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 8/24/2010 6:32:57 PM GMT
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-03-22 14:30
    Andy,
    Thanks for these objects. The Propeller Eeprom object has helped me to keep track of file names used in data logging (each time the logger is started it uses a new file name for the data). I recently needed to modify the object to leave pins 28 and 29 low and as inputs after the necessary read or write has been preformed. I found the original Propeller Eeprom object was interfering with another object using pins 28 and 29.
    I added this method:
    PRI I2cEnd
      ' Restore pins to original state so other cogs can use them.
      outa[noparse][[/noparse]SCL]~                                    
      dira[noparse][[/noparse]SCL]~
      outa[noparse][[/noparse]SDA]~                                    
      dira[noparse][[/noparse]SDA]~                                    
    

    I added a call to I2cEnd at the end of FromRam and ToRam methods. This ended the conflict the object was causing.
    Duane
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-10-06 07:06
    ...Attached is the first application installment for the next Propeller Kit lab – EEPROM Datalogging and I2C...

    I was just wondering if an actual lab, that explains all of this in english, has ever been released. I know it's always fun to reverse engineer how things work and how to interface to Objects by poring over various sections of code, test demos, etc. and dreaming of copious comment lines, but once in a while I like curling up by a warm fire with a cold beverage and the english translation. Might there even be a draft version somewhere on hand?

    :)
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2011-10-13 00:00
    Andy; Any chance this lab will be updated soon? The spin document file is calling out the use of Hyper Terminal.
  • Skywise711Skywise711 Posts: 37
    edited 2013-09-10 20:57
    Just found this object (Propeller eeprom) on the Prop Education Kit sticky.

    I can find no copyright or licensing info with the source code.

    It looks perfect for my application, but since my project is potentially commercial in nature, I need to know the licensing status.

    I think the files need to be updated to include such if it's going to be released for use.

    I don't want to assume.

    Brian
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-09-10 21:15
    Skywise711 wrote: »
    Just found this object (Propeller eeprom) on the Prop Education Kit sticky.

    I can find no copyright or licensing info with the source code.

    It looks perfect for my application, but since my project is potentially commercial in nature, I need to know the licensing status.

    I think the files need to be updated to include such if it's going to be released for use.

    I don't want to assume.

    Brian


    Did you try looking for the same or similar code in the Object Exchange (OBEX)? I think most of the code in the OBEX should have some sort of license statement.

    http://obex.parallax.com/search/eeprom

    From the OBEX welcome page.... http://obex.parallax.com/
    "All objects and snippets on the Propeller Object Exchange are provided under the MIT License. "
  • Skywise711Skywise711 Posts: 37
    edited 2013-09-10 23:12
    Did you try looking for the same or similar code in the Object Exchange (OBEX)? I think most of the code in the OBEX should have some sort of license statement.

    http://obex.parallax.com/search/eeprom

    From the OBEX welcome page.... http://obex.parallax.com/
    "All objects and snippets on the Propeller Object Exchange are provided under the MIT License. "

    I had looked there, but based on descriptions alone, nothing sounded quite right, mostly too generic. The "propeller eeprom" is perfect, which I found referenced by searching the forums for other threads talking about this. This is my first attempt and this task, writing data to the eeprom.

    I guess I'll have to start downloading all the stuff in the OBEX and actually look at the code.

    Brian
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-09-11 07:24
    Skywise711 wrote: »
    ...

    I guess I'll have to start downloading all the stuff in the OBEX and actually look at the code.

    Brian

    I can't speak for Parallax but what you want to use is almost certainly under the same MIT license as what's in the OBEX, so why not email Parallax and just ask them directly?
  • Skywise711Skywise711 Posts: 37
    edited 2013-09-11 13:38
    I can't speak for Parallax but what you want to use is almost certainly under the same MIT license as what's in the OBEX, so why not email Parallax and just ask them directly?

    That was my plan if I didn't find a good answer via the thread. Since it was posted by Andy, I'll email him directly.

    Brian
Sign In or Register to comment.