Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: omegasea21 on April 18, 2010, 05:01:20 PM

Title: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 05:01:20 PM
They are the same marco, except the first uses the GetOEMLED which is mapped from input 1 and second looks directly at the input1 instead of the LED. Not sure if it makes a difference.

I just want to make sure that they are correct.

VacuumSwitch=GetOEMLED(24)

Code M8 (mist on)
Code G4 P1 (wait for 1 second)
Code M8 (flood on)
Code G4 P1 (wait for 1 second)
If VacuumSwitch=1 Then (if led 24 "trch on" is active then end macro)
Endif
Else (if not)
Code M8 (mist on)
Code G4 P1 (wait for 1 second)
Code M7 (flood on)
Code G4 P1 (wait for 1 second)
Endif (end macro)

Second option:

Code M8 (mist on)
Code G4 P1 (wait for 1 second)
Code M8 (flood on)
Code G4 P1 (wait for 1 second)
If IsActive(Input1) Then (if input1 is active then end macro)
Endif
Else (if not)
Code M8 (mist on)
Code G4 P1 (wait for 1 second)
Code M7 (flood on)
Code G4 P1 (wait for 1 second)
Endif (end macro)

Thank you!
Title: Re: Please take a look at my simple macro - is it correct?
Post by: ger21 on April 18, 2010, 06:14:58 PM
First, you mistakenly have M8 for both mist and flood in the first section.

Second,

Code M8

should be

Code "M8"

Third, just set the delays in Ports and Pins, Spindle page.

Fourth, you're turning on Mist and Flood at the start. Then, you're checking for a condition, and turning them on again. But, they're already on?? :) So the If ... Then section doesn't really do anything.

And last, either should work. You can also use:

If GetOEMLED(24) then
....
...
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 06:19:21 PM
Not the best at VB but these may work for you.

VacuumSwitch=GetOEMLED(24)

Code ("M7") 'mist On
Sleep (1000) 'wait For 1 Second
Code ("M8") 'flood On
Sleep (1000) 'wait For 1 Second

If VacuumSwitch=1 Then 'If led 24 "trch on" is active Then End macro
End
Else 'If Not
Code ("M7") 'mist On
Sleep (1000) 'wait For 1 Second
Code ("M8") 'flood On
Sleep (1000) 'wait For 1 Second
End If 'End macro




Code ("M7") 'mist On
Sleep (1000) 'wait For 1 Second
Code ("M8") 'flood On
Sleep (1000) 'wait For 1 Second

If IsActive(Input1) Then 'If if input1 is active then end macro
End
Else 'If Not
Code ("M7") 'mist On
Sleep (1000) 'wait For 1 Second
Code ("M8") 'flood On
Sleep (1000) 'wait For 1 Second
End If 'End macro


Hood

Edit see Ger has posted while I was typing :-)
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 06:28:32 PM
Thank you so much.

1.) The M7/M8 are being turned off by brains (I should have mentioned previously)
2.) Understood about setting the delay in ports in pins

I modified the script a little, this time I set it to wait until the previous command ends, will this work? Will the While IsMoving Wend command know to wait until m7 or m8 stops (as mentioned they are stopped by brains)?

Code "G0X9Y11" (go to specified coordinate)
While IsMoving (wait until stops moving)
Wend
Code "M8" (mist on)
While IsMoving() (wait for mist to turn off)
Wend
Code "M7" (flood on)
While IsMoving() (wait for flood to turn off)
Wend
If GetOEMLED(24) then (if led 24 is active then end macro)
Code "G0X0YO"(go home)
Endif
Else (if not)
Code "M8" (mist on)
While IsMoving() (wait for mist to turn off)
Wend
Code "M7" (flood on)
While IsMoving() (wait for flood to turn off)
Wend
Code "G0X0YO" (go home)
Endif (end macro)
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 06:31:23 PM
Hood, thanks for your post, this is the second time you came to my aid!

I see that you changed the Endif to End in the middle of macro, I didnt see that when I made my last post, but will adjust it in the final script.

Are parenthesis required?

I.e.

Code ("M8") or will this work Code "M8"

thank you!
Title: Re: Please take a look at my simple macro - is it correct?
Post by: ger21 on April 18, 2010, 06:31:29 PM
When does the Brain turn them off? You don't seem to be doing anything that would trigger the Brain?

