Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: jbraddock on July 01, 2018, 04:09:04 PM

Title: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 01, 2018, 04:09:04 PM
I HAVE TRIED to activate cycle start with a script i got from joe average but we just cant get it to work, i know my input is working we have it activating the diagnostic led but cant seem to get it to activate Cycle Start when you trigger that input #1
 
Cycle Start()
[mc.ISIG_INPUT10]=function(state)
   if state==1 then
      CycleStart()
   end
end

i have put it in the left down script, the left up script i have put the left up an left down actions  to cycle start with an without the code installed in the  clicked boxs, not sure what the exact scenario is that i need to have them installed an what order needs to be on an off with the left dwn/up clicked act/srpt/ boxs,... 

im trying to get all my main screen buttons onto external buttons or either have them where they can be triggered by key strokes an use a macro keyboard to activate them, i dont care which way but this was suppose to be the easiest way to do it an its not been easy to figure out,... i have tried some of the scripts in another post similar to what im trying but those didn't work either,...so im tryn to determining if its in my inputs or in the scripts,...
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 01, 2018, 04:50:06 PM
Hi,
Quote
i have put it in the left down script, the left up script i have put the left up an left down actions
Wrong, that code needs to go in the SigLib table at the top of the screen load script.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: Fledermaus on July 01, 2018, 05:12:18 PM
jbraddock

Notice that individual table entries are separated by a comma , so be sure to include one after your code unless it is the final entry in SigLib{}.

Allan
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 01, 2018, 05:34:37 PM
Hi,
Quote
i have put it in the left down script, the left up script i have put the left up an left down actions
Wrong, that code needs to go in the SigLib table at the top of the screen load script.

Craig you posted screen shots with them circled to where they go..? or atleast thats what i understanded you were saying to put them, now your saying they dont go inside the script boxs?
if so im confused as to where this sig lib is?
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 01, 2018, 05:44:24 PM
Hi,
I am at work and so can't show you at the moment.

Open the screenload script and near the very top you'll see:

