Hello Guest it is March 28, 2024, 04:25:55 AM

Author Topic: How to mark an axis as "Homed"  (Read 2933 times)

0 Members and 1 Guest are viewing this topic.

How to mark an axis as "Homed"
« on: October 06, 2019, 01:30:30 PM »
When you run the out-of-the-box homing script, the axes are homed one at a time and each one has a LED which changes from red to green to mark that the homing has completed on that axis.

I am writing my own homing script which doesn't use the built in "drive to home switch" type of homing. What API call can I use to set that LED green, and mark in software that the axis has been homed?

Thanks,

Mike

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: How to mark an axis as "Homed"
« Reply #1 on: October 06, 2019, 04:25:38 PM »
There is no script API to set the homed state of a motor (and thereby the axis it is attached to), only in C or C++ can you do that.  So set the axes to use "home in place" in the configuration dialog and call the regular homing API (mc.mcAxisHome() to turn the LEDs on and mc.mcAxisDeref() to turn the LEDs off)  Then do what you want. 

Steve
Re: How to mark an axis as "Homed"
« Reply #2 on: October 06, 2019, 05:34:18 PM »
Well shoot. So briefly, here is what I am trying to do. I have servo drives on my machine that have the absolute position stored in them through power cycles (even if the motor is moved). I can read this position into Mach and set the axis positions to match using scripts. This is the homing without needing to drive to the switch. Before I can do that though, I need to do a normal home to the home switches on my machine and write that "zero" position to the servo drives.

So technically I need to be able to home both to the switch and in place (which is what will be done most of the time).

I don't know what goes into it, but this would be a feature that would be really helpful (to me) to have exposed to the API. Something like mc.mcAxisSetRef()? Maybe I can use the home in place setting but find another way to accomplish the normal home to switch routine? I'm not sure how I could get the Smoothstepper to execute its homing sequence though...

This is a really weird use case, I know, but it would be really cool for me to get it working.
Re: How to mark an axis as "Homed"
« Reply #3 on: October 06, 2019, 06:04:16 PM »
Hi,

Quote
So technically I need to be able to home both to the switch and in place (which is what will be done most of the time).

But there are APIs that let you do just exactly that.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to mark an axis as "Homed"
« Reply #4 on: October 06, 2019, 06:49:36 PM »
Craig,

Didn't think of that... You think I can just change the Mach 4 homing configuration on the fly?

Looking at the API reference, I see mc.mcAxisSetHomeInPlace(inst, AxisID, T/F). I would think I could set this TRUE before calling to home the axis using my servos so they don't move (for absolute homing from the servo drives), and FALSE to home normally?

Thanks
Re: How to mark an axis as "Homed"
« Reply #5 on: October 06, 2019, 07:26:33 PM »
Hi,

Quote
Looking at the API reference, I see mc.mcAxisSetHomeInPlace(inst, AxisID, T/F). I would think I could set this TRUE before calling to home the axis using my servos so they don't move (for absolute homing from the servo drives), and FALSE to home normally?

Yes, that is exactly my understanding.

There are other situations where you can change 'settings' like that. Ordinarily, and in Mach3, once a setting is made then the only way to change it is to restart Mach3.
All semblance of changing machine behaviour on the fly is lost.

I suggest you look at the ability to link, or conversely un-link individual motors to or from an axis. There are some interesting cheats/hacks that can be done using the ability
to programatically change machine settings without the need to restart the program.

One trap is that if you change a setting in this manner is when, or even if, it will ever be written to the .ini file. There is an API that flushes the machine state to the .ini file,
and its use is recommended or unpredictable things can happen.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to mark an axis as "Homed"
« Reply #6 on: October 06, 2019, 09:25:09 PM »
Quote
There are other situations where you can change 'settings' like that. Ordinarily, and in Mach3, once a setting is made then the only way to change it is to restart Mach3.
All semblance of changing machine behaviour on the fly is lost.

I guess that is what I am familiar with (even though I've been in Mach 4 for a while now). Makes sense that it was made to be much more flexible.

Not 100% sure what you mean about the INI file. Is the goal to save your changes to the INI every time you make a change, or are you trying to avoid saving it at all?

At this time my thoughts are that I want to have Mach start up in a defined state every time. I may change settings throughout its use, but unless I crash the program, it should be back to default before shutting down.
Re: How to mark an axis as "Homed"
« Reply #7 on: October 06, 2019, 09:40:59 PM »
OK, here is where I am at on this. I have modified the REF ALL HOME script to ask me in a pop-up window if I want to define home from the absolute data in the servo drives or if I want to execute the normal homing sequence. If I choose normal, at the end of the sequence it asks if I would like to define the home position in the drives as well (which I answer YES to unless the homing failed for some reason). If I opt to restore the position data from the drives, the data is read, converted from hex to decimal, and written to the current position in Mach. I have not yet implemented the home in place to mark the axis as homed.

What I noticed is that the API call mc.mcAxisSetPos() only sets the fixture offset and not the actual machine position (which now as I just looked is what the documentation says - doh!). I think what I need to do is: change mode to home in place, read servo drive position, copy that position to the home offset, then home in place. Since this method can be completed when the machine is in any position, I can't guarantee I will be sitting at 0,0,0. What is pretty neat is I can enable and disable the motors as much as I want and the position data reflects the minuscule changes in shaft position as the motors get energized and de-energized. 

BTW, if anyone is interested, the servo drives are AB Ultra 3000's and I created an interface to the drives over serial (RS485) using the drive's host commands. Took a while to develop, but the serial interface through Mach 4/LUA is really solid and this communication seems bulletproof.
Re: How to mark an axis as "Homed"
« Reply #8 on: October 06, 2019, 10:26:11 PM »
This may be diving into the realm of the Smoothstepper's Plug-in but there really seems to be no change in behavior between setting mc.mcAxisSetHomeInPlace() to TRUE or FALSE. This seems to be the only thing holding this function up for me.

I can correctly set the home offset, and set the API call to home in place, but then all the axes move to the switches and home normally. I'll cross post this question with Warp9 to try and get an idea of what they are doing with homing code on their end.
Re: How to mark an axis as "Homed"
« Reply #9 on: October 07, 2019, 12:59:29 AM »
Hi,
I rather suspect that Mach4 is continuing in the existing homing mode, that you have changed mode has not yet taken effect.

If memory serves there is an API that causes Mach to re-read the .ini file, and then and only then does the change take effect.

I'm due out the door in minutes to play bridge but would otherwise explore this further.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'