Also, after your "Go Home" moves, you should probably add while ismoving...wend.
Title: Re: Please take a look at my simple macro - is it correct?
Post by: ger21 on April 18, 2010, 06:31:57 PM
Code "M8"
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 06:34:54 PM
The M7 / M8 are actually tied to linear actuators with potentiemeters. When M8 turns on, the actuator extends, when the potentiemete hits certain value it turns off (same with flood but in reverse)

thanks!
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 06:35:15 PM
Parenthesis are probably not required, just something I have always done, but as I am crap at VB its likely the wrong way ;D

Notice in your script you have just post you have YO instead of Y0 ;)

Hood
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 06:38:13 PM
Also you  have your comments within parenthesis, dont think that will work, either use Rem or '

Hood
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 06:38:26 PM
Gerry - So aside from "after your "Go Home" moves, you should probably add while ismoving...wend." does it look OK? This is the final step is completing my project and I am really excited to get it to work like I envisioned many months ago.

Also - hood just saw your post, thank you!
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 06:57:33 PM
I looked at your macro and also noted you saying you are turning the Mist/Flood off again by Brains. What exactly are you doing with the Brains as I dont think the While IsMoving() will wait for a Brain. Also you mention Pots, do the Brains tie into with the Pots?

Hood
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 07:07:20 PM
Hood,

Hello. Yes, the brains tie in the with potentiometer.

The brain reads like this:

if value of potentiemeter is > 13, turn off mist, it works fine and takes about 1 second for the actuator to extend.

So if the macro will not wait for the brain, I wonder if I should remove the brain and incorporate the "mist off" via the marco. Like this:

Code "G0X9Y11" 'go to specified coordinate'
While IsMoving 'wait until stops moving'
Wend
Code "M8" 'mist on'
If GetOEMDRO(74) >13 Then
Code "M8" 'Mist Off'
Sleep (1000) 'wait For 1 Second'
Code "M7" 'flood on'
If GetOEMDRO(74) <12 Then
Code "M7"
If GetOEMLED(24) then 'if led 24 is active then end macro'
Code "G0X0YO" 'go home'
While IsMoving 'wait until stops moving'
Wend
End
Else 'if not'
Code "M8" 'mist on'
If GetOEMDRO(74) >13 Then
Code "M8" 'Mist Off'
Sleep (1000) 'wait For 1 Second
Code "M7" 'flood on'
If GetOEMDRO(74) <12 Then
Code "M7"
Code "G0X0Y0" 'go home'
Endif 'end macro'
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 07:24:47 PM
I would probably try it this way

Code "G0X9Y11" 'go to specified coordinate
While IsMoving 'wait until stops moving
Wend
Do
Code "M8" 'mist on
If GetOEMDRO(74) >13 Then Exit Do
Loop
Code "M9" 'Mist Off
Do
Code "M7" 'flood on
If GetOEMDRO(74) <12 Then Exit Do
Loop
Code "M9"
If GetOEMLED(24) Then 'if led 24 trch on is active then end macro
Code "G0X0Y0" 'go home
While IsMoving 'wait until stops moving
Wend
End
Else 'if not
Do
Code "M8" 'mist on
If GetOEMDRO(74) >13 Then Exit Do
Loop
Code "M9" 'Mist Off
Do
Code "M7" 'flood on
If GetOEMDRO(74) <12 Then Exit Do
Loop
Code "M9"
Code "G0X0Y0" 'go home
End if 'end macro
Title: Re: Please take a look at my simple macro - is it correct?
Post by: Hood on April 18, 2010, 07:37:08 PM
Thinking this may be better, but as said I am no VB guy so someone may come up with a more sensible way.

DROvalue = GetOemDRO(74)

Code "G0X9Y11" 'go to specified coordinate
While IsMoving 'wait until stops moving
Wend
Do
Code "M8" 'mist on
If DROvalue >13 Then Exit Do
Loop
Code "M9" 'Mist Off
Do
Code "M7" 'flood on
If DROvalue <12 Then Exit Do
Loop
Code "M9"
If GetOEMLED(24) Then 'if led 24 trch on is active then end macro
Code "G0X0Y0" 'go home
While IsMoving 'wait until stops moving
Wend
End
Else 'if not
Do
Code "M8" 'mist on
If DROvalue >13 Then Exit Do
Loop
Code "M9" 'Mist Off
Do
Code "M7" 'flood on
If DROvalue <12 Then Exit Do
Loop
Code "M9"
Code "G0X0Y0" 'go home
End if 'end macro
Title: Re: Please take a look at my simple macro - is it correct?
Post by: omegasea21 on April 18, 2010, 07:42:37 PM
Thank you. I will give it try!