Help with Macro that logs homing deviation

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Help with Macro that logs homing deviation

Postby SteelHero » Thu Feb 22, 2024 4:04 am

I have a machine that is having intermittent step loss issues. I have 2 objectives

1. Rehome the machine after each cut, we suspect the step loss happens at the end of the cut, rehoming the machine would allow it to reset the home position in preparation for the next run. The appears to be as simple as a G28.1 command in the M30 macro.

2. Log the difference in home position. Lets say I lost steps and it causes a .050" positioning error in the y axis. The machine would travel to the Y axis limit, when triggered log the -0.050" position value in a sheet with date and time, and then set the the machine coordinate system to zero (essentially homing the machine).

Having never written a macro in UCCNC before, this was my thought process. (This would triggered via the M30 macro

Define slow home speed, fast home speed, warning limit, and file location.

1. Turn off soft limits
2. Move Z axis to switch at a fast home speed till switch hit
3. Retract Z axis .25"
4. Move Z axis to switch at slow home speed till switch hit
5. Save Z axis readout to variable
6. Move Y axis to switch at a fast home speed till switch hit
7. Retract Y axis .25"
8. Move Y axis to switch at slow home speed till switch hit
9. Save Y axis readout to variable
10. Move X axis to switch at a fast home speed till switch hit
11. Retract X axis .25"
12. Move X axis to switch at slow home speed till switch hit
13. Save X axis readout to variable
14. Write X, Y, and Z values + date/time + current G-Code File to Log File
15. Set machine coordinates to 0,0,0 (or alternatively move away from switches by .5" and run G28.1 to home).
16. Popup a window telling the operator if error exceeded some defined limit

I'm still researching if this is possible via Macros. I would welcome any suggestions for improvement.

I plan to use some of the macros provided here by Robert Spark as a reference while writing the Macro. https://cncdrive.com/forum/viewtopic.ph ... 1&start=10

Thanks
SteelHero
 
Posts: 4
Joined: Thu Feb 22, 2024 3:07 am

Re: Help with Macro that logs homing deviation

Postby dezsoe » Thu Feb 22, 2024 6:32 pm

Many years ago I wrote a macro to check homing. (In fact, I wrote 2 of them to demonstrate the two macro languages.) There are some limitations that you need to take care of:

- UCCNC will not home twice, only once.
- You must not run the home check macro while you run a g-code. This is because it changes the axis settings while running and in older UCCNC versions this made faults while newer versions simply ignore the apply/save settings button while cycle is running.

I've just checked that the linked macros do not turn of the soft limits, so I upload here the current version of them.
Attachments
M20912.txt
(3.82 KiB) Downloaded 41 times
M20910.txt
(3.58 KiB) Downloaded 39 times
dezsoe
 
Posts: 2078
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Help with Macro that logs homing deviation

Postby SteelHero » Fri Feb 23, 2024 2:42 am

dezsoe wrote:Many years ago I wrote a macro to check homing. (In fact, I wrote 2 of them to demonstrate the two macro languages.) There are some limitations that you need to take care of:

- UCCNC will not home twice, only once.
- You must not run the home check macro while you run a g-code. This is because it changes the axis settings while running and in older UCCNC versions this made faults while newer versions simply ignore the apply/save settings button while cycle is running.

I've just checked that the linked macros do not turn of the soft limits, so I upload here the current version of them.


Thank you so much! This would have been a real challenge for me to arrive at. I do have a few questions for you.

When you say UCCNC will not home twice, only once, what do you mean by that?

Regarding not using the macro while running G-code, if I'm understanding correctly that means I wouldn't be able to initiate the home-check by including it in an existing macro, like M30, or calling a user defined macro from the G-Code. Would it be possible to call the macro after each program has run via a macroloop?

Thank you again, such a time saver and such a well written macro.
SteelHero
 
Posts: 4
Joined: Thu Feb 22, 2024 3:07 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 2 guests