Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: moorea21 on January 28, 2015, 12:47:05 PM

Title: New to macros; do macros run only when needed?
Post by: moorea21 on January 28, 2015, 12:47:05 PM
I have had no luck getting homing to work on my machine, so I've decided to write a macro that should do what I want. This macro should set the DRO of X axis to zero if the switch wired to input#1 is tripped, and then reverse away from it. Not tested yet, as I'm not near the machine.

If IsActive(INPUT1) Then 'if switch is triggered
   DoOemButton (250)     'stop X axis
   Code "G92 X0"            'zero X axis
   Code "G00 X10"          'move away from switch
   While IsMoving()
   Wend
End If

This should allow me to zero from my Gcode program.

Can I call this macro when needed by using an M command in the Gcode? Would it switch off after it has returned to the main Gcode?
The problem is, I only need this to happen once in each file, but if the macro is constantly running in the background checking the input, it will use a lot of processor power; not good.
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 28, 2015, 10:11:41 PM
What about HOMING does not work for you?

(;-) TP
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 05:14:36 AM
Have a look at my previous post, it explains in detail what happens when I try to home an axis... I still don't know why it behaves like that; I'm having more luck at the minute writing macros!
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 05:16:18 AM
http://www.machsupport.com/forum/index.php/topic,28959.0.html
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 10:37:48 AM
Are you sure you have the switches setup correctly ? I have never seen Mach3 not home if setup correctly.

If you look on the diagnostics page and push the switch manually does the correct HOME led light up and then go OUT when you release the switch?

AND no your macro will not work correctly.

(;-) TP
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 12:40:23 PM
I changed the macro a bit, it works now, although I'll probably also try a different approach to see if that works.. My ports and pins and homing are all set up correctly as far as I can see, the correct leds (M1 Home, M2 Home) light on the diagnostic page when I manually trigger the X home switch while the command 'G28.1 X0' is running. And yet Mach still ignores my home switch when I trigger it... Same thing happens during Y axis home. These are the only 2 axes configured at the moment.
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 01:00:16 PM
Are you running with the LPT driver OR using an outside motion controller ??

(;-) TP
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 01:12:14 PM

As a test from the diagnostic page, trip the X axis HOME switch and see if the A home LED lights up.

IF so then from the MDI (same page) give a command to home X , G28.1 X0.  While it is moving trip and release the X home switch. Does Mach3 stop ?

(;-0 TP

Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 01:31:30 PM
It's 2 parallel ports, and 2 pmdx 122 breaker boards, only using the inbuilt (non PCI card) port currently. I disabled Y home; now X home is the only home enabled. I have no A home at this point, although I have an A axis.

Only M1 home (which is X) lit in 1st test, 2nd test gave same results as previously, ie mach ignores me tripping home switch. Was watching diagnostic page in 2nd test, M1 home lit.
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 01:45:10 PM
Is this a licensed version OR DEMO ?

Goto HELP then About .  does it say DEMO ?

(;-) TP
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 01:54:21 PM
Yes, its demo version. Please don't say that means homing won't work...:)
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 03:54:44 PM
 >:D  I do not believe that homing works in DEMO MODE  :o
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 29, 2015, 04:01:57 PM
seriously?
Title: Re: New to macros; do macros run only when needed?
Post by: BR549 on January 29, 2015, 06:48:41 PM
IF everything worked in DEMO mode why would you ever buy a license (;-).

If you need Free there is LinuxCNC.

(;-) TP
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 30, 2015, 07:08:51 AM
I wish it had said that on the website, I wasted a good 3 days of my life trying to get it to work. Never mind!
Title: Re: New to macros; do macros run only when needed?
Post by: Overloaded on January 30, 2015, 08:17:09 AM
I wish it had said that on the website .....................

I tend to agree. All know limitations should probably noted here ....... :-\
Title: Re: New to macros; do macros run only when needed?
Post by: Hood on January 30, 2015, 08:44:53 AM
I agree as well, however as far as I know homing works in demo mode.


moorea21
Are you using the parallel port or an external device?
Hood
Title: Re: New to macros; do macros run only when needed?
Post by: Hood on January 30, 2015, 09:00:29 AM
Just confirmed, works fine in Demo when using the PP.

Hood
Title: Re: New to macros; do macros run only when needed?
Post by: moorea21 on January 30, 2015, 09:18:54 AM
To my amazement, I've found that homing works, and probably did from the start. I just didn't understand how G28.1 was supposed to behave. I'm sure I tried to read up on it prior to starting this little escapade, but I didn't understand the significance of the number after the axis letter.

I now realise that

a) Home switch will not trigger until axis is in its 'slow zone'. This information is not in the config manual; I have a stretched drive belt and a broken home switch now due to not knowing about that.

b) That the number after the axis letter denotes the point at which that slow zone will start. (Says so in the manual, but not clearly enough for me apparently)

I'd been trying to trigger the home switch with the axis 'out of step' by +/-50mm (simulating massive loss of steps), but with the slow zone setting at 1.00, and only using G28.1 X0, instead of slow zone of 50, and G28.1 X100.

I'm not blaming the author of the manual, it's my fault for not understanding something properly before using it.

I still need to have homing like behaviour on my Z axis that moves in the opposite direction to homing proper, so I'll still try a macro/macropump to achieve that, as in one of other current threads.

I think this may mean my problem is solved, we will wait and see...
Title: Re: New to macros; do macros run only when needed?
Post by: Overloaded on January 30, 2015, 10:31:52 AM
I think this may mean my problem is solved, we will wait and see...

I sincerely hope so.
Good luck with your further endeavors Richard.

Regards,
Russ