Hello Guest it is March 28, 2024, 07:01:40 PM

Author Topic: Mach 4 - Code for Holding Motion Until THC Sends a Signal  (Read 7471 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach 4 - Code for Holding Motion Until THC Sends a Signal
« Reply #10 on: June 27, 2016, 01:22:43 PM »
The external THC handles all Z motion, and lighting the torch.  All you need in M4 is an output to tell the THC to initiate the cut.  After the THC does it's thing and lights the torch, it sends a signal to M4 to move.  At the end of the cut, M4 needs to signal the THC to end the cut cycle.  THC will shut off the torch and retract to safe Z.  The THC then sends a signal to M4 to continue to the next cut...and the whole thing repeats.

Basically, you need a M code that triggers an output then loops while waiting for an input to go active.  I'd put a time limit on the loop so it the THC somehow fails, the M code will exit rather than locking up M4.  The output is to initiate the cut sequence and the input is the signal from the THC that it's OK to move.

At the end of the cut, either fire another output to end the cut sequence or just turn off the output you turned on to start the sequence.  Depends on how the THC handles those signals. After the THC turns off the torch and retracts, it should signal M4 to move to the next part.  To do this, you would use another loop in the "end sequence" M code waiting for that signal.

Re: Mach 4 - Code for Holding Motion Until THC Sends a Signal
« Reply #11 on: June 27, 2016, 02:15:56 PM »
Thanks rrc, that describes how I would want to do this in an ideal situation.  But do M-Codes have access to I/O signals by themselves?  Also, what would the syntax be for a looping process to monitor when the signal actually goes off.  I believe I know how to script an initial check, and I think I saw an example of a timer, but not a loop itself.  Sometimes the Lua syntax can be confusing for me still.

Anyway, finally have some time to be at the machine to test all of these ideas.  I'll keep progress posted here.  Thanks much.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Mach 4 - Code for Holding Motion Until THC Sends a Signal
« Reply #12 on: June 27, 2016, 03:00:15 PM »
The pre-releases mentioned here http://www.machsupport.com/forum/index.php/topic,27039.msg227697.html#msg227697 uses a coroutine in the ref all home script. You will want too look at the ref all home button script, screen load script and the PLC script. This may be a way to do what you want and avoid a loop.

You may also be able to use a signal script.

I would look at some of the scripts that come with the defaults to see how to do lots of things.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Mach 4 - Code for Holding Motion Until THC Sends a Signal
« Reply #13 on: June 27, 2016, 04:33:51 PM »
Update for anyone interested.

 - None of my coding attempts worked to code the actual input signal.  Either I am just that bad at code, it was in the wrong file / position, or it just plain didn't work.

 - Bob at pmdx's solution with the spindle works very well.  However, I had to enable reverse in the spindle setup screen in Mach, and I had to make sure Const. Surface was selected in the General tab, as opposed to Const. RPM.  I have no idea why, but doing those things actually made it work well.  Thanks very much Bob.  Huge weight lifted off my brain.

Just to elaborate further for future reference.  I have to set the torch to fire during the height sensing process due to a very slight delay from when the THC commands motion versus when the signal is sent for motion.  This I believe is a THC/plasma machine issue that I think I can solve.  If not, then I can add a half second dwell after M03 to fix it so I can save consumables a bit.

Also, very occasionally, Mach will get hung up on the M05 command.  Its inconsistent, so I think its just the demo version of Mach messing with functions.  Luckily, I can finally resolve that issue tomorrow.


Chaotic - I'll check out that information next to see what its all about, thanks for the info.  I did try using a signal script earlier, but it was either in the wrong place or my code is just bad.