adding auto leveling to linuxCnc

More
16 Feb 2022 05:08 - 16 Feb 2022 05:10 #235010 by SrLange61
I got it going and it was easy.

Just changed the name of signal line like this-

net xpos2-cmd <= axis.x.pos-cmd => compensation.x-pos

I can see the Z motor moving so its now fine. Now time to scan the table again and get it around the 0 Z level.
Will post again when I cut .1 mm above the glass.

Thanks
srl
Last edit: 16 Feb 2022 05:10 by SrLange61.

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 11:14 - 23 Feb 2022 11:14 #235591 by zdebel
The scanning and Z compensation seem to work properly (I check this using a cup, I scan it, remove it and then I see when moving on same 'Z' depth, the tip carves the shape of the cup). The problem I have is that the Z compensation is lagging, when I put the cup back, there are collisions between the tip and the cup, the Z is lagging behind the current XY position.
Last edit: 23 Feb 2022 11:14 by zdebel.

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 12:30 #235597 by ds.lithographie
seems that compensation.py is best for dealing with a flat surface that is tilted or uneven -- you sample surface height at 10 mm X-Y spacing, and then it interpolates a height map with 0.1-1 mm resolution depending on the scaling factor.

Check out Compensation.loadMap() method definition from the compensation.py file. ~ 30 lines of code and this is where things happen. If you provide a much denser probe-results.txt, the code may handle it poorly if without modification.

Essentially what loadMap() does is take X,Y, Z value from probe-results.txt, clean it up a little bit, feed them into scipy.interpolate.griddata(), and returns a value-mapped 2D array with X and Y being the index.

Since array indicies cannot be float, so X and Y must be int() -ed, and this might be a significant source of error (and bug!) if you r application requires a much better resolution than 0.1-1 mm.

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 12:32 #235598 by zdebel
ok, will check, thank you for your reply

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 20:06 #235644 by zdebel
I've recorded videos where you can see how the Z compensation is lagging.



I've probed the tape, removed the probe and I'd like to see the Z axis "draw" the arc, as you can see it's lagging very badly.

Please Log in or Create an account to join the conversation.

More
23 Feb 2022 20:51 - 23 Feb 2022 20:52 #235650 by ds.lithographie
Ah I see, when feed rate is high it wont keep up.
In Compensation.run() method definition there is a time.sleep() function sitting in the while True loop. Modifying its value may give better or worse lagging behaviors.

Think of the Python script as a real-time module in the HAL file. After initialization (loadMap()), and clicking enable in the GUI, this script is just constantly comparing current machine position with the generated heightmap, and outputting height adjustment to the joints.

This obviously will take specific amount of time that is dependent on the particular Linux machine running the script.

I have not benchmarked the timing behaviors, but I think it is possible to add time stamping like this and review the numbers in the terminal. Python can print to the terminal if you invoke Linuxcnc from the command line by calling "linuxcnc":
```
import time
print_every = 1000
time_counter = 0
t_total = 0.0
t1 = 0.0
t2 = 0.0
  while True:
  time.sleep(UPDATE_INTERVAL)
  t1 = time.time()
  ##start of original while loop code
  ##end of original while loop code

  t2 = time.time()
  time_total += t2-t1
  time_counter += 1
  if time_counter > 1000:
    print("average execution time is %f "% (time_total / time_counter))
    time_counter = 0
```
If decreasing the sleep interval does not help or causes problem, another way is to just decrease your feed rate to below your (resolution / UPDATE_INTERVAL). Unit here is machine unit per second
Last edit: 23 Feb 2022 20:52 by ds.lithographie.

Please Log in or Create an account to join the conversation.

More
03 Mar 2022 01:50 - 03 Mar 2022 02:04 #236238 by SrLange61
I've now been using it and its great. The dial shows that my table level variance has been reduced from .3mm down to .05. The milled parts come out much better. My next job is to move off VDFMOD to MB2HAL.
srl
Attachments:
Last edit: 03 Mar 2022 02:04 by SrLange61.
The following user(s) said Thank You: ds.lithographie

Please Log in or Create an account to join the conversation.

More
03 Mar 2022 23:46 #236294 by andypugh

Think of the Python script as a real-time module in the HAL file. 

Unfortunately Python can never truly be realtime. If true realtime behaviour is needed then the calculations would need to be done in C in an actual realtime module. 
There are examples of this sort of thing, where a userspace module handles file access etc and passes data to a realtime module. See for example sampler and halsampler. linuxcnc.org/docs/2.8/html/man/man1/halsampler.1.html (halsampler is userspace and sampler is realtime) 


 
The following user(s) said Thank You: ds.lithographie

Please Log in or Create an account to join the conversation.

More
11 Apr 2022 04:22 #239879 by Trihwangyudi1990
I use g-code ripper almost 1 year.. Can i save the g-code with probe data ? I mean when i start to run g-code from g code ripper, at the half of running this program i have to shut down my machine, so can i save the probing data then i continue run my gcode later?

Please Log in or Create an account to join the conversation.

More
26 Jul 2022 06:11 #248296 by rajsekhar
Dear friends,

I tried to use the autoleveller and got the error report as attached.

I followed ds.lithographie  steps and did followings:
1. copied compensation folder unzip under the same folder ini file is.
2. Offset added under Z axis and Halfile added in ini file.
3. postgui halfile modified (attached).
4. custompanel.xml changed (attached). I am doubtful If I made any thing wrong.
5. downloaded autoleveller jar and placed as per attached photo.
6. downloaded jdk 8 u341 from oracle www.oracle.com/java/technologies/downloads/#license-lightbox.
    My system is 32 bit. Not sure there is any mistake.
    tar used and extracted folder pasted in autoleveller folder as per attached photo.
7. created run.sh (attached as test file) and moved to bin folder. Not sure if I typed the address right in the run.sh file, big doubt.
8.  error report attached. it says "No module named scipy.interpolate". If any such module needed, please mention the source and how/where to paste/install it.

Thanks in advance for any help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.210 seconds
Powered by Kunena Forum