Hello Guest it is August 12, 2020, 12:49:14 AM

Author Topic: Please take a look at my simple macro - is it correct?  (Read 5530 times)

0 Members and 1 Guest are viewing this topic.

Please take a look at my simple macro - is it correct?
« 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!

Offline ger21

*
  • *
  •  6,282 6,282
    • View Profile
    • The CNC Woodworker
Re: Please take a look at my simple macro - is it correct?
« Reply #1 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
....
...
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: Please take a look at my simple macro - is it correct?
« Reply #2 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 :-)
« Last Edit: April 18, 2010, 06:23:52 PM by Hood »
Re: Please take a look at my simple macro - is it correct?
« Reply #3 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)
Re: Please take a look at my simple macro - is it correct?
« Reply #4 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!

Offline ger21

*
  • *
  •  6,282 6,282
    • View Profile
    • The CNC Woodworker
Re: Please take a look at my simple macro - is it correct?
« Reply #5 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.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline ger21

*
  • *
  •  6,282 6,282
    • View Profile
    • The CNC Woodworker
Re: Please take a look at my simple macro - is it correct?
« Reply #6 on: April 18, 2010, 06:31:57 PM »
Code "M8"
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Please take a look at my simple macro - is it correct?
« Reply #7 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!

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: Please take a look at my simple macro - is it correct?
« Reply #8 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

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: Please take a look at my simple macro - is it correct?
« Reply #9 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