Sleep mode question

Hello, friends!

I need a help with sleep-wake processes.

Goal is power on my board without algorythm (in sleep mode) than when +5v comes to some pin (in my case D2) board needs to wake and work (my algorythm controls PWM).

When +5v disappears , board waits 20 secs, then 10 secs and sleep.

I made program but with errors - works not as i expected - or not wakes al all , or works without sleep-wake.


This is how I understood the program you needed:

  • On the boot MCU waits for the 5V signal
  • Then it does something within 20 seconds
  • Then it idle for 10 seconds
  • Then it sleeps, until the next signal is received

Am I understood your program correctly?

If so, here my thoughts about problem places:

  1. You have no initial pulse (there are pulse-on-true nodes, right?) Try to add any node between defer and sleep-until-s... and bind Boot on the free pin.
  2. I don’t know how the node sleep-until-s... works, but I suppose that DONE pulses when it awaken. And it looks like you need to link it into SET and RST from defer. But you don’t need a flip-flop and puls... node here at all. Just link the pulse output directly to the SET input of delay node.
  3. Then just link DONE of the delay node (20s) with SET of the second one. While your first delay is acting (ACT is true) — do your job (which is unseen).
  4. Link DONE of the second delay node (10s) right in the defer node

In conclusion, I have to say, that you have a conceptually problem here by converting pulses into booleans and back. It’s a bad idea, when you can work only with pulses. At least, because you might loss some of the pulses. Moreover, if you need to pass pulses with some conditions, it’s much better to use gate node, instead of converting booleans to pulses.

Thank you for an answer.

I’ve corrected program :slight_smile:

  • On the boot MCU waits for the 5V signal
  • Then it does something till +5v present
  • When +5v disappers it works 20 seconds more
  • Then it idle for 10 seconds (it’s not neceessary)
  • Then it sleeps, until the next signal is received

This is sleep-until-switch node:

Feel free to write in Russian if you wish :slight_smile:

So, the problem is solved? :slight_smile:

Problem mostly solved , thank you very much for your advice! :slight_smile:

Accepting your advices i made this patch.
Everything works as expected except board reaction on D2 pin. It works on disappearing +5v (though in patch’s help was “either from low to high or from high to low”). :slight_smile:

Screen Shot 2020-05-14 at 22.30.59

But it is not very big problem to invert signal on this pin.
Thank you again!

It looks like you still got a wrong part of a program: you have linked ACT into pulse-on-true node, so it produces a pulse right at the moment when the delay has been started (the second delay node became useless in your program). I think you need to link the DONE output directly to the defer node.

Probably, there is no bug in the slep-until-switch node, but you put the MCU into sleep earlier than you think, and then you missed one of the signal changes. :thinking:

This node is “pulse on false”.
Making pulse when second delay over

Changed links as you advice - result when +5v present - my program runs 20 sec than 10 stops sec than 20 secs run then 10 secs stop. Some cycle loop.

With added “pulse on false” linked to second delay there is no this cycle. Seems to this patch generating excess pulse.

Update: in both cases 20 of 10 off :frowning:

Update #2:

Everything works as expected without second delay:

I will think about killing second delay :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.