Hello Guest it is August 04, 2020, 10:52:40 AM

Author Topic: Macro Code  (Read 6953 times)

0 Members and 1 Guest are viewing this topic.

Macro Code
« on: May 01, 2008, 08:17:42 PM »
Ok, I think I finally figured out what is going on. The following code is what I wrote for a Z axis zeroing routine. Thanks to everyone for your help with this. If any previous post implied that I have not gotten support here, it was just poor wording (I was complaining about my previous hardware/software vendor , not Mach3 or CandCNC), everyone here has been nothing but helpful.  I've gotten several suggestions that got this program to work in the first place and, hopefully, a few more will let me make this a usable macro.

If GetOEMLed(800)<>0 Then    (Check to see if the reset led is on or off, if on send reset)
     DoOEMButton(1021)
End If
While GetOEMLed(824)=0         (If the Z Home led is not on)
  DoOEMButton(312)Wend        (Activate Z- jog button)
Wend
q=0                                        (I could never get the 'Sleep' function to work. I got a syntax error every time I tried to use it.)
While q < 1000                        (These 4 lines are just a time delay)
  q=q+1
Wend
While GetOEMLed(800)<>0       (Since the touchplate acts as a limit, this sends a reset code)
     DoOEMButton(1021)
Wend
q=0                                        (Another time delay.)
While q < 1000
  q=q+1
