Array storage while sleeping

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Synergy6
Posts: 28
Joined: Wed Jan 18, 2017 3:38 pm
Been thanked: 4 times
Contact:

Array storage while sleeping

Post by Synergy6 »

Hi,

I am working on a project and need to get a clear answer on a potential problem.

We are using a PIC to communicate with a sensor. This sensor has some data that needs to be read initially in order to use it in formulating the output.
This data will be pulled upon startup and stored in an array. The results will also be stored into an array.
The device will be battery powered so it makes sense that when not sampling data we put it to sleep.

The question we have is when asleep do we loose the data stored in the array?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Array storage while sleeping

Post by kersing »

What controller are you using? What sleep settings do you want to use?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Array storage while sleeping

Post by Steve »

Kersing is correct - it depends on what microcontroller you are using and what sleep mode you have it in.

Retaining power to the RAM is fairly significant and so in certain applications it is desirable to remove this power. I believe many modern micros have multiple options for sleep and so you will need to look at the device datasheet to see if this is possible.

One alternative is to use non-volatile memory such as EEPROM (some chips have it internally, but if not you can use an external chip). And other chips allow data to be written to the program memory space which is also non-volatile.

Hope this helps.
Steve.

Synergy6
Posts: 28
Joined: Wed Jan 18, 2017 3:38 pm
Been thanked: 4 times
Contact:

Re: Array storage while sleeping

Post by Synergy6 »

Hi,

The chip is possibly going to be PIC18LF25K22.
As for sleep modes, no idea as of yet, i didnt realise there were more than one setting. It will be the setting that requires least power.

I dont think EEPROM will be suitable as we will be constantly reading and writing to it so it will wear over time, Or at least thats how i read it.
Final application is a datalogger.

Program memory seems like a good option tho as long as this doesnt wear out as well with repeated writes.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Array storage while sleeping

Post by kersing »

Synergy6 wrote:Program memory seems like a good option tho as long as this doesnt wear out as well with repeated writes.
Except RAM all memory wears out when frequently rewritten.

The 18LF25K22 should retain RAM contents while in sleep mode if the voltage does not drop below 1.5V according to the data sheet.

For lowest power sleep mode all peripherals need to be disabled as well as brown out detect, watchdog timer, secondary oscillator and fixed voltage reference. If you want to take periodic measurements you will need to either provide an external interrupt source or use the watchdog (increasing the sleep consumption of the chip) to wake the device from sleep.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply