Hello Guest it is January 29, 2020, 09:24:06 AM

Author Topic: Help programming inputs  (Read 2513 times)

0 Members and 1 Guest are viewing this topic.

Help programming inputs
« on: January 10, 2014, 02:55:06 PM »
Hello, I'm trying to program an input into Mach3. Basically, I want to make a wait statement. Where do you go to configure the usage of OEM triggers or Inputs? Also, does Mach3 support any kind of "Wait for Input" feature? I cannot find a G-code for any kind of wait statement.

To give you a better Idea of what I'm trying to do, I want a program to run a set number of codes, send an output to an alternate program, and then halt Mach3's operation until the other program sends a signal back to Mach3 to continue operation. I understand this can be done manually with an M0 or M1 code, but I need it to automatically restart after the break.

Keep in mind: this is my first post on this forum, and I'm not sure where it goes. Keep in mind I just got this Mach3 software. I am certainly not a CNC pro either.

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Help programming inputs
« Reply #1 on: January 10, 2014, 03:15:11 PM »
In Mach go to Operator menu then VB Script Editor. When that opens you can type in the VB required then save as m101.m1s (or similar) and save it to the macro folder of the profile you are using. Then if you have m101 in your code it will do whatever is in the macro you just wrote.

Now I am not great at VB but something like the following should work fine.

Do
ActivateSignal(OutPut1)
If IsActive (Input1) Then Exit Do
Loop
Sleep(10)



Hood
Re: Help programming inputs
« Reply #2 on: January 10, 2014, 03:19:44 PM »
Thanks for your reply, Hood.

If I understand that script correctly, then that will Deactivate my Output1 signal when my Input1 signal goes active. Is that correct?



EDIT: If I am correct in my assumption.... I want to script something like this to stop the line I'm working on now, and skip to the next line of G code. I understand you're not a VB expert, neither am I, but do you know what something like that might look like?
« Last Edit: January 10, 2014, 03:24:22 PM by DuhSavant »

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Help programming inputs
« Reply #3 on: January 10, 2014, 03:22:37 PM »
oops, missed a bit ::)

It would need to be
Do
ActivateSignal(OutPut1)
If IsActive (Input1) Then Exit Do
Loop
Sleep(10)
DeActivateSignal (OutPut1)

Hood

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Help programming inputs
« Reply #4 on: January 10, 2014, 03:25:18 PM »
BTW there is a manual that details all the VB used in Mach, its probably in the members documents area.
Hood
Re: Help programming inputs
« Reply #5 on: January 10, 2014, 03:29:38 PM »
I have read portions of the Programmer reference manual, and did not see any kind of wait statement in there.

Now, as far as M101 code in my program. Is that in the top of my program with my general declarations?

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Help programming inputs
« Reply #6 on: January 10, 2014, 03:31:16 PM »
No you put it where you want the macro to be in the code, similar way as you would put a M1..
Hood
Re: Help programming inputs
« Reply #7 on: January 10, 2014, 03:39:14 PM »
I'm sorry for all the questions I'm throwing at you.

So basically, I just used VB to create an M-code?
ALSO: I just tried to implement that code to see if it works and when I ran the code, it skipped to the M101, activated the Output1 signal and sat there. It did not run any other lines of code.

I can show you the code I'm using right now. It's a very simple code.


Code:
G20 G17 G91 F90
G0 z0.00

M98 P1234 L2

G90
G0 x0.00
M30

O1234
G1 X10.000
M4
M3  (These do not actually activate the spindle, so don't worry. I just output them to another source, and this part of the code runs fine)
(M101 would have taken the place of the M3, but again, did not run when I put it there)
G1 Y10.000
M5
M99
%
« Last Edit: January 10, 2014, 03:42:28 PM by DuhSavant »

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Help programming inputs
« Reply #8 on: January 10, 2014, 03:57:26 PM »
It would just sit there looping until the input was seen then the rest of the code should run.
Never tried it from a sub but should work I would think.
Hood