591,536 active members*
5,194 visitors online*
Register for free
Login
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2021
    Posts
    33

    Physical button to toggle "Enabe" on and off

    Hi

    I've built a remote pendant with "Cycle Start", "Feed Hold", "Stop", "Disable" and "E Stop" physical buttons all working via entries in the "Signal Library" but I'd like to make the "Disable" a toggle for "Enable/Disable".

    I've tried a number of option but cannot get it working. I can get the first press of the button to "Enable" and the "Disable" always works but on subsequent presses of the button the "Enable" is only active whilst I hold the button down.

    Here are the "Signal Library" entries I've got going. (without anything for the "Enable" included)

    [mc.ISIG_INPUT1] = function (state) -- Cycle Start external button
    local inst = mc.mcGetInstance()
    if (state == 1) then
    CycleStart(inst)
    end
    end,

    [mc.ISIG_INPUT2] = function (state) -- Feed Hold external button
    local inst = mc.mcGetInstance()
    if (state == 1) then
    mc.mcCntlFeedHold(inst)
    end
    end,

    [mc.ISIG_INPUT3] = function (state) -- STOP external button
    local inst = mc.mcGetInstance()
    if (state == 1) then
    CycleStop(inst)
    end
    end,

    [mc.ISIG_INPUT4] = function (state) -- Disable external button
    local inst = mc.mcGetInstance()
    if (state == 1) then
    mc.mcCntlEnable(inst, 0) -- Disable
    end
    end,

    Hoping someone can point me in the correct direction.

    Thanks
    Phil

  2. #2
    Join Date
    Nov 2013
    Posts
    4827

    Re: Physical button to toggle "Enabe" on and off

    Hi,
    you are misunderstanding the role of an input signal in Mach4.

    In particular Mach4 monitors ALL defined signals and executes the SignalLib script if anyone of them change state. Thus if you have a physical button and is NO,
    when you press it the signal script will run because the signal has changed from Low to High. When you release the button the script will run again because the signal has changed from High to Low.
    The functionality you program into the SigLib script must accommodate both signal transitions.

    As it turns out I'm not at all sure that a SigLib entry is the best way to handle a toggle switch.

    What I would do in instantiate a toggle button on screen, and then attach a input signal to it. This has the effect that every time you press the physical button its the same as if you had pressed the onscreen toggle button.

    See the attached pic. It is the Screen Editor and the properties displayed are the Enable/Disable button.......just a toggle button screen element. Note how you can assign an Input signal to it. Then any time the input signal
    triggers (ie the button is pressed) the screen button will toggle. You can assign one of many actions to the button, be it an enable/disable or whatever.

    This means that do don't even need an entry in the SigLib table for the input. Groovy or what??

    Craig

  3. #3
    Join Date
    Aug 2021
    Posts
    33

    Re: Physical button to toggle "Enabe" on and off

    Hi Craig
    OK, I understand and thanks for the tip.
    That looks exactly what I want.
    A day doesn't go by where I learn something new and powerful about Mach4.

    Again, many thanks for the assistance.
    Cheers
    Phil

  4. #4
    Join Date
    Aug 2021
    Posts
    33

    Re: Physical button to toggle "Enabe" on and off

    Hi again Craig

    I've implemented the solution as suggested but still have the same issue. On trying to "Disable" after using the button to "Enable" it just toggles whilst the button is pressed.
    Attached are screen shots of that I've done.

    First is the screen editor and editing the "Enable" screen button.
    Second is that I've removed the code from the library
    Third is the Pin assignments in ESS
    Fourth is the Input in ESS

    What have I got wrong??

    Cheers
    Phil
    Attached Thumbnails Attached Thumbnails Snap2.jpg   Snap3.jpg   Snap4.jpg   Snap5.jpg  


  5. #5
    Join Date
    Nov 2013
    Posts
    4827

    Re: Physical button to toggle "Enabe" on and off

    Hi,
    not sure, but think the standard Mach4 Enable/Disable button is NOT a toggle button.

    Follow my first suggestion and make a NEW toggle button, as per the pic attached. It need not actually do anything yet....all you want to do is learn to control the on-screen button
    using a remote physical button. Once you've worked out that....then actually get it to do something. You may also discover what it is about the regular Enable/Disable button that
    differs.

    Note that I put a new toggle button on screen and that it auto-generated a software entry (tog(28)) in the file tree. Note however the Enable/Disable button is different...whether that is just a name
    or whether it is another type of button I don't know.

    Craig
    Attached Thumbnails Attached Thumbnails AuxToggleButton.jpg  

  6. #6
    Join Date
    Aug 2021
    Posts
    33

    Re: Physical button to toggle "Enabe" on and off

    OK
    Shall do.
    Cheers
    Phil

Similar Threads

  1. HELP NEEDED Servos will not turn on without pressing "Reset Overtravel" button
    By KaptinAmerika in forum SERVICE FOR CNC-MACHINES
    Replies: 2
    Last Post: 12-08-2021, 12:09 AM
  2. new K40 chinese laser only fires if I press "test" button
    By BlueLaser in forum Laser Engraving / Cutting Machine General Topics
    Replies: 5
    Last Post: 04-30-2021, 10:11 AM
  3. Replies: 2
    Last Post: 10-18-2019, 12:12 PM
  4. Controls locks when I Push the "list Prog" button
    By Mikenman in forum Haas Mills
    Replies: 13
    Last Post: 04-13-2015, 06:32 PM
  5. X Axis "Goes Off Pattern", "Awry", "Skewed", "Travels"
    By DaDaDaddio in forum Laser Engraving / Cutting Machine General Topics
    Replies: 1
    Last Post: 05-06-2013, 09:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •