Shop OBEX P1 Docs P2 Docs Learn Events
Need to store a 2-Byte number — Parallax Forums

Need to store a 2-Byte number

CatwareCatware Posts: 14
edited 2005-01-26 19:52 in General Discussion
Hi guys, I'm new to the microcontroller scene, having just found out about and picked up my SX28AC development kit last Friday. I'm trying to build a frequency counter for production, and when the user calibrates the device, I need to store a 2-Byte number. This is all I need to store, and it needs to be persistant across power cycles -- obviously no one wants to recalibrate every time they turn the device on. Is there any way to do this without adding an EEPROM? That seems like massive overkill for my modest needs. Thanks a lot for any input!

It's possible I could save this calibration setting·by reading the resistance that the user set with a trimmer, but I'd rather do it digitally, and haven't read that far in the 'Beginner's programming the SX' manual yet. All I know how to do is detect a threshold voltage, not full A/D conversion.

Comments

  • PJMontyPJMonty Posts: 983
    edited 2005-01-26 02:05
    Catware,

    Sorry, but you're going to be adding some EEPROM. The SX chip's EEPROM can't be programed at runtime, so it can't be used for storing user data. Still, while an EEPROM is overkill in terms of storage capacity, it doesn't have to be big. There's lots of serial EEPROM that are tiny things with only a few leads.
      Thanks, PEterM
  • BeanBean Posts: 8,129
    edited 2005-01-26 02:18
    The only other thing I can think of is (2) 8 position dip switches... I know it's about the lowest tech solution...
    Bean.
  • CatwareCatware Posts: 14
    edited 2005-01-26 03:10
    Thanks a lot for the input. I was hoping the state of the registers·was somewhat persistant when turned off [noparse]:)[/noparse] but I'll have to decide on either an EEPROM or perhaps an analog trimmer. I think 16 dip switches would be too confusing for most folks,·but the idea was·a good shot in the dark anyway. Great response time, great help!

    David


    Edited:

    Well, I found some 8-pin 2-wire·128bit EEPROM on Mouser for $.35, so that's not too much overkill [noparse]:)[/noparse]

    Post Edited (Catware) : 1/26/2005 3:20:32 AM GMT
  • BeanBean Posts: 8,129
    edited 2005-01-26 03:40
    How about putting the SX to sleep and use a "super-cap" to keep the memory alive.
    The current draw is something like 1uA in sleep mode, so you should be able to keep the settings for months without power.

    Bean.
  • CatwareCatware Posts: 14
    edited 2005-01-26 15:22
    Hey, that's a good idea. More on that thought, a watch battery should work too. I kind of got interested in the 128bit serial EEPROM I found at Mouser, though; I think I'll play around with reading/writing from that before a definite decision.·Great ideas, guys, thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-26 16:19
    One more possibility, depending on what other chips you may be connecting to the SX, some have their own extra memory.· One good example is the DS1302, which has I think 40 bytes of user RAM to store whatever you want in it.· Generally the DS1302 is battery-backed, so it retains that information.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-26 16:40
    Dallas Semiconductor sells SRAM nonvolatile controller chips which apply backup power (via a battery) to retain the data in an SRAM, It appears that you may be able to modify this to accomodate giving the SX power. An example chip is here:·http://rocky.digikey.com/WebLib/Dallas/Dallas%20Web%20Data/DS1210.pdf. From what I·can gather from the spec you would tie pin 3 to pin 1 and whenever Vcc drops below·4.5V it switches to supplying via the battery (it also provides the ability of connecting a redundant battery) the voltage drop of the circuit is a max of .3 volts so using 3V lithiums would supply the SX with 2.7V which the SX can operate at (though you won't be, this just means data will be retained in the ram). If you were using the SX48/52 I'd suggest disabling the clock when sleeping but the SX28 doesn't have this feature. But I would consider enabling the brown out detector to 2.2V, this won't save your data (data RAM will be·in an·undefined state after power up) but upon wake up you can detect if the brown-out was triggered which will tell you the data is suspect and shouldn't be trusted.

    I would not just hook up a battery to the SX (while also providing a 5V power) without incorperating a supervisor circuit·to switch between the two,·this can cause your battery to explode. Bean's idea is to hook a super cap that would draw its power from the supply then feed it back during power down. There is a potential problem with this though, if you use a very large cap, it will cause the power to the SX to rise slowly, causing the drt_time_out to activate before the power is at a high enough voltage. Check pages 140 and 141 of the SX User's Manual (http://www.parallax.com/dl/docs/prod/sx/SxUsersManualV31.pdf) for a discussion on this and a suggested solution.

    If you do decide to go with the supercap idea, I would get a 5V 1F aerogel cap (yes 1 Farad) they are $9.00 but they are compact and designed for this type·application. You could get by with a smaller size but it depends on how long you plan on keeping the power off (hours, days, weeks, years?), if you need approximate data retention lifetimes for various sizes ask and I can do it for you. I wouldn't go with your standard electrolytic capacitor though you might be tempted (they are cheaper), thier leakage current is dreadful, and you'd likely loose more of the stored charge to inefficiencies of the capacitor than with powering the SX.

    Most importantly, whichever route you choose (unless you go the eeprom route) always be sure to place the SX in sleep mode before disconnecting the power. With the SX running in active mode, the backup power will be quickly consumed loosing your data and requiring your to replace the batteries (if you use a battery solution).

    Cheers,
    Paul
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-26 16:41
    Seems Chris and I are thinking in the same direction with two different outcomes [noparse]:)[/noparse]

    Also another prob with the cap idea, if you have other chips on your board, they will also draw power from the cap and if they have no sleep mode as well you can find your cap drained quickly. The Dallas chip seperates the supply to the SX from the supply from the rest of the circuit, meaing it won't try to supply power to any other chips.

    One last addendum, if the /MCLR pin is powered by you 5V external supply, the SX chip will automatically place the SX in reset condition, which is equavalent to a SLEEP, meaning no SLEEP command is needed and aleviating the fear of the SX running in active mode (this is only when using the dallas chip, the cap would drive the /MCLR line high as well, still requiring you to place the SX into SLEEP)

    Post Edited (Paul Baker) : 1/26/2005 5:08:15 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-26 17:03
    Paul,

    ·· In the past I had used several different Dallas chips with Z80 designs...Most often everything had some sort of battery-backup included, since then the code was running off a 27C256 EPROM, and there was no storage except the 62256 SRAM.· So, you'd either use a Dallas Smart-Socket, or Battery-Backer SRAM equivalent if you needed to save alot of data.· Or their BBRTC chips has extra memory for configuration settings much like the DS1302 does on a serial interface.· I almost think there was a Watchdog that we used once that also had a few extra bytes, but that was forever ago.

    ·· Anyway, I suggested it on the off-chance he would be using an extra chip anyway, although in retrospect I guess if not, there's not much difference to using an EEPROM in terms of connections and code.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-26 17:23
    Chris, true, my suggestion goes more to a general need of the SX to retain state, thus preserving all of its memory contents. In this particular application Catware would likely be best served by a 8-dip (or 8-soic) SEEPROM with a few bytes, its cheaper and its reliability is greater (it think average retention times of EEPROMS in non-radiation harsh environments is >10years and 10K to 100K rewrite cycles before wear-leveling issues become a problem).

    Paul

    I've also contemplated using Atmel's ATtiny15 (8-DIP) as a general off-board accessory for the SX, it has 6 I/O, 4 of which can be operated as 10 bit A/D inputs, 32 bytes of RAM, 64 bytes of eeprom, 1K program flash, 1 MIPS, 2.7-5.5V operation, and in circuit programmable via an SPI interface·for just $2.71 for a single unit. Thats quite a bit of goodies packed into such a small package for such a small price. Maybe after the contest I'd do it and post the project over to that forum.

    Post Edited (Paul Baker) : 1/26/2005 5:28:51 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-26 19:52
    Paul,

    ·· It would be interesting to see!





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
Sign In or Register to comment.