Hello Guest it is December 14, 2019, 01:11:12 PM

Author Topic: Re-routing input to output in Mach??  (Read 3263 times)

0 Members and 1 Guest are viewing this topic.

Re-routing input to output in Mach??
« 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

Offline TPS

*
  •  1,411 1,411
    • View Profile
Re: Re-routing input to output in Mach??
« Reply #1 on: February 26, 2015, 09:37:42 AM »
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
« Last Edit: February 26, 2015, 09:40:46 AM by TPS »
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Re-routing input to output in Mach??
« Reply #2 on: February 27, 2015, 05:54:57 AM »
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

Offline TPS

*
  •  1,411 1,411
    • View Profile
Re: Re-routing input to output in Mach??
« Reply #3 on: February 27, 2015, 07:37:07 AM »
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
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Re-routing input to output in Mach??
« Reply #4 on: February 27, 2015, 08:45:08 AM »
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
Re: Re-routing input to output in Mach??
« Reply #5 on: March 04, 2015, 05:17:52 PM »
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?
Code: [Select]
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

Offline TPS

*
  •  1,411 1,411
    • View Profile
Re: Re-routing input to output in Mach??
« Reply #6 on: March 05, 2015, 02:36:29 AM »
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
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Re-routing input to output in Mach??
« Reply #7 on: March 05, 2015, 11:37:02 AM »
It works!

Danke Schön Thomas!

Cheers!
Juha