M1xx: Controlling Relays (solenoids) from within axis MDI

More
06 Aug 2025 14:44 #332967 by seuchato
Hi all
I was looking for a way to control my vacuum table's vacuum pump from within axis. After reading the manual, searching linuxcnc's forums, I realised others were probably struggling with similar tasks (myst, dust extraction, ...), too. I could not find a proof cooked recipe. Below, you'll find what I am ready to go with. It is a proof of concept at the time. However, and since I use same/similar components the same/similar way in home automation, I am positive, it works in the real harsh world. Teaser wanted?
 
The KDialog message box is being called by M100, this reads the relays statii and displays as shown

So: let's go, just a remark: the editor seems to be disfunct, so I use my own marking:
Ingredients:
=====================================================
* github.com/ondrej1024/crelay
* a crelay compatible USB relay controller card, I used this one: 
* some time
Setting stuff up:
=====================================================
* follow the installation intructions of ondrej, should you fail (like me) at the first step (git clone git://github.com/signal11/hidapi.git), do this instead:
git clone github.com/signal11/hidapi.git
* If you'd like to have access to your relays over LAN. you can set it up as follows:cat /etc/crelay.conf  which crelay
 /usr/local/bin/crelay
sudo echo "user ALL=(ALL) NOPASSWD:/path/to/other/comands, /usr/local/bin/crelay" > user 
Replace "user" with the very username you run linuxcnc, check itcrelay 1
crelay 1 is on

That was a success, now get familiar with crelay:
crelay -i

Detected relay cards:
                                        #
#1    Conrad USB 4-channel relay card (serial 00633CF4) 
crelay 1 on
crelay 1
crelay 1 is on

I guess there is no comment needed, ondrej's work is just perfect, isn't it?
So we can set relays from command line, as user "user" (cnc in my case) and read their status. Howto do it from within g-code?

M1xx comes handy:

=====================================================

Place a script similar to attached M100 into the directory specified in the .ini file's [DISPLAY] section under PROGRAM_PREFIX = /home/cnc/linuxcnc/configs/cnc0/macros

My path above needs to be changed to your definition.
Maybe, there is some rebooting and logging in/out/in required. I did not make notes on this.

Things to consider:

=====================================================
This approach is not for real time requiring tasks. However, I think, for these tasks:
* clamping stock via vacuum
* starting dust extraction
* and mybe even myst
real time is not required


Hope that helps someone else, too
greez
chris



 
Attachments:

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

More
06 Aug 2025 22:36 #332975 by langdons
A solenoid is just a coil.

A relay is a coil+switch.
The following user(s) said Thank You: seuchato

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

More
06 Aug 2025 22:38 #332976 by langdons
On a parallel port system a 5V relay + a liitle flyback diode should be enough.

1N4148 diodes are cheap and work great to protect the breakout board.
The following user(s) said Thank You: seuchato

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

More
07 Aug 2025 15:09 #333004 by seuchato
langdons
Thx for you pointing this out and your hint on 5V relay.
I do have a parport based router. All pins are used, and still I want my vacuum clamping, dust extraction, myst (maybe) etc. to be operable from within axis (in my case).

greez
chris

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

More
08 Aug 2025 23:01 #333074 by langdons
I see.

What are pins 8 and 9 used for?

(Just wondering)

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

More
08 Aug 2025 23:19 #333078 by langdons
A parallel port has 12 output pins, that's a lot to work with.

But in case more than 12 outputs are needed, this method is great for non-latency-sensitive stuff.

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

More
08 Aug 2025 23:54 #333083 by tommylight

I was looking for a way to control my vacuum table's vacuum pump from within axis.

To late, but:
Axis (and probably other GUI's) already have built in control for Mist and Flood so you could have just used those as that would also make it possible to use the M7/M8/M9 codes to control them directly, more info here
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m7-m8-m9
For more outputs/stuff, you would have to go with what you did, and there are probably many ways of doing it, and you can use PyVCP panel to show info about it at all times:
linuxcnc.org/docs/html/gui/pyvcp.html
I use PyVCP panels a lot with Axis GUI, a lot, even for showing all Mesa IO and everything else, on industrial machines. :)
forum.linuxcnc.org/30-cnc-machines/31792...ofit?start=100#88523
See the right side, all is added as PyVCP panels.
P.S.
I was just searching for a retrofit i did to post the link here, bumped into my video from youtube posted by some russian company on rutube !!! And they wonder why the whole world hates them!

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

Time to create page: 0.099 seconds
Powered by Kunena Forum