Hello Guest it is March 28, 2024, 06:52:19 PM

Author Topic: Variable in PLC script and m6 toolchange  (Read 930 times)

0 Members and 1 Guest are viewing this topic.

Variable in PLC script and m6 toolchange
« on: September 05, 2019, 10:24:44 AM »
Dear people,

I want to use a variable in my m6 toolchange which tells my plc script to turn off a relay. I made a variable and tried to use this in the plc script but is does not seem to work.

The thing I want to achieve is: I programmed in my plc script that when tool 11 is selected it lowers the right spindle, with a relay attached to a pneumatic cilinder, but I want to make a statement that when a m6 toolchange is activated that it can't do that. So I wanted to make a variable ''Change'' which will be set 1 when the tool change is activated and set 0 when it is deactivated.

The problem now is that it seems that I can't use variables from m6 in the plc script?

Could someone help me please?
Thanks in advance.

Kind regards,
Jelle

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Variable in PLC script and m6 toolchange
« Reply #1 on: September 05, 2019, 01:29:14 PM »
According to the API help file there is an OSIG_TOOL_CHANGE signal. Have you tried looking at it?
;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!

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Variable in PLC script and m6 toolchange
« Reply #2 on: September 05, 2019, 01:36:26 PM »
Jelle,

What are you referring too as a variable?
The best thing to use is a register.
They can be seen and read from all parts of Mach4

Bill

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Variable in PLC script and m6 toolchange
« Reply #3 on: September 05, 2019, 02:27:33 PM »
Jelle,

What are you referring too as a variable?
The best thing to use is a register.
They can be seen and read from all parts of Mach4

Bill

This is only true if .......... there isn't already a signal constant (to be used in an api that can be seen from all) defined. If there isn't a constant creating a register is perfectly acceptable.

Getting the state of the OSIG_TOOL_CHANGE signal returns a 0.0 if the tool change is not running and 1.0 if it is.

Code: [Select]
local inst = mc.mcGetInstance()
local rc = nil
local hSig = nil
local state = nil
hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_TOOL_CHANGE)
state, rc = mc.mcSignalGetState(hSig)
mc.mcCntlSetLastError(inst, tostring(state))

Test the above using the default Mill4 profile.

You can put the above code in a wizard. Name the wizard something like test.mcs.

Select the wizard form the list. See what you get in the status bar.

In a default profile, start the tool change (default tool change waits on user to click cycle start to finish). Be sure you call a tool that isn't the current tool because if the Current tool == Selected tool there is nothing to do. Select the wizard form the list. See what you get in the status bar.

Once the tool change is finished select the wizard form the list. See what you get in the status bar now.
« Last Edit: September 05, 2019, 02:32:37 PM by Chaoticone »
;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!