Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: justjuha on February 26, 2015, 06:35:16 AM
-
Hello!
A background to my question lies on an automatic tool changer in my small milling machine project.
I managed to build a macro (thruth is that I really do not know how to write these in VB, so I had no option but to copy&edit it) that handles the fuction. It e.g. activates an output (output #1 which further employs mag. relay) as requested.
The question is, how to activate the same output by activating a certain input? In my case the input signal is going to be emulated. I want to release tool once I hit e.g. "T" on a PC keyboard. This feature would be needed in a simple manual tool change but also in case when I need to use more tools than I have in a tool magazine (all 3!). Idea is that the machine waits till the tool gets changed and then continues work. I have not figure out yet how to do this in macro, so lets's see... but anyway manual release is needed at this point. Actually it would be nice if the output could be toggled.
Briefly, how to reroute inputs (even emulated) to outputs and how to get this in a toggle mode?
I'm using CSMIO/IP-M controller, but I think it is not relevant in order to configure Mach to reroute IOs
Thanks,
Juha
-
Hello Juha,
i would do it with a Messagebox in the Makro like this:
Sub Main()
'ask Operator to enable output
Response = MsGBox ("Do you realy want to enable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
ActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
'ask Operator to disable output
Response = MsGBox ("Do you realy want to disable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
DeActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
Ende:
End Sub
not test.
Regards Thomas
-
Thomas,
I just cannot figure out how to call this macro in operation.
Lets say, I want to activate output #3 when I press T key (ascii code 84), how does the macro created know that now it is my time to operate? And how to name the macro that Mach can call it in operation?
As you can see, I'm really out as the snowman with this macro stuff...
Mit FG,
Juha
-
Hello Juha,
i also dont know how to start a macro if you press the t key.
my thinking was to integrate my sample into the M6 macro.
Thomas
-
Create a Screen User Button and assign it a HOTKEY {Alt,T} then place your macro inside the button . When needed press the hotkey. DO NOT do a direct {T} hotkey or ELSE every time you press the T the macro will run.
Just a thought, (:-) TP
-
Thomas, your macro seems to work. However, being a nitpicker, there is one thing...
Sub Main()
'ask Operator to enable output
Response = MsGBox ("Do you realy want to enable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
ActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
'ask Operator to disable output
Response = MsGBox ("Do you realy want to disable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
DeActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
Ende:
End Sub
If you answer to the first question (do you want to enable output1) yes, the output is activated.
Then if you answer no to the 2nd question (do you want to disable), the dialog box disappears and output remains active. So far so good.
But then if I finally want to disable output and I press the button created for the output control, I get the first message again and it asks to enable even the output is already enabled.
So how to modify macro that it jump to the second question right away if output is already activated when you hit the button?
Sub Main()
[color=red]If OUTPUT1 =Active then goto dude[/color]
'ask Operator to enable output
Response = MsGBox ("Do you realy want to enable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
ActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
[color=red]dude[/color]
'ask Operator to disable output
Response = MsGBox ("Do you realy want to disable Output 1?" , 4)
'Yes has been pressed
If Response = 6 then
DeActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
Ende:
End Sub
How to code what I've tried to explain in red text?
Ok, it seems that the coloring does not work in the code section, but you can see what I am explainin there in between color brackets [ ]
Cheers,
Juha
-
Hello Juha,
i think this should work:
Sub Main()
'check status of OUTPUT1
If getoemled(852) = true Then GoTo dude
'ask Operator to enable output
Response = MsgBox ("Do you realy want to enable Output 1?" , 4)
'Yes has been pressed
If Response = 6 Then
ActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
dude:
'ask Operator to disable output
Response = MsgBox ("Do you realy want to disable Output 1?" , 4)
'Yes has been pressed
If Response = 6 Then
DeActivateSignal(OUTPUT1)
'Abort has been pressed
Else
GoTo Ende
End If
Ende:
End Sub
Thomas
-
It works!
Danke Schön Thomas!
Cheers!
Juha