Thanks for the detailed feedback and also for the launcher script!
We haven't had the opportunity to test your script yet, but we will definitely take a closer look at it. Starting LinuxCNC and the simulator together with a single command is a very useful idea.
I went through the three points you mentioned and used them to update the Phase 3 example.
Working area
You were right that the previous working area was much too small for a realistic milling machine example.
The Phase 3 machine now uses:
X: 0 .. 600 mm
Y: 0 .. 400 mm
Z: -200 .. 0 mm
The virtual limit switches were updated accordingly and are located 1 mm outside the normal working area.
Z homing
I also changed the Z homing as you suggested.
X and Y still home toward their minimum switches, but Z now homes upward toward the maximum/home switch. The Z switch is therefore approached from below with a positive HOME_SEARCH_VEL.
Z offset between AXIS and the simulator
This was the point I was most interested in, so I tried to reproduce it deliberately.
For the test I placed the physical Z home switch at +1 mm and configured:
HOME = 0
HOME_OFFSET = 1
HOME_SEARCH_VEL = 2
HOME_LATCH_VEL = 0.2
This means that the physical switch position is intentionally different from the final G53 Z0 position.
I tested the complete homing sequence with LinuxCNC 2.10.0-pre2.
Z approaches the upper switch from below, backs off, performs the slow latch approach and finally moves back to G53 Z0.
After homing, both AXIS and the simulator showed exactly Z0.
I then commanded:
AXIS showed:
X = 10.000
Y = 10.000
Z = -5.000
and the simulator showed exactly:
X = 4000 steps = 10.000 mm
Y = 4000 steps = 10.000 mm
Z = -2000 steps = -5.000 mm
at 400 steps/mm.
I also checked the simulator's min/max switch implementation and added an explicit automated test for approaching the Z maximum switch from below, including its hysteresis behavior.
So far I have not been able to reproduce the several-millimeter Z offset you are seeing.
These changes are now included in
v0.1.2:
linuxcnc-sim v0.1.2
The complete simulator test suite also passes with the new configuration:
91/91 tests passed.
Could you try v0.1.2 with the new Phase 3 configuration and see whether the Z offset still occurs on your system?
If the offset is still there, could you send me your LinuxCNC .ini and .hal files, and your virtual-io.conf if you changed it?
Then I can reproduce your exact configuration instead of guessing where the difference comes from.
Thanks again for testing the simulator. Your feedback already resulted in several improvements to the example configuration.