Idea to keep PIC18F working for 1 or 2 seconds after system OFF

Thread Starter

aqua_life

Joined Aug 28, 2017
5
Hello,
I am trying to develop a system with CAN communication using a PIC18F25K80.
The PIC is working good with CAN, however I have a problem...
When I turn OFF the system power I would like to keep the PIC alive for 1 or 2 seconds to be able to send CAN messages to turn OFF another module.

So, basically my system is powered by 12 Volts and I have a 78L05 to feed the PIC with 5 Volts.
My idea is to use ADC or Interrupt flag in the PIC to check when the power is turned OFF.
When this happens, I must have power to send CAN messages for 1 or 2 seconds. These CAN messages will inform other modules that the system was turned OFF.
I measured the current consumption on my system and I have 36mA.
I think I could use a capacitor and a diode. However the capacitor needed is big and expensive.

Do you know any other method ?

Thank you for your help.
 

Papabravo

Joined Feb 24, 2006
14,409
Hello,
I am trying to develop a system with CAN communication using a PIC18F25K80.
The PIC is working good with CAN, however I have a problem...
When I turn OFF the system power I would like to keep the PIC alive for 1 or 2 seconds to be able to send CAN messages to turn OFF another module.

So, basically my system is powered by 12 Volts and I have a 78L05 to feed the PIC with 5 Volts.
My idea is to use ADC or Interrupt flag in the PIC to check when the power is turned OFF.
When this happens, I must have power to send CAN messages for 1 or 2 seconds. These CAN messages will inform other modules that the system was turned OFF.
I measured the current consumption on my system and I have 36mA.
I think I could use a capacitor and a diode. However the capacitor needed is big and expensive.

Do you know any other method ?

Thank you for your help.
Use a coin battery in conjunction with a low power mode of operation
 

djsfantasi

Joined Apr 11, 2010
6,803
Include space for a couple of 18650 batteries. You may need a regulator. Then, wire the supplies in parallel.

Send the isolated external power to a GPIO pin on your PIC, that can be used as an interrupt trigger. Wire it with a pull down resistor.

When this pin goes low, enter an ISR that sends the CAN messages as required. And any other shutdown tasks. The final step of the ISR is to shutdown the PIC.

If you do need an external voltage regulator, you could use another GPIO pin to disconnect the batteries when the PIC is powered down. There may be a way to combine thee functions. My reply was written in my leather powered recliner while self-quarantined. So, take it as a concept rather than an engineered solution.
 

Papabravo

Joined Feb 24, 2006
14,409
Include space for a couple of 18650 batteries. You may need a regulator. Then, wire the supplies in parallel.

Send the isolated external power to a GPIO pin on your PIC, that can be used as an interrupt trigger. Wire it with a pull down resistor.

When this pin goes low, enter an ISR that sends the CAN messages as required. And any other shutdown tasks. The final step of the ISR is to shutdown the PIC.

If you do need an external voltage regulator, you could use another GPIO pin to disconnect the batteries when the PIC is powered down. There may be a way to combine thee functions. My reply was written in my leather powered recliner while self-quarantined. So, take it as a concept rather than an engineered solution.
I'm jealous, I just have an ordinary secretaries chair.

Rather than shutting down completely you can reduce your power consumption to a very low level by going to "sleep". You wake up periodically to check things out. If the power is still off you go back to sleep.
 

Papabravo

Joined Feb 24, 2006
14,409
Another idea to consider is the "heartbeat" message. Once enabled the peripheral devices on a network will expect to "consume" a "heartbeat" message on a periodic basis. If some number of "heartbeat" intervals are missed the peripheral nodes can execute a shutdown procedure. This software change will obviate the need for the alternate solution you may have been contemplating.
 

danadak

Joined Mar 10, 2018
4,057
Q = C x V
I = C x dV / dT

Say part is 5V part, reg output is 5V, you detect power fail at 10% low, 4.5V. Say processor
works down to 3.3.

So C = ( I x dT ) / dV = (.036 x 2 ) / (4.5 - 3.3 ) = .072/ 1.2 farads = .06 farads = 60,000 uF.

Pay attention to C datasheet, if its C is proportional to its V to get worst case.

A .1 Farad part costs approximately >= $ 1.

https://www.digikey.com/products/en/capacitors/electric-double-layer-capacitors-edlc-supercapacitors/61?FV=mu100mF|2049,mu5.5V|2079,-8|61&quantity=0&ColumnSort=1000011&page=1&k=supercapacitor&pageSize=25&pkeyword=supercapacitor

When yiou do above calculation use worst case values everywhere.

Also when power is reapplied you have issue rechsrging cap, how long it takes, in system considerations.



Regards, Dana.
 
Last edited:

ElectricSpidey

Joined Dec 2, 2017
1,236
I'm probably way off base here, but why would you shut down power then expect a device to still send messages?

I would think a separate power down circuit is in order. IE:

Press a button, it starts a timer and changes a GPIO pins state, this triggers an ISR to send the messages, then at the end of the time it shuts off the power with a relay or such.
 

ElectricSpidey

Joined Dec 2, 2017
1,236
Actually I was thinking of a simple two button system that doesn’t require any external parts other than the relay, a transistor and diode and some push buttons.

Something like this…

One button changes the state of a GPIO pin triggering a ISR, the ISR starts a timer or delay, and sends the shutdown messages, at the end of the time/delay the relay opens and turns off the power supply.

The other button bypasses the relay terminals, starting the micro, which then takes over control of the relay.

One button on.
One button off with delay.
 
Top