Integrating a UPS with LinuxCNC

More
27 Dec 2013 11:51 #42053 by subnoize
Hello!

After destroying a project from a brief power outage I obtained two CyberPower UPS, one for the mill and one for the computer, controller and steppers. I quickly discovered the controller had to be by itself on a UPS and the mill and computer on the other. Now I have about 22 to 25 minutes in case of power failure.

Has anyone integrated an UPS with LinuxCNC? Has anyone integrated two separate UPS to theirs? It would be nice to back the end mill out and bring everything to a position that would enable you to return to milling should the outage continue beyond usable battery life.

If anyone has examples this it would be great! Thanks!


JB

Please Log in or Create an account to join the conversation.

More
28 Dec 2013 07:28 #42085 by andypugh
I don't know if it has been done.
One solution might be a HAL component that onitors UPS status, and a fixed time after an "On UPS Power" pin goes high it toggles a a pin connected to halui.program.stop and then a second later toggles a pin connected to an MDI_COMMAND that retracts the spindle:
www.linuxcnc.org/docs/html/man/man1/halui.1.html

Depending on the interface between LinuxCNC and the UPS it might be easier to do it with a Python Userspace component, in which case the component can probably issue the quill-up as a linuxcnc.command() call.

Is the LinuxCNC machine aware of the UPS status?

Please Log in or Create an account to join the conversation.

More
28 Dec 2013 11:20 #42094 by subnoize

Is the LinuxCNC machine aware of the UPS status?


It can be. The UPS has a serial and a USB port. There is software to shut down a Linux box after doing backups and stuff. It will even integrate with httpd to pull it out of a load balancer and stuff like that so this is possible. I was hoping somebody had already done it.

My problem is I'm a Java guy. Not much good at anything other than cell phones, web servers and dorky looking glasses ;)


JB

Please Log in or Create an account to join the conversation.

More
28 Dec 2013 18:26 #42105 by andypugh

My problem is I'm a Java guy. Not much good at anything other than cell phones, web servers and dorky looking glasses


It's probably more trouble than it is worth to write a HAL interface in Java. But if you are a programmer you should be able to hack about with a working component and get something working.

Useful manual page here:
www.linuxcnc.org/docs/html/hal/halmodule.html

This is a Python component that reads USB data (it might be pendent on the HID interface though, which the UPS probably isn't)
Have a look at git.linuxcnc.org/gitweb?p=linuxcnc.git;a...cede397068fcc64c5674

"import linuxcnc" gives your Python code access to this structure, which allows you to query the state of linuxcnc and send MDI commands:
linuxcnc.org/docs/html/common/python-interface.html

it looks like you need to send
linuxcnc,command.abort
then
linuxcnc.command.mdi("G53 Z0")
The following user(s) said Thank You: subnoize

Please Log in or Create an account to join the conversation.

More
30 Dec 2013 00:18 #42161 by subnoize
Actually, it appears that the CyberPower UPS units are USB HID devices. I will have to research further and learn some new skills to get to the bottom of this.

Thanks,

JB

Please Log in or Create an account to join the conversation.

More
30 Dec 2013 07:44 #42187 by andypugh

Actually, it appears that the CyberPower UPS units are USB HID devices. I will have to research further and learn some new skills to get to the bottom of this.

In that case you can probably use hal_input to get the UPS status into HAL.
You can use that signal to stop the machine without any coding at all, and you can then probably use an MDI_command to retract the spindle.
I think you would need a timedelay component to give the abort time to act before issuing the quill-up.

So, no need for any actual code at all, unless you want to.

Please Log in or Create an account to join the conversation.

More
16 Jan 2014 14:22 #42863 by bottleworks
If you come up with something, I would be interested in your findings.

Please Log in or Create an account to join the conversation.

More
17 Jan 2014 12:06 #42903 by subnoize
It wasn't all that hard to get it to connect. Most UPS use a HID compliant driver. Looks like a mouse but what its trying to tell me is confusing. I guess the X and Y are power and time left respectively. Now, what to do with that input?

When I get that part figured out then we'll be in business!


Jb

Please Log in or Create an account to join the conversation.

More
09 Mar 2014 21:47 #44599 by Badger
You may want consider a dumb solution and monitor line power instead of UPS status. You could hook a pin up to a relay connected to the power line, then when the power drops the status of the pin would change. You could then wait for however many minutes you want and then trigger you shut down process. I have no idea how to do this but it may be a valid approach.

- Badger

Please Log in or Create an account to join the conversation.

Time to create page: 0.092 seconds
Powered by Kunena Forum