Working with UPS

Topics about the Hardware of Revolution Pi
mirko.comparetti
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Working with UPS

Post by mirko.comparetti »

Hello,
We need to put in place an UPS to gracefully shut down a revpi when the cabinet hosting the RevPi is shut down, and switch it back on when the cabinet is power back on.
Looking at the instructions here https://revolution.kunbus.com/tutorials ... n-connect/ I personally do not understand how to connect the UPS and how that is supposed to work.

Assuming we have the following:
  • Vcc: 24V from the main power supply unit
  • Vups: 24V from the UPS unit
As far as I understood, we need to connect Vups to the X4 to power up the RevPi and Vcc to the IN in X2; is that correct?

Now, lets assume that the wiring is taken care, lets discuss about how this is supposed to work.
  • Everything is on and running (RevPi, Vcc, Vups)
  • Vcc is removed by the power switch
  • Vups is still powered
  • RevPi detects the power failure
  • RevPi gracefully shuts down (

    Code: Select all

    shutdown --halt now
    ?)
Now the question is:
  • How to detect the power failure? Do we need a background service running at system level to check the revpi status variable and trigger the shutdown? Is there an example of this service?
  • If the RevPi is down but Vups has still some energy left, what happens if Vcc comes back? Will the unit power up again?
I'm sorry if I asked lots of (newbie) questions, and I thank you for your help and time.

Thanks
Mirko
Amar
KUNBUS
Posts: 157
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: Working with UPS

Post by Amar »

Hello Mirko,
Your assumptions are correct. Answer regarding to your questions:

First:
You can use the Vcc supply at X2 connector to monitor the power supply.
Alternatively you can also use the Relay Contact and monitor the
Statusbytes of RevPi Connect if relay is Open or Close and then perform software shutdown of RevPi Connect using some background service or directly in application.

https://revolution.kunbus.com/tutorials ... t-connect/


Second:
A hard power reset (at X4 ) will be required in order to start this device again. This means both Vups should be low for a short instance before in order to reboot the device
automatically.

Regards,
Amar
KUNBUS
mirko.comparetti
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Re: Working with UPS

Post by mirko.comparetti »

Hello Amar,
Thanks a lot for your answer... sorry for my late reply but I did not get the notification (which I forgot to enable) and didn't see your reply.
Amar wrote: 18 Dec 2020, 14:22 You can use the Vcc supply at X2 connector to monitor the power supply.
Alternatively you can also use the Relay Contact and monitor the
Statusbytes of RevPi Connect if relay is Open or Close and then perform software shutdown of RevPi Connect using some background service or directly in application.
https://revolution.kunbus.com/tutorials ... t-connect/
So as you said, we will use Vcc at IN of X2 to detect whether we still have power and then switch off the RevPi Connect accordingly.
Amar wrote: 18 Dec 2020, 14:22 A hard power reset (at X4 ) will be required in order to start this device again. This means both Vups should be low for a short instance before in order to reboot the device
automatically.
This makes it a little tricky.
The first idea that comes to my mind is to have an hardware circuit that will cut Vups after some time the RevPi Connect is off. So the idea is:
  • Connect Vups also to the relay contact
  • Use the relay contact to detect when the RevPi is off, by changing its state (i.e. as this is normally closed, we keep it open when the RevPi is on)
  • When the RevPi is off, then the relay is closed and so power will go to its terminal
  • That terminal will be used to trigger a latch SR that will control a delayed relay that, after few seconds will cut the power to the RevPi on X4
  • On the other terminal of the SR latch we will connect Vcc so that when the power comes back, the delayed relay will be activated again
Would that do the trick? Or what are you suggestions to do so?

Thanks
User avatar
dirk
KUNBUS
Posts: 1942
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Working with UPS

Post by dirk »

Hi, there is no need for an external cirquit at all see here at the end:
https://revolution.kunbus.com/tutorials ... n-connect/

So basically the UPS just reports a low battery by a digital output
So that is what you have to poll is RevPiLED, bit 6.
Use an example script from here "/home/pi/connect". It should stop triggering the watchdog reset in case the input pin gets low.

You can poll for a bit using piTest like so:

Code: Select all

pi@RevPi39627:~ $ piTest -v RevPiLED
variable name: RevPiLED
       offset: 6
       length: 8
          bit: 0
pi@RevPi39627:~ $ piTest -g 6,6
Get bit 6 at offset 6. Value 0
pi@RevPi39627:~ $ piTest -q -g 6,6
0
So you can handle it like so:

Code: Select all

pi@RevPi39627:~ $ if [ `piTest -q -g 6,6` == "0" ]; then echo "low"; else "hi"; fi;
low
mirko.comparetti
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Re: Working with UPS

Post by mirko.comparetti »

Hello Dirk,
Thanks for your reply, but I think I didn't explain myself properly. We understood how to detect when the RevPi is running on UPS power and that the system can be shutdown automatically using scripts.
dirk wrote: Hi, there is no need for an external cirquit at all see here at the end:
https://revolution.kunbus.com/tutorials ... n-connect/
The external circuit is meant to be used in case the RevPi has been shutdown, ups has still some power (and thus X4 has 24V, still) and Vcc comes back: in this case we need that the device to automatically come up and Amar mentioned that for this to happen we need to briefly bring 0V at X4 and then 24V again. This cannot be managed via software on the RevPi (as it is down) and an external circuit has to be implemented.
Amar wrote: A hard power reset (at X4 ) will be required in order to start this device again. This means both Vups should be low for a short instance before in order to reboot the device
automatically.
Thanks,
Mirko
User avatar
dirk
KUNBUS
Posts: 1942
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Working with UPS

Post by dirk »

Hi Mirko, ok now I got the point. With the Teltonika WLAN router there is the possibility to implement this function with the relays if you can access the router remotely.
User avatar
dirk
KUNBUS
Posts: 1942
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Working with UPS

Post by dirk »

Hi Mirko, we are currenty discussing alternative options here with the hardware team.
mirko.comparetti
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Re: Working with UPS

Post by mirko.comparetti »

Hello Dirk,
Thanks! We designed a wiring diagram that can handle this situation with the UPS; we tested it by simulating the UPS and soon we will receive the ups then we will test it in the final solution.

But we are open to your ideas!

Thanks,
Mirko
User avatar
dirk
KUNBUS
Posts: 1942
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Working with UPS

Post by dirk »

Hi Mirko, thank you for your reply and your ideas. So here is our idea - you can use an industrial time relais like this:
https://www.amazon.de/HSB-Industrieelek ... yddemsn-21

The set drop-out delay must be long enough for the device to have enough time to shut down.
mirko.comparetti
Posts: 36
Joined: 04 Jun 2018, 11:01
Answers: 0
Location: Lomazzo

Re: Working with UPS

Post by mirko.comparetti »

Thanks!
We tought about a solution like this, but we discarded it as it adds a constant delay time that can impact an operation like "switch off and on again"; also, using a fixed time has no guarantee that the device is actually off (theoretically).

The circuit we designed has 2 standard relays and 1 time delayed one; with that circuit we can detect a rising edge on the main power supply and, when this happens if the RevPi is actually off, it triggers the delayed relay to create a rising edge on the power supply in X4.
Post Reply