Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: BGelektronika on January 27, 2020, 05:26:02 AM
-
Hi,
I kindly asking anyone to help me with that macro. I need System wait function, but it doesn't work. What is right command to get it work? I could get command from input 2, or OemLed 822.
I need that macro for Lathe Bar Fedder.
If GetOemLED(821) Then
Code "G0 G54 Z110"
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1
Else
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1)
SystemWaitFor(INPUT2)
ResetOutBit(90,9)
ResetOutBit(90,6)
Sleep 100
SetOutBit(90,11)
SetUserLed(1001,0)
End If
Thank you
Best regards
Gasper
-
Looks like you are using a CSMIO
you can use GetInBit
If GetInBit(adr, bit) = False Then
Sleep(50)
End If
-
Looks like you are using a CSMIO
you can use GetInBit
If GetInBit(adr, bit) = False Then
Sleep(50)
End If
Hi,
Thank you for answer.
If I use this it will not wait for needed input signal and then continue program. It will continue if input wont be active. Or I'm I wrong?
Thank you
Best regards
Gasper
-
it will continue program if Input is true
If GetOemLED(821) Then
Code "G0 G54 Z110"
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1
Else
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1)
If GetInBit(adr, bit) = False Then
Sleep(50)
End If
ResetOutBit(90,9)
ResetOutBit(90,6)
Sleep 100
SetOutBit(90,11)
SetUserLed(1001,0)
End If
you Need to replace "adr" and "bit" by your real values.
-
it will continue program if Input is true
If GetOemLED(821) Then
Code "G0 G54 Z110"
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1
Else
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1)
If GetInBit(adr, bit) = False Then
Sleep(50)
End If
ResetOutBit(90,9)
ResetOutBit(90,6)
Sleep 100
SetOutBit(90,11)
SetUserLed(1001,0)
End If
you Need to replace "adr" and "bit" by your real values.
it will continue program if Input is true
If GetOemLED(821) Then
Code "G0 G54 Z110"
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1
Else
ResetOutBit(90,11)
SetOutBit(90,9)
SetOutBit(90,6)
SetUserLed(1001,1)
If GetInBit(adr, bit) = False Then
Sleep(50)
End If
ResetOutBit(90,9)
ResetOutBit(90,6)
Sleep 100
SetOutBit(90,11)
SetUserLed(1001,0)
End If
you Need to replace "adr" and "bit" by your real values.
Can you please check attached macro and look what is wrong in it, coz I have sytax error. And please repair, coz I believe there are errors in it, coz I'm beginner with marcos...
-
Could we also change instead 'If GetOemLed (821)' to If GetInBit(90,16) ?
Here Is attachment.
-
If GetInBit(90,16) Then 'Bar end signal
Code "G0 G54 Z110" 'Clear to make space for Bar fedder to push remnant out
ResetOutBit(90,11) 'Collet close reset
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
Code "G0 G54 Z-35" 'Position stopper at top cut position
Sleep(1000)
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep(100)
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep(2000)
Else
ResetOutBit(90,11) 'Collet close reset
Sleep(100)
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep(100)
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep(2000)
End If
-
If GetInBit(90,16) Then 'Bar end signal
Code "G0 G54 Z110" 'Clear to make space for Bar fedder to push remnant out
ResetOutBit(90,11) 'Collet close reset
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
Code "G0 G54 Z-35" 'Position stopper at top cut position
Sleep(1000)
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep(100)
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep(2000)
Else
ResetOutBit(90,11) 'Collet close reset
Sleep(100)
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
If GetInBit(90,17) = False Then 'Wait for Start signal from Bar fedder
Sleep(50)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep(100)
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep(2000)
End If
I have test it now and It does not wait for signal, it just goes forward. What I'm I doing wrong?
I really appreciate for help.
-
It is working!
It is not GetInBit(xx,xx) but GetInput(xx)
-
Well I was wrong. It still does not wait for signal, it just goes forward. How to tell him to wait for signal to be active, and then continue?
-
it is GetInBit(x,y) for sure, i have used this in my own macros.
can you see the Input Led on the fron of the Controller comming on?
-
btw i see you are using a csmio/a
there is no Input 90,16 if you are using Input16 it will be 91,0
-
btw i see you are using a csmio/a
there is no Input 90,16 if you are using Input16 it will be 91,0
You where right. Input is 91,0 for 16 and 91,1 for 17. But the problem is that, when it comes to If GetInBit(90,17) = False Then, it does not wait here till it is active. It goes further to other lines all the way to the end of macro. Can I use GetIn bit with While Not IsActive command?
Signal is coming to machine, I also have LEDS os screen to see them
-
For reference, attached is my working macro. But Instead of LEDs and inputs I would like to use CSMIO inputs directly as sometimes happens that don't detect input signal 2, even so led on CSMIO input comes on. This could end up catastrophically.
-
... But the problem is that, when it comes to If GetInBit(90,17) = False Then, it does not wait here ...
that is the Problem i tryed to explain ....GetInBit(90,17) will not work it has to be GetInBit(91,1)
-
... But the problem is that, when it comes to If GetInBit(90,17) = False Then, it does not wait here ...
that is the Problem i tryed to explain ....GetInBit(90,17) will not work it has to be GetInBit(91,1)
Yes I understand, and I test with GetInBit(91,1), but when it come to this line it doesnt stay here till this imput get active.
Is it possible that lines not in right order? I mean where line starts?
-if
-
-
- ?
Or
-
-
-
-
-?
-
can you please post the actual macro you are testing with?
and witch Input led is coming on at the Controller?
if you look on CSMIO webside for macro examples they are using also the GetInBit like me on all my three machines.
so the Problem must be somewhere else.
BTW, if you copy and paste your code into Operator -> VB Script Editor Window and use the >|| button you can step through your
code and see where it goes.
-
can you please post the actual macro you are testing with?
and witch Input led is coming on at the Controller?
if you look on CSMIO webside for macro examples they are using also the GetInBit like me on all my three machines.
so the Problem must be somewhere else.
BTW, if you copy and paste your code into Operator -> VB Script Editor Window and use the >|| button you can step through your
code and see where it goes.
Attache are two Macros. First with Input, and second with GetInBit. With input 2 is working 100% but like I said, it It happens that sometimes don't detect input 2 signal , even so led 17 on CSMIO input comes on.
When I change from While Not IsActive(input2) to If GetInBit(91,1), it is not wait on that line till it get signal from csimo /ip-s input 17, but it just go forward to other line till the end.
Thank you so much for helping me...
-
Attachments
-
Sorry my fault.
code corrected:
If GetOemLED(821) Then 'Bar end signal
Code "G0 G54 Z110"
ResetOutBit(90,11) 'Collet close reset
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
Code "G0 G54 Z-35"
Sleep 1000
If GetInBit(91,1) = 0 Then 'Wait for Start signal from Bar fedder
Sleep(100)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
Else
ResetOutBit(90,11) 'Collet close reset
sleep 100
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
End If
-
I also try to make just half of macro working, but the same all the time.
If I can get this Half macro working then I would also manage first part of it.
I write all scripts in Mach3 VBscript editor, and for that one, when I press play button, it just plays whole macro, without waiting on GetInBit for signal.
-
Sorry my fault.
code corrected:
If GetOemLED(821) Then 'Bar end signal
Code "G0 G54 Z110"
ResetOutBit(90,11) 'Collet close reset
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
Code "G0 G54 Z-35"
Sleep 1000
If GetInBit(91,1) = 0 Then 'Wait for Start signal from Bar fedder
Sleep(100)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
Else
ResetOutBit(90,11) 'Collet close reset
sleep 100
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
End If
This one Works at least in VB script editor. I'll Test it on machine in few hours and let you know result.
Thank you
-
Sorry my fault.
code corrected:
If GetOemLED(821) Then 'Bar end signal
Code "G0 G54 Z110"
ResetOutBit(90,11) 'Collet close reset
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
Code "G0 G54 Z-35"
Sleep 1000
If GetInBit(91,1) = 0 Then 'Wait for Start signal from Bar fedder
Sleep(100)
End If
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
Sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
Else
ResetOutBit(90,11) 'Collet close reset
sleep 100
SetOutBit(90,9) 'Collet Open
SetOutBit(90,6) 'Collet Open
SetUserLed(1001,1) 'Set Collet open LED ON
While Not(GetInBit(91,1)) 'Wait for Start signal from Bar fedder
Sleep(100)
Wend
ResetOutBit(90,9) 'Reset Collet Open
ResetOutBit(90,6) 'Reset Collet Open
SetOutBit(90,11) 'Collet Close
sleep 100
SetUserLed(1001,0) 'Set Collet open LED OFF
Sleep 2000
End If
This one Works at least in VB script editor. I'll Test it on machine in few hours and let you know result.
Thank you
Well, this is working, but there must be no Sleep in middle of Whille and Wend. Like this:
While Not(GetInBit(91,1))
Wend
But Unfortunately this didn't solve my problem. Still some times don't get input. Led on CSMIO controller illuminates, but looks like in program doesn't detect it. I also try different inputs, but always the same result.
It really is frustrating. Whole retrofit end up terrific, machine is working great, but without bar feeder is useless.
Do you have any clue what could be the cause of that problem?
-
do you mean macro will not wait until Input is on, or does the macro not goin Forward after Input is on?
-
Problem solved.
I was running .066 version of Mach3 and then TPS member suggested to try with .062 version. Well since then no problem. Looks like older version solve my problem.
Thank you
Best regards
Gasper