One of the aspects of my CNC that I’m liking is the embedded Raspberry Pi that is powered directly off of the CNC’s 24VDC power supply. When the CNC is powered on, the Raspberry Pi comes on. When the CNC is powered off, the Raspberry Pi goes off.
Except, of course, Linux systems don’t like to have the power yanked out from under them repeatedly, and SD cards tend to like it even less. Also, Raspberry Pis don’t like 24 VDC power. (From reading about people’s problems with micro USB power supplies, sometimes I wonder if they like any power.)
To deal with both of these problems, I bought an Andino X1, which is a Rasbperry Pi in a DIN-mountable industrial enclosure with a 24V power supply and a handful of 24V-compatible inputs. I also bought an Andino UPS, which is a tiny supercap UPS that is designed to power the Andino X1 for a minute or two. The UPS is wired into the CNC’s power, and the X1 is wired into the UPS. When power goes out for more than 30 seconds or so, the UPS trips a “power fail” relay, and if everything’s wired up right it’s possible to get the X1 to shut down cleanly before the power actually goes away.
Andino has released a ton of docs for their boards, including the firmware for the UPS, but they didn’t actually provide a shutdown daemon for the X1. So I had to write one myself. As of this afternoon, it’s now available on Github. It will quite likely work with Andino’s other boards as well, but I don’t have any to test. It’s not particularly complicated, and it has no configuration settings. When the UPS signals power failure, it shuts the system down. That’s it.