Wend
Code "G91 G0 Z0.252"              (my touchplate is .498 thick so it raises the Z axis .252" to get it to .750)
q=0                                        (Another time delay. If it parses the 'While IsMoving() line before the axis starts moving it gets stuck in an unrecoverable loop)
While q < 1000
  q=q+1
Wend
While ismoving()                       (Wait for the Z axis to stop moving before setting the Z axis DRO)
Wend
SetDro(2,.750)                        (Reset the Z axis DRO to .750 (my .498 plate + .252 travel)
End

This code runs perfectly in the VBScript editor window, but it chokes if I enter M1001 (the name of the macro) in in the MDI window, or try to call it as a button routine. It runs until the tool hits the touchplate, then aborts. I think that what is happening is that in the VB window, it is running under the control of VB. While it does trip a limit, the program continues and is allowed to pass a reset code to Mach3, and the program completes. When I attach it to a button in Mach3, when it hits the limit, Mach3 aborts the program so it never gets to the 'Reset' command.

It appears that what I want to do isn't possible from inside the program because any home or limit activation aborts all program code, and won't allow you to do anything else until clicking on the reset button. I have 'Auto Limit Override' turned on, but it makes no difference. What I've been able to find in documentation indicates that this setting should allow one move in the opposite direction after a 'Reset' flag is set, but so far I haven't found a way to make it work.

Does anyone have any idea if it is possible to override the 'Reset'?

Re: Macro Code
« Reply #1 on: May 01, 2008, 09:10:37 PM »
Do you have the Limit Override enabled in the Config--->Ports & Pins ---> Input Signals?  I had the same prob with limit overides until someone clued me in to enabling it.

HTH,
Sid
Re: Macro Code
« Reply #2 on: May 01, 2008, 09:22:04 PM »
Yeah, I tried the limit override, but it made no difference. I found one setting (I don't remember where) that would override the limits, but using that, it just ignored the limits/homes completely. I think that the problem is that 'Home' and 'Limit' should be treated differently. A 'Limit' should shut everything down and abort any running program, but a 'Home' should only stop axis movement in that direction, on that axis. The only time a 'Home' switch is used is when you are 'TRYING' to hit a limit for positional information, a 'Limit' is used when you screwed up. You should be able, via an OEM function, to tell a macro/program whether to use a switch as a 'Home' or 'Limit' switch. If that is possible, I haven't found a way to do it.
Re: Macro Code
« Reply #3 on: May 01, 2008, 09:46:41 PM »
OK, a couple more ideas.

Maybe try a different number to name the macro.  I know that sounds screwy but sometimes I couldn't get macros to call using certain numbers.  Doesn't sound like this is your problem but WTH- who knows?


If the whole limit thing is a problem, what about finding a way to not use it.  Why does the touch plate HAVE to act as a limit- can you configure to make it act like something else.  I don't have the SDk loaded on this machine but I seem to recall that the probing/digitizing example does not use the limit to retract.  Maybe looking at that might help.

Sid

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macro Code
« Reply #4 on: May 02, 2008, 04:26:22 AM »
Is this what all this stuff about reset has been about?

code "G31 Z-100"
while isMoving()
wend

set zero

G00 Z0.75
while isMoving()
wend


« Last Edit: May 02, 2008, 04:31:34 AM by stirling »

Offline jimpinder

*
  •  1,232 1,232
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macro Code
« Reply #5 on: May 02, 2008, 06:11:16 AM »
You have probably found the answer when you say that your program trips a limit switch, which aborts the program and stops everything moving. As far as I understand, that is what it is supposed to do - it is an emergency stop.

However - and I might have said this earlier, or elsewhere, recently - switches are bi-functional. You must turn off the LIMIT switch function before you hit the switch. It will then act as a home switch - which allows you to hit it without stopping the whole show.

I don't know how you do this from a Macro- I've been looking through my notes without any luck as yet.

I would try your program, but switch the LIMITS off first - leave the homes on if you are using that part of the program - and see if it runs correctly then. At least we will know what we are looking for then.
Not me driving the engine - I'm better looking.
Re: Macro Code
« Reply #6 on: May 02, 2008, 07:46:19 AM »
jimbinder - I have tried every setting I can find to turn off the limit function, but haven't found any setting yet that will stop it from tripping a reset. It may be in there somewhere, I just haven't found it. I'm still going through the documentation for Mach3, the Customizing documentation, and the Wiki site. Each of them has supplied some info, but so far I haven't found this.

stirling - While that code will work to set Z0, the final outcome is wrong. Using that code, it will set Z0 at the height of the touchplate and raise the head .75". This leaves Z at 1.248. Also, this is only one of a couple of things I want to do that require referencing a home switch, but they all require the head to be able to move again after touching a home switch, without intervention by the operator.

sshneider - I have tried a couple of different names. Initially I used M90000 (as suggested by the documentation for user macros).

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macro Code
« Reply #7 on: May 02, 2008, 08:06:50 AM »
stirling - While that code will work to set Z0, the final outcome is wrong. Using that code, it will

set Z0 at the height of the touchplate and raise the head .75". This leaves Z at 1.248.
Oh come on... so set 0.498 instead of zero - whatever. Do you really think you're the first person ever to want to do toolheight with a touchplate - the forum's litered with the CORRECT way to do it.

Also, this is only one of a couple of things I want to do that require referencing a home switch, but they all require the head to be able to move again after touching a home switch, without intervention by the operator.

I don't get it - you feed dribs and drabs but never actually say what it is you're trying to achieve.

I'll be VERY suprised if whatever way you finally achieve what you want it couldn't have been done far easier if the above is anything to go by.

Offline jimpinder

*
  •  1,232 1,232
  • Wakefield, West Yorks, UK
    • View Profile
Re: Macro Code
« Reply #8 on: May 02, 2008, 01:56:37 PM »
If you go to Config/Ports and Pins/Input Signals the first 18 lines cover the Limits and Homes of all the axis. Just disable (click first column) the limit switches that are causing you bother and then try your code. If you leave the home switch enabled, that switch will only act as a home.

There must be a way of disabling the limit in software - perhaps someone can tell us how.
Not me driving the engine - I'm better looking.
Re: Macro Code
« Reply #9 on: May 02, 2008, 02:01:37 PM »
Or another idea....

Don't know about your B.O.B.  but if you can come up with an extra input pin, put the touch plate on a seperate pin that is discrete from the rest of your home/limit system (as is done with a touch probe system).

Also, I have found that 4 digit macros are 'funky' sometimes, I try to stick with 3 Digits (650 is my all time Fav!)

Sid