231
Mach4 General Discussion / Re: adding a simple relay
« on: February 24, 2023, 03:58:07 PM »
Hi,
there are a number of approaches to doing that, and which one you choose will depend on what conditions you want to apply.
For instance, you may want a pump to turn on by a physical button, or an on-screen button, but ONLY while the spindle is operating say.
This would be a good example of using Machs programming to introduce logic.
Lets start with just the simplest of the solutions to turn a relay on or off. This would be a toggle button on screen.
I have attached a pic of a toggle button. Note I just put it on the FileOps tab simply for the sake of room, but you can put it anywhere you want or need.
Note that you have access to all the properties of the button, things like its size and location, its text, both button Up and button Down, colour etc but most importantly
look near the lower end of the properties list and you'll see that I have assigned Output#20 to the button from the drop down list of Machs available and defined
output signals.
Note that many of the properties are just so you can arrange the button on the screen to look and feel right with your control. The assignment of a matching output signal
is the ONLY thing thus far that means the visual representation of the button actually 'do anything' Anyway the upshot now is that every time you operate the button Output#20
will change state. To turn your relay on and off requires that you connect Output#20 via your motion control through the breakout board to the relay.
I use an ESS and I'm going to picture how this is done with an ESS.
In the ESS plugin on the PinsConfig tab I have assigned an ESS output, Port1, Pin9 and given it an alias 'MyNewRelay'. In the same ESS plugin I have
now assigned and enabled Output#20 from the drop down menu to my newly configured pin 'MyNewRelay'.
Now whenever Output#20 changes state, which reflects the on-screen toggle button, the Port1Pin9 of the ESS will also change state, which will of course be connected to your
BoB and that BoB output will turn on or off the realy, or beer pump or whatever.
Craig
there are a number of approaches to doing that, and which one you choose will depend on what conditions you want to apply.
For instance, you may want a pump to turn on by a physical button, or an on-screen button, but ONLY while the spindle is operating say.
This would be a good example of using Machs programming to introduce logic.
Lets start with just the simplest of the solutions to turn a relay on or off. This would be a toggle button on screen.
I have attached a pic of a toggle button. Note I just put it on the FileOps tab simply for the sake of room, but you can put it anywhere you want or need.
Note that you have access to all the properties of the button, things like its size and location, its text, both button Up and button Down, colour etc but most importantly
look near the lower end of the properties list and you'll see that I have assigned Output#20 to the button from the drop down list of Machs available and defined
output signals.
Note that many of the properties are just so you can arrange the button on the screen to look and feel right with your control. The assignment of a matching output signal
is the ONLY thing thus far that means the visual representation of the button actually 'do anything' Anyway the upshot now is that every time you operate the button Output#20
will change state. To turn your relay on and off requires that you connect Output#20 via your motion control through the breakout board to the relay.
I use an ESS and I'm going to picture how this is done with an ESS.
In the ESS plugin on the PinsConfig tab I have assigned an ESS output, Port1, Pin9 and given it an alias 'MyNewRelay'. In the same ESS plugin I have
now assigned and enabled Output#20 from the drop down menu to my newly configured pin 'MyNewRelay'.
Now whenever Output#20 changes state, which reflects the on-screen toggle button, the Port1Pin9 of the ESS will also change state, which will of course be connected to your
BoB and that BoB output will turn on or off the realy, or beer pump or whatever.
Craig