• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Powering off via UI while using a Mausberry Circuit

Scheduled Pinned Locked Moved Help and Support
mausberrypower offcircuitmenuled
72 Posts 4 Posters 17.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    cyperghost @caver01
    last edited by cyperghost 14 Sept 2017, 16:10

    @caver01 Yes this behaviour sounds logical.
    Man... it could be so easy but I think the SSR is also a good catch. I use one to activate and deactivate the monitor from LCD by switching on/off the video input via GPIO. So in fact it is just the same approach as to toggle a LED on/off.

    1 Reply Last reply Reply Quote 0
    • C
      caver01
      last edited by 14 Sept 2017, 16:11

      It's hard to blame the design--if all you ever do is use the power button, it's fine. But if you do a soft shutdown without using the button, it seems as though the mausberry has no way to detect that, and it sits in a powered state.

      My 4-player cocktail style cabinet built as a custom "roadcase"

      C C 2 Replies Last reply 14 Sept 2017, 16:13 Reply Quote 1
      • C
        cyperghost @caver01
        last edited by cyperghost 14 Sept 2017, 16:13

        @caver01 We will change this via SSR-GPIO software switch ;)

        C 1 Reply Last reply 14 Sept 2017, 16:24 Reply Quote 0
        • C
          caver01 @caver01
          last edited by caver01 14 Sept 2017, 16:14

          What I need is a normally open switch that closes when power gets cut. If I wired that in parallel with the power button, it will trigger when the Pi shuts down without any need for a GPIO command to be sent.

          <EDIT> ha ha I just read the first sentence on the link to the SSR. Says it is a normally open switch. . . I may have to pick one up.

          My 4-player cocktail style cabinet built as a custom "roadcase"

          C 1 Reply Last reply 14 Sept 2017, 16:22 Reply Quote 0
          • C
            cyperghost @caver01
            last edited by cyperghost 14 Sept 2017, 16:22

            @caver01 Normally means powered, so indeed it should work ;)

            1 Reply Last reply Reply Quote 0
            • C
              caver01 @cyperghost
              last edited by caver01 14 Sept 2017, 16:24

              @cyperghost
              Ok, so I was thinking if we had a component that was OPEN when powered, but closes when the power goes off, we could wire this to a power pin and in parallel with the power button. It would trigger the mausberry like a button press when the Pi goes off. But that would make the circuit think the power button is being held down!

              So, if you plug in the system, it would power up immediately. Maybe it would even loop.

              My 4-player cocktail style cabinet built as a custom "roadcase"

              C 1 Reply Last reply 14 Sept 2017, 16:25 Reply Quote 0
              • C
                cyperghost @caver01
                last edited by cyperghost 14 Sept 2017, 16:25

                @caver01 But the mausberry works with permanent switches?
                But I think the real button won't work anymore ;(

                So use a GPIO to set event on/off ;)

                C C 2 Replies Last reply 14 Sept 2017, 16:27 Reply Quote 0
                • C
                  cyperghost @cyperghost
                  last edited by cyperghost 14 Sept 2017, 16:27

                  @caver01
                  So you soldering the SSR next to your switch. So you have two switches running.
                  I'm guessing the hardware switch is a momentary one - with normal state off?
                  So the SSR can also act as a momentary, unpowered via GPIO it is off, powerd via GPIO it is on....

                  So it think it should work ;)

                  C 1 Reply Last reply 14 Sept 2017, 16:36 Reply Quote 0
                  • C
                    caver01 @cyperghost
                    last edited by 14 Sept 2017, 16:33

                    @cyperghost said in Powering off via UI while using a Mausberry Circuit:

                    @caver01 But the mausberry works with permanent switches?
                    But I think the real button won't work anymore ;(

                    So use a GPIO to set event on/off ;)

                    Yep. use it to trigger an actual (parallel) button press.

                    What I can't figure out is why, even after the pi shuts down with a soft shutdown, the mausberry ignores my button presses. It is like it locks into a powered state. It must be checking the state of Pin 2:

                    If Pin2 = 0 and power button is closed, DO POWER ON
                    if Pin 2 = 1 and power button is closed, DO POWER OFF

                    so, after a soft shutdown, the mausberry thinks I am trying to turn the pi back on, but it is already on, so it does nothing. It's like an anti-bounce state, the time right after a POWER ON, but before the script is running and can set Pin 2 = 1.

                    My 4-player cocktail style cabinet built as a custom "roadcase"

                    1 Reply Last reply Reply Quote 0
                    • C
                      caver01 @cyperghost
                      last edited by 14 Sept 2017, 16:36

                      @cyperghost If I get one of these to test, I will need help. Which pin on the SSR goes to what, and which pin gets the resistor?

                      My 4-player cocktail style cabinet built as a custom "roadcase"

                      C 1 Reply Last reply 14 Sept 2017, 16:46 Reply Quote 0
                      • C
                        cyperghost @caver01
                        last edited by 14 Sept 2017, 16:46

                        @caver01 page 7 shows connection diagramm
                        Pin 1 goes to positive value (= GPIO Pin), Pin 2 is ground, set a resistor with right value (330ohm for 3.3V).

                        Pin 3 and 4 is the switch ... Connection does not matter here see page 4, it is independent if you switch the ground or positive value.

                        C 1 Reply Last reply 14 Sept 2017, 17:02 Reply Quote 0
                        • C
                          caver01 @cyperghost
                          last edited by 14 Sept 2017, 17:02

                          @cyperghost Looks like the diagram has the resistor on Pin 1. Does it matter?

                          My 4-player cocktail style cabinet built as a custom "roadcase"

                          1 Reply Last reply Reply Quote 0
                          • C
                            cyperghost
                            last edited by cyperghost 14 Sept 2017, 17:05

                            @caver01 No but the resistor has to be placed somewhere in the line (+) LED (-)
                            So (+) R LED (-) or (+) LED R (-) doesn't matter

                            C 1 Reply Last reply 14 Sept 2017, 17:45 Reply Quote 0
                            • C
                              caver01 @cyperghost
                              last edited by 14 Sept 2017, 17:45

                              @cyperghost Oh I get it. . . because the device itself uses an LED internally for actuation.

                              Hey, thanks for your input here and the fun conversation about this. @madmodder123 I hope I didn't overstep by totally dominating your original post. I think we were on the same page with this, and it looks like a little testing may prove that while the Mausberry circuit is an excellent solution for an add-on power switch (especially when coupled with the updated script), it comes with an assumption that the button you add will be the only shutdown method used. It is not setup with awareness of additional soft shutdown procedures that aren't triggered by the button and the circuit itself.

                              My 4-player cocktail style cabinet built as a custom "roadcase"

                              1 Reply Last reply Reply Quote 1
                              • C
                                cyperghost
                                last edited by cyperghost 14 Sept 2017, 19:01

                                @caver01 I'm pretty sure that a normally opened ssr works together with a momentary switch!

                                Annother suggestion. I think if we use a normally closed SSR and connect it to the $GPIOPin2 so there is no current as long as the Pie is active. But if is inactive it would close the reset pads of the mausberry... do you think that may work?

                                C 1 Reply Last reply 14 Sept 2017, 19:30 Reply Quote 0
                                • C
                                  cyperghost @cyperghost
                                  last edited by cyperghost 14 Sept 2017, 19:30

                                  Some "improvments" to the original script! It might be a bit faster as there is no if-then-else....

                                  #!/bin/bash
                                  #this is the GPIO pin connected to the lead on switch labeled OUT
                                  GPIOpin1=23
                                  #this is the GPIO pin connected to the lead on switch labeled IN
                                  GPIOpin2=24
                                  echo "$GPIOpin1" > /sys/class/gpio/export
                                  echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
                                  echo "$GPIOpin2" > /sys/class/gpio/export
                                  echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
                                  echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
                                  power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
                                  until [ $power = 1 ]; do
                                  power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
                                  sleep 1
                                  done
                                  [ $power = 1 ] && echo "Shutdown now!" && poweroff
                                  C 1 Reply Last reply 14 Sept 2017, 20:20 Reply Quote 0
                                  • C
                                    caver01 @cyperghost
                                    last edited by 14 Sept 2017, 20:20

                                    @cyperghost
                                    Nice.

                                    I used to use a python script that did edge detection. I was led to believe that keeping a python script active in the background would be even less of a CPU burden than a polling bash script. But I changed to the bash script you helped build when I saw the better commands. It would be nice to convert it to python.

                                    My 4-player cocktail style cabinet built as a custom "roadcase"

                                    C 1 Reply Last reply 14 Sept 2017, 20:26 Reply Quote 0
                                    • C
                                      cyperghost @caver01
                                      last edited by 14 Sept 2017, 20:26

                                      @caver01 can you post python code please?
                                      I think python is the better choice - if you enable IRQ mode, then it's the fastest alternative ;)
                                      But the old bash script looked a bit weird so I made it a bit cleaner looking

                                      C 1 Reply Last reply 14 Sept 2017, 20:30 Reply Quote 0
                                      • C
                                        caver01 @cyperghost
                                        last edited by 14 Sept 2017, 20:30

                                        @cyperghost I will post it later when I am back to my Pi.

                                        My 4-player cocktail style cabinet built as a custom "roadcase"

                                        1 Reply Last reply Reply Quote 0
                                        • C
                                          cyperghost
                                          last edited by cyperghost 15 Sept 2017, 13:41

                                          @caver01 I will be online in a few hours again. At work I asked a colleague (circuit designer) how this issue can be solved. It's possible to switch the event just via a transistor - but I forget which type ... I think N-type, but you need some resistors (at lease one at base) and best a diode (for current switchbacks) the make sure switch behaviour.

                                          On the other hand he said, that the optical-mosfet is also a nice method to trigger that and it's really fail safe as the circuits are isolated.

                                          Then I asked the method with the reset trigger... Clear answer: NO! A reset is a reset as you don't know what there really happens. It can be named as "emergency exit" if the µc is trapped but never should be used as regular switch.

                                          C 1 Reply Last reply 15 Sept 2017, 16:37 Reply Quote 0
                                          42 out of 72
                                          • First post
                                            42/72
                                            Last post

                                          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.

                                            This community forum collects and processes your personal information.
                                            consent.not_received