SigLib{

which is the start of the signal library table. You just need to put another entry in it.
It tell Mach 'this is the signal I'm interested in....and this is what I want you to do...'

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: Fledermaus on July 01, 2018, 06:27:19 PM
Open the Screen Load script in the screen editor and find the line:

    SigLib = {

This is the beginning of the signal table. Now try inserting the following between 2 existing entries:

Code: [Select]
--AW: Set cycle start if user presses key assigned to Input0
[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then
        CycleStart()
    end
end,

--AW: Set feed hold or stop if user presses key assigned to Input1
[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then
        local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_RUNNING_GCODE)
        local codeRunning = mc.mcSignalGetState(hSig)
        if (codeRunning  == 1) then
            mc.mcCntlFeedHold(inst)
            --CycleStop()
        end
    end
end,


Use your own inputs instead of inputs 0 and 1. That's all there is to it.

Allan
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 01, 2018, 06:59:32 PM
Open the Screen Load script in the screen editor and find the line:

    SigLib = {

This is the beginning of the signal table. Now try inserting the following between 2 existing entries:

Code: [Select]
--AW: Set cycle start if user presses key assigned to Input0
[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then
        CycleStart()
    end
end,

--AW: Set feed hold or stop if user presses key assigned to Input1
[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then
        local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_RUNNING_GCODE)
        local codeRunning = mc.mcSignalGetState(hSig)
        if (codeRunning  == 1) then
            mc.mcCntlFeedHold(inst)
            --CycleStop()
        end
    end
end,


Use your own inputs instead of inputs 0 and 1. That's all there is to it.

Allan

thank you,..ive been in the wrong place all day,
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 01, 2018, 07:00:50 PM
Hi,
I am at work and so can't show you at the moment.

Open the screenload script and near the very top you'll see:

SigLib{

which is the start of the signal library table. You just need to put another entry in it.
It tell Mach 'this is the signal I'm interested in....and this is what I want you to do...'

Craig

ok
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 01, 2018, 07:14:28 PM
Hi,
the signal library takes a little bit of 'getting your head around' however when you do
you'll soon realize that this method is light years ahead of Mach3 which polls its inputs.

Further now that you have that one example under your belt you'll be able to repeat it with
all manner of variations...and so simple!

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 02, 2018, 06:13:39 PM
its not easy for me apparently,.... ive tried numerous ways an it keeps
 Saying...

 LUA  SYNTAX ERROR DURING PRE COMPILATION UNEXPECTED SYMBOL NEAR =
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 02, 2018, 06:19:22 PM
Hi,
please post the code, cut and paste so that it is exact.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 02, 2018, 06:24:07 PM
Hi,
just noticed that other examples:

if (state==1) then

ie it might be necessary to put the parenthesies around the conditional. As someone pointed out that
Lua has syntax 'that only a mother could love'.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 02, 2018, 06:26:56 PM
Hi,
just noticed that other examples:

if (state==1) then

ie it might be necessary to put the parenthesies around the conditional. As someone pointed out that
Lua has syntax 'that only a mother could love'.

Craig

finally got it it was that code you gave me was wrong, i got one off another post an its working FINALLY!!!! THANK GOD!!!

NOW TO DO ENABLE  can i do it the same way?
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 02, 2018, 06:35:26 PM
Hi,
have a look at the <Enable> button event properties in screen edit mode. If it has
a script or a function as an event, but NOT an action, then yes you can do exactly the
same thing.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 02, 2018, 07:01:15 PM
i tried just changing CyleStart to MachEnable an no go
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 02, 2018, 07:05:25 PM
Hi,
did you check that <Enable> is a function? If it is, have you called the function using the correct
syntax:

MachEnable().......note Lua is case sensitive and the parenthesies indicate to Lua that its a function
thus

MachEnable
machenable()
and
MachEnable()  are all different.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 02, 2018, 08:14:48 PM
Hi,
did you check that <Enable> is a function? If it is, have you called the function using the correct
syntax:

MachEnable().......note Lua is case sensitive and the parenthesies indicate to Lua that its a function
thus

MachEnable
machenable()
and
MachEnable()  are all different.

Craig


yeah i found some scripts an got it working THANKS!, problem now is im outa inputs an bob im using is full of outputs an not inputs,...so idk,...im looking into the Pokeys 57cnc with membrane buttons,... may go that route,... so hopefully all the scripts will work the same for that card
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 02, 2018, 08:39:33 PM
Hi,
or buy another BoB, or even two, for $23.00 each and have as many inputs as you could shake a stick at!

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: dude1 on July 03, 2018, 03:52:23 AM
you can use your keyboard num pad, I tried it a few years ago and it worked
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 03, 2018, 11:28:09 PM
What do you mean? Im still tryn to figure out how to set button functions to keyboard keys
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 03, 2018, 11:28:56 PM
Hi,
or buy another BoB, or even two, for $23.00 each and have as many inputs as you could shake a stick at!

Craig
Which bob is $23.00 that your talking abought
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: dude1 on July 03, 2018, 11:39:34 PM
https://www.automationtechnologiesinc.com/products-page/motion-controllers/c10-bidirectional-breakout/
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: dude1 on July 03, 2018, 11:40:11 PM
https://www.automationtechnologiesinc.com/products-page/motion-controllers/kl-db25-breakout-board/
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 04, 2018, 12:45:24 AM
Hi,
I meant the C10 BoB, it has a bi-directional buffer which allows pins 2-9 to be used as inputs
whereas the kl-bd25 pins 2-9 can ONLY be used as outputs.

You need more inputs and so a BoB which has bi-directional pins 2-9 is what you need.

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: joeaverage on July 04, 2018, 12:51:40 AM
Hi,
you could use the C13 at only $9.00 but it has no buffer ICs, if you have a cock-up with the wiring
you could blow the ESS. I prefer BoBs with a buffer, blowing a cheap BoB I'd live with but I'd be
p.....sed off if I blew my ESS!

Craig
Title: Re: I NEED ''Enable'' an ''Cycle Start'' scripts for activating with a ESS input
Post by: jbraddock on July 04, 2018, 11:28:44 AM
you can use your keyboard num pad, I tried it a few years ago and it worked
What do you mean, im tryn to figure out how to activate by keyboard instead of by input button,... in other words how do i make say enable work when i hit a keyboard input like spacebar or another keystroke