Hello Guest it is April 20, 2024, 01:28:55 AM

Author Topic: Wait for signal  (Read 8464 times)

0 Members and 1 Guest are viewing this topic.

Wait for signal
« on: January 24, 2019, 09:38:22 AM »
Hello forum.
Can you please advice me how can i write the g code so when i get a high signal in to an input to stop the g code from running and when the signal gets low the program to continue running automatic.
Thank you
Evangelos
Re: Wait for signal
« Reply #1 on: January 24, 2019, 11:57:20 AM »
Hi,
Gcode as used by mach3 or Mach4Hobby does not include conditional statements. Without a conditional you cannot write
Gcode  to do it. Mach4Industrial enacts Marco B programming which does have conditionals and could do it in Gcode alone.

What you require is a macro running in the background that causes a <feedhold> when low and a <cyclestart> when high.

I use Mach4 and would code this in Lua easily enough. I presume you could do a similar thing in Mach3 but I can't be bothered
with Cypress Enable.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Wait for signal
« Reply #2 on: January 24, 2019, 01:43:21 PM »
Thank you very much for your answer. So I need mach 4 indutrial in order to be able to get signals and manipulate the g code. I am new to all this and I don't know if there is a manual for m conditional Instructions and how to do it.
I ll do a research and if cant do it maybe ask you again. Thank you in deed.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Wait for signal
« Reply #3 on: January 24, 2019, 02:03:43 PM »
Gcode as used by mach3 or Mach4Hobby does not include conditional statements. with Cypress Enable.
Craig

i am not familar with Mach4 (LUA Scripting),

but i am pretty sure that the is (Mach4Hobby), a posibility to create a macro call M123 or what ever,
witch is waiting for a stupit Input to get "High".
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Wait for signal
« Reply #4 on: January 24, 2019, 02:45:27 PM »
Is there any manual for M commands at Mach 4? Is it possible an example? A small one from point a to point b with a wait at point b.
Thank you
Re: Wait for signal
« Reply #5 on: January 25, 2019, 01:34:50 AM »
Hi,

Quote
So I need mach 4 indutrial in order to be able to get signals and manipulate the g code
No, absolute rubbish! What I said was that Mach4 Industrial supports Gcode that includes conditional statements.
IF you had conditional statements you could code what you require in Gcode.

With Mach3 OR Mach4Hobby which don't have conditionals that approach wont work. There is however another which will work
equally well.

In Mach4 you would write a script that test the input at regular intervals ( every few milliseconds) and issues a <feedhold>
instruction if the signal is low or a <cycle start> instruction if the signal is high.

This is conceptually easy. Another variation which is more programmatically efficient is to use the SigLIb table (Signal Library).
It takes more thinking about and displays the underlying strength of Mach4.

Irrespective of the approach you adopt, you might choose the easy way first AND THEN have a go at the SigLib idea, you
will have to learn a little Lua and use the API. Are you up for it?

Look in the Mach4Hobby/Docs directory and you will find all sorts of good stuff, the API.chm, Mach4 Scripting Manual and
Mach4 Gcode programming. Note that with Mach enabled the docs directory can be displayed with the <Help Docs> button,
too easy.
Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Wait for signal
« Reply #6 on: January 25, 2019, 03:32:42 AM »
To write a script for Mach 4 though i can type it in a notepad right? I shouldn't need any lua software to write a simple script of  if - else commands etc.
Also i found somewhere that in Mach 3 within the configuration i can register OEM input pin 1 as 1000 for start cycle and OEM input pin 2 as 1002 for freehold.
Would't this work?
Re: Wait for signal
« Reply #7 on: January 25, 2019, 12:49:19 PM »
Hi,

Quote
To write a script for Mach 4 though i can type it in a notepad right? I shouldn't need any lua software to write a simple script of  if - else commands etc.

Yes you could write a script with a text editor but Zero Brane has been provided for the purpose. It has auto-complete,
context sensitive formatting, a compiler, and can debug, ie run in single step, to breakpoints etc.

You will be coding in Lua and using he API. I have this online manual open on the desktop when coding:
https://www.lua.org/manual/5.2/.

Open the Script Editor (or alternately Edit/Debug scripts). Open a new document.

I suggest that you make a temporary folder within you profile, called 'temp' say, in which to store your script,
'waitscript.mcs' say.

Using SaveAs, navigate to your profile and create a new folder 'temp'.

Open the new folder and save your script as waitscript.mcs. Its not the end of the world if you name it *********x.lua but the
debug features wont work, you'd have to rename it *********xx.mcs
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Wait for signal
« Reply #8 on: January 25, 2019, 12:52:24 PM »
Hi, cont...

You should now see your open document in Zero Brane as waitscript.mcs and see the location in the navigation tree.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Wait for signal
« Reply #9 on: January 25, 2019, 12:55:08 PM »
Thank you Craig. I ll follow your advice. I also ordered the lua programming manual today. You very been very helpful. Appreciate it.