Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Robin06790 on July 11, 2013, 10:28:30 AM

Title: need help with macro
Post by: Robin06790 on July 11, 2013, 10:28:30 AM
I have been a cnc tech for years and
all inputs and outputs work and have been tested
   my biggest problem is that i am familiar with latter logic and programing of other plcs which is probably a hindrance (aerotech Mitsubishi  Automation-direct)
what i want to do is to create something so when i
activate a M-code or ????
i can run a program to look at a input( input#2 )
then activate a air cylinder( output#5 ) then
once the air cyl is forward see the next input
( input#1 ) and shut off the output

M22.m1s

Do
If Not (getoemled(821))Then
End If
If (getoemled(821)) Then activatesignal(output5)
Loop
Do
If Not (getoemled(822))Then
End If
If (getoemled(822)) Then deactivatesignal(output5)
Loop
Do
If Not (getoemled(821))Then
End If
If (getoemled(821)) Then Exit Do
Loop

Thanks Robin
Title: Re: need help with macro
Post by: BR549 on July 14, 2013, 12:08:34 PM
OK, are you asking for help or just showing us what you have done??

Glad to help if needed, (;-) TP
Title: Re: need help with macro
Post by: Robin06790 on July 15, 2013, 08:51:13 AM
oh yes i need help help help   i have read a lot of posts and have solved some of my problems   first i foun out u can not use any m code below 100 so i renamed it m113.m1s    this i my new program after a lot of time it almost works right
here is what it does from MDI it runs  when i try to run it from the program it sticks on the path generation screen saying please wait Generating Path
i figured it is stuck in some kind of endless loop??????

m113.m1s

Do
deactivatesignal(output5)
If (getoemled(822))Then
Exit Do
End If
Loop
Do
activatesignal(output5)
If (getoemled(821))Then
Exit Do
End If
Loop
Do
deactivatesignal(output5)
If (getoemled(822))Then
Exit Do
End If
Loop
end

thanks Robin

Title: Re: need help with macro
Post by: Hood on July 15, 2013, 11:44:07 AM
General Config, Ignore M Calls While Loading.
Hood
Title: Re: need help with macro
Post by: Robin06790 on July 15, 2013, 12:12:27 PM
Thanks hood that worked Great

Robin
Title: Re: need help with macro
Post by: BR549 on July 15, 2013, 09:29:34 PM
Did that solve your problem ?

You may want to consider a time based exit from the loops as you CAN get stuck in the loop and the only way out is to crash out/reboot

It is as simple as  adding a loop counter with a sleep state to count up.

Count1 = 0

DO
deactivatesignal(output5)
If (getoemled(822))Then
Exit Do
End If
Count1 = (Count1 +1)
Sleep(1000)
IF Count1 >4 then exit

Loop

This way each loop through the code it ups the count by 1 and waits 1 sec before starting the loop again AND when it gets to the set time limit it will exit OUT of the loop.

Just a thought, (;-) TP