cancel
Showing results for 
Search instead for 
Did you mean: 

Power turn ON and Power turn OFF detection.

vbk22398
Senior

My requirement is as follows.
When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this? Kindly let me know the solution if anyone has come across such a situation.

Thank you!

18 REPLIES 18
SofLit
ST Employee

Not obvious.

Need to keep the MCU powered while sending string over UART.

Use external capacitor/super cap to power supply the MCU during the power down? + detect the power drop on power source to trigger the UART transmission?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@vbk22398 wrote:

When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". N!


That bit's easy - just make sending that message the first thing you do!

 


@vbk22398 wrote:

Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this? 


That requires two things:

  1. detect that the power has gone OFF;
  2. have sufficient backup power to keep the microcontroller running long enough to complete sending the  "Power is OFF" message.

 


@SofLit wrote:

+ detect the power drop on power source to trigger the UART transmission?


How to do the above? I am completely out of ideas to implement your logic. Could you be a little elaborate. I have doubts like to which pin should I connect the external capacitor/super cap. What is the rating of capacitor? Are there any other options apart from capacitor. How to track the power down? Kindly elaborate.

Thank you!


@vbk22398 wrote:


I have doubts like to which pin should I connect the external capacitor/super cap. 

Check if the MCU features an internal comparator that will compare the power supply level to what expected. Otherwise need to add an external comparator that detects the power down which triggers over MCU EXTI the UART transfer.

 


@vbk22398 wrote:


What is the rating of capacitor? Are there any other options apart from capacitor. 


The capacitor needs to be mounted on the power supply of the MCU. For the rating you need to find it yourself by test ..

Make some internet search on super cap usage, example: https://www.digikey.com/en/articles/how-to-use-a-single-supercapacitor-as-backup-power-for-a-5-volt-supply

PS: we are here to guide you and propose some guidelines not supposed to provide a complete solution.

Thanks

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

 


@vbk22398 wrote:

 What is the rating of capacitor? 


That will depend on your system - how much power it uses.

The capacitor needs to be large enough to store sufficient energy to guarantee to power your system for long enough to complete sending the message.

 

@vbk22398 wrote:
Are there any other options apart from capacitor. !

Sure: https://www.google.com/search?q=microcontroller+backup+power 

 

@vbk22398 wrote:

How to track the power down? 


You need to give more details of your system:

  • where does its power come from - AC mains? battery? other ... ?
  • how does it get switched on/off?

 

It seems that you lack electronic design skills/knowledge - do you not have anyone to help with what is an electronic design project?


@vbk22398 wrote:

Are there any other options apart from capacitor. 


The obvious one would be a battery - which could be rechargeable ("secondary") or not ("primary")

Pavel A.
Evangelist III

But this can be also seen "upside down". Imagine a smarter terminal that understands periodic "heart beat" signals from the MCU. The first time it sees the signal, it prints "Power on". After it misses couple of signals it prints "power off" or whatever ))

 

> I have doubts like to which pin should I connect the external capacitor/super cap. What is the rating of capacitor? Are there any other options apart from capacitor. How to track the power down? Kindly elaborate.

This would be the job of the hardware designers.

Tell them that the power supply stage must be able to maintain the 3.3V supply for at least 100ms (or more) after mains off. State you average/max current requirement at this stage, and they should be able design it.
A properly sized electrolytic capacitor will do the job -> Q = I * t.

I had been working on a project were the main MCU stored about a dozen parameters into EEPROM during that remaining time.


@Ozone wrote:

This would be the job of the hardware designers.


Indeed.

Also the job of the hardware designers to provide a signal which indicates "power lost" (or, conversely,  "power good")