Shop OBEX P1 Docs P2 Docs Learn Events
Storing Info in the SX — Parallax Forums

Storing Info in the SX

SailerManSailerMan Posts: 337
edited 2007-03-22 01:40 in General Discussion
I need a way to store setting in the SX28.· I can create Data Statements to create the Default, but I want to be able to configure the setup using the serial connection I have.

I am Sending "!CMD" then I will send a Command number and a setting and I want to store it in the SX28 even if power is removed I want it to stay.

Can someone help...Again.. [noparse]:)[/noparse]

Regards,
Eric
·
«1

Comments

  • JonnyMacJonnyMac Posts: 8,959
    edited 2007-03-09 02:33
    You're going to have to attach an external EEPROM. SX/B has I2C functions that make using them pretty straightforward.
  • BeanBean Posts: 8,129
    edited 2007-03-09 03:05
    Eric,
    The flash memory on the SX doesn't work like EEPROM. It requires a high voltage to program (that the SX-Key/SX-Blitz provides).
    There is no way the SX can change it own flash memory.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • SailerManSailerMan Posts: 337
    edited 2007-03-09 03:19
    OK... Thanks...Which EEPROM works well with the SX-28.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-09 04:13
    Any I2C EEPROM should do. Whatever is large enough for the amount of data you need to store. The part numbers mostly start with 24LC, then a number like 16, 32, 64, 128, 256, 512, 1024. This number is the number of bits in the device. Divide by 8 to get the number of bytes. The largest current devices are 128K bytes. The theoretical maximum using the current addressing scheme (8 device addresses, each with a two byte address) is 512K bytes.
  • JonnyMacJonnyMac Posts: 8,959
    edited 2007-03-09 06:20
    If you look in the help file under any of the I2C commands there's a circuit and demo code for the 24LC16, a 2K device that you can get from Parallax.
  • SailerManSailerMan Posts: 337
    edited 2007-03-09 12:20
    OK thanks... I hope the 24LC16 comes in a SMT design.
  • BeanBean Posts: 8,129
    edited 2007-03-09 13:07
    Eric,
    You don't say how many bytes you want to store, but I have a bunch of 24C00 EEPROMs.
    They only hold 16 bytes though. I'll mail you some if you can use them. They are SOT23-5 size.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • SailerManSailerMan Posts: 337
    edited 2007-03-09 13:51
    Bean,

    Are you serious? Yeah for this project I'm only gonna need a few bytes.

    I'll PM you a mailing Address.

    Regards,
    Eric
  • BeanBean Posts: 8,129
    edited 2007-03-09 14:13
    Eric,
    How many do you need ?
    You don't need to pay me anything for them, I'll just pop them in an envelope.
    I have a whole reel of them.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • SailerManSailerMan Posts: 337
    edited 2007-03-09 16:35
    Bean,

    I don't feel right about taking them... How about 5 or 10... They seem like they are going to be handy.

    Thanks for this, If I need more how much are you asking?

    Eric
  • BeanBean Posts: 8,129
    edited 2007-03-09 17:13
    Eric,
    I got a reel of several thousand from Ebay for cheap.
    I'll send you a bunch, the postage stamp would cost more than 10 pcs [noparse];)[/noparse]

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • SailerManSailerMan Posts: 337
    edited 2007-03-09 18:14
    OK thanks... [noparse]:)[/noparse] I'll look for them.

    Eric
  • Henry CassonHenry Casson Posts: 12
    edited 2007-03-10 17:33
    Most likely this is a dumb question. Can this sort of external memory allow the SX28 to run a program longer than can fit in the existing memory ? Henry.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-03-10 18:42
    Can this sort of external memory allow the SX28 to run a program longer than can fit in the existing memory?
    No, but if your program·involves using·DATA/WDATA then that all can be stored in an external memory leaving more EE/Flash available.
  • SailerManSailerMan Posts: 337
    edited 2007-03-12 14:03
    Bean,

    Do· you have sample code that works with these and the SX-28?

    Regards,

    Eric
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2007-03-12 16:16
    Hello Eric,

    Have you seen the EEPROM sample code in SX/B on the following post:

    http://forums.parallax.com/forums/default.aspx?f=7&m=172860&p=1&ord=a

    It may help you get the external EEPROM up and running a bit faster. You should be able to prototype and test with a DIP version of the chip and then go to a surface mount part for your final design.

    Best Regards,

    Robert
  • JonnyMacJonnyMac Posts: 8,959
    edited 2007-03-12 16:34
    Details can be found in here: http://www.robotstore.com/download/276568catalyst.pdf

    The help file code can be adapted easily -- it looks like the only change is that the 24C00 just uses one address byte versus two in the 24LC16B.

    Post Edited (JonnyMac) : 3/12/2007 4:50:25 PM GMT
  • BeanBean Posts: 8,129
    edited 2007-03-12 16:37
    Eric,
    They are pretty standard. Here is the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/21178F.pdf
    They are 24LC00T/OT devices and I sent you 50 or so today.

    For a write you do:

    START
    SEND $A0
    SEND addr ' 0 to 15
    SEND data ' 0 to 255
    STOP
    PAUSE 5 ' Allow time for device to write data


    For a read you do:

    START
    SEND $A0
    SEND addr ' 0 to 15
    START
    SEND $A1
    READ bytevar
    STOP

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com


    Post Edited (Bean (Hitt Consulting)) : 3/12/2007 4:41:52 PM GMT
  • SailerManSailerMan Posts: 337
    edited 2007-03-12 16:55
    Thanks all... It was a little odd in reading an Address... Thanks for clearing that up.


    Bean... Thanks for everything.

    Eric
  • egpegp Posts: 2
    edited 2007-03-16 16:09
    Bean,

    I'm wondering if I sent you some stamps to cover postage, would you be willing to send me some of those 24LC00T/OT devices?
    If so, send me an email to (egp at egp dot net) with your snail mail address, and I'll send you some stamps and my snail mail address.
  • BeanBean Posts: 8,129
    edited 2007-03-16 16:35
    Send me a private message with your mailing address.
    Just consider it a early birthday present [noparse];)[/noparse]

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A problem well defined is a problem half solved"

    "Just because you're approved, doesn't mean you can afford it."
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Cheap used 4-digit LED display with driver IC·www.hc4led.com
    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • egpegp Posts: 2
    edited 2007-03-16 16:46
    Thanks, Bean, that's very generous of you. I sent you a separate email with my snail mail address.
  • SailerManSailerMan Posts: 337
    edited 2007-03-21 15:45
    OK I believe that I jumped too Quick... I laid out my circuit and etch a board with the SX and a 24C00 Eeprom... I'm, guessing it's not working because I don't have Pull up resistors on the SCL and SDA line... Would this be a good assumption?
  • JonnyMacJonnyMac Posts: 8,959
    edited 2007-03-21 16:13
    Yes, I2C requires pull-ups (usually 4.7K) on the SCL and SDA lines. The idea behind I2C is that the transmitting device pulls the line low, the pull-up handles the high. That way if two devices transmit at the same time there is no electrical problem (as there would be if the transmitter drove the line high).
  • SailerManSailerMan Posts: 337
    edited 2007-03-21 16:17
    That's what I thought... Darn!!! All of those darn holes drilled. Hahahaha Thanks for confirming that.
  • BeanBean Posts: 8,129
    edited 2007-03-21 16:19
    Eric,
    Depending on many factors you MIGHT get away with just enabling the internal pull-ups on the SDA and SCL pins.
    I don't recommend depending on it, but with some devices it does work.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"

    Benjamin Franklin
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Cheap used 4-digit LED display with driver IC·www.hc4led.com
    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Coming soon! Propeller based OSD module www.hittconsulting.com
    ·
  • SailerManSailerMan Posts: 337
    edited 2007-03-21 17:54
    I'm using the SX48 with one 24C00 that you sent me... I will try that. Good Idea as usual.
  • SailerManSailerMan Posts: 337
    edited 2007-03-21 22:21
    I am Using a 24C00 and I have SDA Connected to RD.4 and SCL Connected to RD.5 on the SX48
    I am trying to run this code.

    An LED will flash if the Code written to and returned from the EEProm is the same.

    I don't have external Pull up resistor connected only the internal.

    Should the Code below work? If so I'm going to have to redesign my circuit.

    Thanks in Advance,
    Eric

    DEVICE          SX48, OSCHS2, BOR42
    FREQ            4_000_000
    
    ID  "24C00"
     
    Pullup RD.4
    Pullup RD.5
     
    Sample Var Byte
     
    PROGRAM Start NOSTARTUP
    Start:
     I2CStart RD.4
     I2CSend  RD.4,$A0
     I2CSend  RD.4,0
     I2CSend  RD.4,170
     I2CStop  RD.4
     Pause 50               
     
    Do
     I2CStart  RD.4  
     I2CSend   RD.4,$A0
     I2CSend   RD.4,0
     I2CStart  RD.4
     I2CSend   RD.4,$A1
     I2CRecv   RD.4,Sample,0
     I2CStop   RD.4
    
     If Sample=170 Then  
         Toggle RD.7
      Pause 100
     Endif 
    Loop
    
    


    ·OK I carefully added some External Resistors...They look like Smile but assume it will work.

    I still can't read the value of "Sample" as 170

    Attached is an O-Scope attached to the SDA and SCL line.

    Can anyone offer a solution.

    Regards,
    ERic


    Post Edited (SailerMan) : 3/21/2007 11:48:30 PM GMT
  • JonnyMacJonnyMac Posts: 8,959
    edited 2007-03-22 00:31
    Check your connections.

    And I think your NAK bit is set incorrectly -- on the final byte read it should be 1, not 0 as in your listing.

    And... it is very dangerous to embed "magic numbers" -- including pin numbers -- into your listings; HUGE bug generator. Try this version:

    DEVICE          SX48, OSCHS2, BOR42
    FREQ            4_000_000
    ID              "24C00"
    
    SDA             PIN     RD.4
    SCL             PIN     RD.5  
    Led             PIN     RD.7
     
    sample          VAR     Byte
    
     
    PROGRAM Start NOSTARTUP
    
    Start:
      PULLUP SDA
      PULLUP SCL
    
    Main:
      I2CSTART SDA
      I2CSEND  SDA, $A0
      I2CSEND  SDA, 0
      I2CSEND  SDA, 170
      I2CSTOP  SDA
      PAUSE 10
    
      DO
        sample = 0
        I2CSTART SDA
        I2CSEND  SDA, $A0
        I2CSEND  SDA, 0
        I2CSEND  SDA, $A1
        I2CRECV  SDA, sample, 1
        I2CSTOP  SDA
    
        IF sample = 170 THEN
          TOGGLE Led
          PAUSE 100
        ENDIF
      LOOP
    
      END
    
  • SailerManSailerMan Posts: 337
    edited 2007-03-22 01:40
    I am usually careful about my wiring, but I totally missed a ground jumper. Ugh! Works now...I could just slap myself silly now!!!!

    Thanks Jonny
Sign In or Register to comment.