Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Propeller Chip > PE Kit Lab Applications – EEPROM Datalogging and I2C  Forum Quick Jump
 
New Topic Post Reply Printable Version
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1131
 
   Posted 9/25/2007 9:34 PM (GMT -7)    Quote This PostAlert An Admin About This Post.

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[32]

 

OBJ

  eeprom : “Propeller Eeprom”

 

PUB Main

  ...

  eeprom.VarBackup(@values, @values[31] + 3)    ‘ Backup

  ...

  eeprom.VarRestore(@values, @values[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[31] + 3, eeAddr)

 

   ...

 

   ‘ Copy from eeAddr to eeAddr + 127 to value[0]..value[31].

   eeprom.ToRam(@value, @value[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)) : 3/10/2008 5:29:38 PM GMT



File Attachment :
Test Propeller Eeprom v0.677 - Archive [Date 2007.09.25 Time 21.33].zip   18KB (application/x-zip-compressed)
This file has been downloaded 2092 time(s).
Back to Top
 

Rayman
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2007
Total Posts : 3127
 
   Posted 9/26/2007 5:29 AM (GMT -7)    Quote This PostAlert An Admin About This Post.
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?
Back to Top
 

rjo_
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2007
Total Posts : 1836
 
   Posted 9/26/2007 11:58 AM (GMT -7)    Quote This PostAlert An Admin About This Post.
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:)



Rich
Back to Top
 

Andy Lindsay (Parallax)
Forum Moderator



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1131
 
   Posted 9/26/2007 4:01 PM (GMT -7)    Quote This PostAlert An Admin About This Post.
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)) : 3/10/2008 5:28:10 PM GMT

Back to Top
 

Duane Degn
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Apr 2008
Total Posts : 57
 
   Posted 3/22/2010 7:30 AM (GMT -7)    Quote This PostAlert An Admin About This Post.
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[SCL]~                                    
  dira[SCL]~
  outa[SDA]~                                    
  dira[SDA]~                                    
I added a call to I2cEnd at the end of FromRam and ToRam methods. This ended the conflict the object was causing.
Duane
Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
 
Forum Information
Currently it is Thursday, July 29, 2010 5:21 PM (GMT -7)
There are a total of 462,441 posts in 62,066 threads.
In the last 3 days there were 90 new threads and 802 reply posts. View Active Threads
Who's Online
This forum has 20143 registered members. Please welcome our newest member, ME01.
55 Guest(s), 14 Registered Member(s) are currently online.  Details
John Abshier, Erik Friesen, Kevin Wood, simpsonmichael1, BradC, David Betz, Julian800, Martin Hodge, prof_braino, Harley, Sapieha, wiresalot, Ravenkallen, Tubular