Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: BGelektronika on January 27, 2020, 05:26:02 AM

Title: System wait macro function help
Post 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
Title: Re: System wait macro function help
Post by: TPS on January 30, 2020, 11:02:11 AM
Looks like you are using a CSMIO

you can use GetInBit

Code: [Select]


If GetInBit(adr, bit) = False Then
Sleep(50)
End If

Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 05:49:20 AM
Looks like you are using a CSMIO

you can use GetInBit

Code: [Select]


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
Title: Re: System wait macro function help
Post by: TPS on January 31, 2020, 05:53:21 AM
it will continue program if Input is true

Code: [Select]
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.
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 06:27:09 AM
it will continue program if Input is true

Code: [Select]
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

Code: [Select]
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...
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 06:27:39 AM
Could we also change instead 'If GetOemLed (821)' to If GetInBit(90,16) ? 

Here Is attachment.
Title: Re: System wait macro function help
Post by: TPS on January 31, 2020, 06:38:13 AM
Code: [Select]

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 




Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 07:14:17 AM
Code: [Select]

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.
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 07:35:48 AM
It is working!

It is not GetInBit(xx,xx)  but GetInput(xx)
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 07:52:57 AM
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?
Title: Re: System wait macro function help
Post by: TPS on January 31, 2020, 08:05:36 AM
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?
Title: Re: System wait macro function help
Post by: TPS on January 31, 2020, 08:17:10 AM
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
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 10:54:28 AM
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
         
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 11:12:23 AM
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.
Title: Re: System wait macro function help
Post by: TPS on January 31, 2020, 01:45:59 PM
... 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)
Title: Re: System wait macro function help
Post by: BGelektronika on January 31, 2020, 02:12:42 PM
... 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
-
-
-
-
-?
Title: Re: System wait macro function help
Post by: TPS on February 01, 2020, 02:46:41 AM
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.
Title: Re: System wait macro function help
Post by: BGelektronika on February 03, 2020, 05:58:07 AM
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...
Title: Re: System wait macro function help
Post by: BGelektronika on February 03, 2020, 05:59:01 AM
Attachments
Title: Re: System wait macro function help
Post by: TPS on February 03, 2020, 06:05:13 AM
Sorry my fault.

code corrected:
Code: [Select]
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 

Title: Re: System wait macro function help
Post by: BGelektronika on February 03, 2020, 06:07:14 AM
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.
Title: Re: System wait macro function help
Post by: BGelektronika on February 03, 2020, 06:10:09 AM
Sorry my fault.

code corrected:
Code: [Select]
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
Title: Re: System wait macro function help
Post by: BGelektronika on February 03, 2020, 09:32:13 AM
Sorry my fault.

code corrected:
Code: [Select]
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?


Title: Re: System wait macro function help
Post by: TPS on February 04, 2020, 01:34:51 AM
do you mean macro will not wait until Input is on, or does the macro not goin Forward after Input is on?
Title: Re: System wait macro function help
Post by: BGelektronika on February 11, 2020, 06:37:14 AM
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