Hello Guest it is March 29, 2024, 09:43:37 AM

Author Topic: Activate custom output pin via machine enable button  (Read 1004 times)

0 Members and 1 Guest are viewing this topic.

Activate custom output pin via machine enable button
« on: November 28, 2019, 10:24:38 PM »
Hi everyone, first post.

I am running Mach 4 with ethernet smooth stepper.
Basically, I want to change the colors of a LCD strip based on the machine status (motors enabled, cycle started, etc.)

In my ESS configuration, I have set output 49 to port3 pin 9
I managed to create a button that pulls the pin high when I press it.

What I want is for it to pull high when I press the "Enable" button (the one that enables machine controls), and pull it low when I press disable

same for spindle start and cycle start


where can I find the script that this button calls
what lines do I need to add

So far I have only found scripts regarding the screen (LUA)

Thanks!
Re: Activate custom output pin via machine enable button
« Reply #1 on: November 28, 2019, 11:15:46 PM »
I think what you want is to copy the machine enable state to your output. I would just use the PMC Editor (Configure > PMC) for that.

See attached image. This will run every 10 ms and copy the machine enabled signal to your output 49.

To do this, you can do this:
1. In PMC Window, click Settings > Code generator and select LUA
2. Instruction > Insert Contact
3. Double Click newly created contact and configure:
    - Source: Core Output
    - Name: machineEnabled
    - Device: Signal
    - Object: Machine Enabled
    Accept with click on ok.
4. In PMC Window move the cursor behind your newly created contact by clicking there
5. Instruction > Insert Coil
6. Double Click newly created coil and configure:
    - Source: Core Output
    - Name: output49
    - Device: Signal
    - Object: Output #49
    Accept with click on ok.
7. Click File save and save the pmc to C:\Mach4Hobby\Pmc
8. Click Generate and save the lua script there too

Then do what is described in this video at 4:47 to enable the PMC script:

https://youtu.be/jVhH9qyjjf0?t=287

It should work then. Add in PMC another rung for cycle start and your other output. Dont forget to hit Generate again.


« Last Edit: November 28, 2019, 11:30:20 PM by brandonb »
Re: Activate custom output pin via machine enable button
« Reply #2 on: November 28, 2019, 11:41:54 PM »
You could also just use the Output Mapping of Machine Enabled directly to your Port 3 / Pin 9. This would work out of the box but would only work if you do not already got a pin mapping configured there.

To do this just click Configure > Control and select the tab "Output Signals". Scroll down until you find "Machine Enabled" signal and configure it.

Mach4 has many of these prebuild signals that one should use.
Re: Activate custom output pin via machine enable button
« Reply #3 on: November 29, 2019, 12:01:40 AM »
Setting it from the control--> output works like a charm.

But, I get this error when trying the PMC way.
It works just fine in the live simulation...

« Last Edit: November 29, 2019, 12:16:19 AM by SIAB Studio »
Re: Activate custom output pin via machine enable button
« Reply #4 on: November 29, 2019, 12:43:15 AM »
Went to said line that the error code stipulated. Somehow i figured my problem.

I had saved my MPC as LED control. Didn't like the space there. Saved it again to LEDcontrol. Compiled, boom. Works.

Thanks to everyone!