So I have an old UPS which needs new batteries, so I am going to pull it apart.
I was thinking, since getting the UPS to communicate with the duet by USB is beyond me and will be to some degree complicated, would it be possible to just connect the UPS Active red LED output to a spare pin on the duet and then monitor it. This way if the UPS unit needs to activate as the mains voltage is aberrant, the red LED comes on the printer then knows the UPS is active.
I will, of course, protect the input pin if the voltage from the LED is not suitable.
Ideally, I'd want to have RRF begin a configurable countdown (the length of which would be determined by the UPS's capability to sustain the power after a mains failure, which I would have to determine by trial and error) after which it would go to pause and store the power fail resume data before the UPS shuts down.
The safest way to connect it would be to replace the LED by the primary side of an opto isolator. Or it may work if you connect the opto isolator in series with the LED. Connect the output side of the opto isolator to a spare endstop input.
There is no facility in RRF to execute a delayed pause at present. However, you could have the input trigger a normal pause, which will create a resurrect.g file ready for use if UPS runs out of power. Or you could use an Arduino or similar to monitor the UPS output signal and send a delayed signal to the Duet.
I was thinking about that, maybe I'll just make a small board with the optocoupler, and a timer which I can set for just less than the nominal run time of the UPS, which can just trigger a pause when the timer runs out.
I was just thinking about how to get the machine to resume automatically if the power outage turns out to be brief.
Shouldn't be a problem, as thinking about it, if the power is restored before the timer triggers the endstop the ups interface circuit will shut off.
Thinking that using something like this might help. Optocoupler included and timer, just need to work out if the voltage from the LED on the UPS will be enough to switch it. If not it might be possible to get supply voltage from somewhere in the ups.
Would then supply 3.3v from duet to the output side of the relay and then to the chosen endstop pin.
On some of my UPS the led & piezo comes on during its daily test, something you might want to check as you probably don't want false alerts.
Have you considered using the serial port, if its like APC they set a pin high to show on battery and a different pin for low battery. You could hook this up to an ESP8266 and then use wifi to talk to the duet.
Sounds great but that's a bit above my digital skills. Although I do work with a much more capable engineer at Precision Piezo. That specific UPS doesn't automatically run a self test unless I specify one, but I'm hoping this system will be able to be set for 2 minutes, and any interruption in the mains, less than 2 minutes won't trigger the endstop input as the timer won't have reached the end of its countdown, and therefore won't put the printers (I have 2 or 3 that I want to connect to the UPS) into pause mode, so its essentially a non-event.
I'm not sure it has a serial port.