Need to store a 2-Byte number
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.
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
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
Bean.
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
The current draw is something like 1uA in sleep mode, so you should be able to keep the settings for months without power.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
·
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
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
·· 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
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
·· 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
·