Hello Guest it is December 15, 2019, 07:24:33 PM

Author Topic: ATC help  (Read 173 times)

0 Members and 1 Guest are viewing this topic.

ATC help
« on: March 12, 2019, 05:50:54 AM »
I am working on a tool change script  my problems are
I need to delay or wait till a input comes on and I do not know how to do that I think I can read the input and can certainly turn on and of the outputs 
But cant figure out how to create a loop while waiting for a input to happen after I give a output command
Regards Ray

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: ATC help
« Reply #1 on: March 12, 2019, 08:25:28 AM »
Check out the mcSignalWait API call in the Mach4CoreAPI.chm help file.
;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: ATC help
« Reply #2 on: March 12, 2019, 06:39:08 PM »
Yup, mcSignalWait is it! 
If I remember, I'll post some of my ATC code tomorrow. 
Anytime I use this call, I always check the rc.
For example, the ATC I just finished working on is all pneumatic, if the cylinder takes to long to extend or retract, I E Stop the machine, leave an error message, and return to the end of the Macro. 
Again, I'll try and remember to post some code tomorrow.
Chad Byrd
Re: ATC help
« Reply #3 on: March 12, 2019, 06:54:58 PM »
Thanks for that I found the  Mach4CoreAPI.chm help file  that is what I need and the wait command will be perfect for what I want to do
Sorry for being such  a amateur I just need pointing in the right direction once in a while thanks again but now having the help files and knowing where they are located will help heaps
Regards Ray
Re: ATC help
« Reply #4 on: March 12, 2019, 06:59:08 PM »
Yup, mcSignalWait is it! 
If I remember, I'll post some of my ATC code tomorrow. 
Anytime I use this call, I always check the rc.
For example, the ATC I just finished working on is all pneumatic, if the cylinder takes to long to extend or retract, I E Stop the machine, leave an error message, and return to the end of the Macro. 
Again, I'll try and remember to post some code tomorrow.
that would be great mine is also air operated in part and will do as you suggest I had not thought of a E-Stop but this would be good if the air supply etc stopped for some reason or other problems as well
thanks
Re: ATC help
« Reply #5 on: March 12, 2019, 07:49:10 PM »
Yeah, for sure.   It can wait indefinitely, or you can set it tot wait for a certain amount of time before it continues.   When it continues on with the macro, you check the rc to see if it completed properly or if it timed out.  I have the code on a jump drive now, I'll post it when I get home.
« Last Edit: March 12, 2019, 07:51:08 PM by Cbyrdtopper »
Chad Byrd
Re: ATC help
« Reply #6 on: March 12, 2019, 08:07:38 PM »
Here it is.  Two parts of my m6 macro. 
I get the handle of my outputs in the beginning of the macro; but here is a rundown of what is going on.

--Move the POT down.
mc.mcSignalSetState(POTUp, 0)
mc.mcSignalSetState(POTDown, 1)
rc = mc.mcSignalWait(inst, mc.ISIG_INPUT24, mc.WAIT_MODE_HIGH, ErrorWaitTime)
if rc ~= 0 then
   mc.mcCntlSetLastError(inst, "There was a problem moving POT down.")
   mc.mcSignalSetState(Alarm, 1)
   return
end--POT down error check.
   
--Move the arm to the spindle.
mc.mcSignalSetState(ArmToHome, 0)
mc.mcSignalSetState(ArmToSpindle, 1)
rc = mc.mcSignalWait(inst, mc.ISIG_INPUT26, mc.WAIT_MODE_HIGH, ErrorWaitTime)
if rc ~= 0 then
   mc.mcCntlSetLastError(inst, "There was a problem moving the arm to the spindle.")
   mc.mcSignalSetState(Alarm, 1)
   return
end--Arm to spindle error check.

rc = mc.mcSignalWait(inst, mc.ISIG_INPUT#, mc.WAIT_MODE_HIGH, ErrorWaitTime) 
The "ErrorWaitTime" on the end of the call is a variable I have declared at the top of my macro.  It is read in seconds.  You can make it a variable or just put in an integer.  That is how long it waits before it continues on with the macro.  If it is left at 0 then it will wait indefinitely.
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: ATC help
« Reply #7 on: March 12, 2019, 08:33:56 PM »
I usually put a helper function in my m6 script. I use it to check all return calls and then do what I want if it fails. This is what it could look like and example of using it.

Code: [Select]
function m6ErrorOut(msg)
mc.mcCntlMacroAlarm(inst, 6, msg)
end

Code: [Select]
rc = mc.mcCntlGcodeExecuteWait(inst, string.format("G1 G53 F%0.4f Z%0.4f\nG1 G53 Y%0.4f\n", changeFeedRate, zAtCar, yAtCar))
if (rc ~= 0) then
msg = mc.mcCntlGetErrorString(inst, rc) --Get the returned error string
m6ErrorOut(msg)
return
end
;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!