Wednesday 24 February 2021

Incremental changes to .ini and .hal files using the PNCConf tool

Background:
Now that I've got the Probe Basic Lathe (PBL) GUI set up and working, I need a simple method for making changes to the .ini and .hal files as I configure and evolve the setup.

As the current working files had to be manually fettled (quite extensively) after initial creation by the LinuxCNC config tool, I can't simply go back in with the PNCConf tool to make changes. If I do so, most of the painfully created edits will be overwritten and I will get quite upset.

My Cunning Plan is to create 2 almost identical system configs using the PNCConf tool, with the second instance differing only by the incremental change I am hoping to carry in to my PBL configuration. Then I can use Visual Studio Code (VSC) to compare the contents and highlight the differences. I can then manually update my PBL system by copying and pasting in the relevant content. I would do this for each change I need to implement. Sounds simple enough?

Current Status:
I have the PBL setup working on the bench. It spins the servos and appears to home correctly when I trigger the home / limit inputs manually using 3 microswitches lying on the bench. However, there was some modest progress last night when I wired up actual the X Axis microswitches on the machine itself. I'd like to get those wired up and working correctly before powering up the servos on the machine. This is what it looks like with the cross slide removed:


Here's what I've got right now in the HAL file on the homing / limit switch front. It works nicely if I manually trigger the microswitches at the correct moments:

# --- BOTH-X ---
net both-x     <=  hm2_5i25.0.7i76.0.0.input-00-not
# --- BOTH-Z ---
net both-z     <=  hm2_5i25.0.7i76.0.0.input-01-not
# --- ALL-HOME ---
net all-home     <=  hm2_5i25.0.7i76.0.0.input-02
....

#*******************
#  AXIS X JOINT 0
#*******************

# ---setup home / limit switch signals---

net all-home     =>  joint.0.home-sw-in
net both-x     =>  joint.0.neg-lim-sw-in
net both-x     =>  joint.0.pos-lim-sw-in

#*******************
#  AXIS Z JOINT 1
#*******************

# ---setup home / limit switch signals---

net all-home     =>  joint.1.home-sw-in
net both-z     =>  joint.1.neg-lim-sw-in
net both-z     =>  joint.1.pos-lim-sw-in

It's quite easy to see how the input-00, input-01 etc inputs into the 7i76 are connected by the coloured nets to the home-sw-inneg-lim-sw-in signals. The PNCConf tool generates these entries automatically, depending on the selections made in the various setup choices.

You can see from the photo above that I have 2 switches on the X Axis, namely a combined "Home + X Pos Limit" switch at one end and a "X Neg Limit" switch at the other. That's not how the above HAL entries are expecting to find things. I will need to use My Cunning Plan to figure out what those changes are.

First pass:
Let's create a simple, minimal setup using PNCConf. Choosing minimal options requires the following:
  • Define XZ / lathe configuration and a dummy name
  • Define stepgens for the X & Z axes
  • Accept default axis parameters
  • Select the appropriate switch inputs for the Home and Limit signals.
  • Then save and exit.
Here's what I have at the top of the "current" .INI file:

# external input signals 
 
# --- BOTH-X ---
net both-x <= hm2_5i25.0.7i76.0.0.input-00-not

# --- BOTH-Z ---
net both-z <= hm2_5i25.0.7i76.0.0.input-01
-not
 
# --- ALL-HOME ---
net all-home <= hm2_5i25.0.7i76.0.0.input-02
-not
 
#*******************
# AXIS X JOINT 0
#******************* 

# ---setup home / limit switch signals---

net all-home => joint.0.home-sw-in
net both-x => joint.0.neg-lim-sw-in
net both-x => joint.0.pos-lim-sw-in

#*******************
# AXIS Z
JOINT 1
#*******************

# ---setup home / limit switch signals---

net all-home => joint.1.home-sw-in
net both-z => joint.1.neg-lim-sw-in
net both-z => joint.1.pos-lim-sw-in


And the replacement:

# external input signals

# --- MAX-HOME-X ---
net max-home-x <= hm2_5i25.0.7i76.0.0.input-00
-not
# --- MIN-X ---
net min-x <= hm2_5i25.0.7i76.0.0.input-01
-not
# --- MAX-HOME-Z ---
net max-home-z <= hm2_5i25.0.7i76.0.0.input-02
-not 
# --- MIN-Z ---
net min-z <= hm2_5i25.0.7i76.0.0.input-03
-not
 
#*******************
# AXIS X JOINT 0
#*******************

# ---setup home / limit switch signals---
 
net max-home-x => joint.0.home-sw-in
net min-x => joint.0.neg-lim-sw-in
net max-home-x => joint.0.pos-lim-sw-in

#*******************
# AXIS Z JOINT 1
#*******************

# ---setup home / limit switch signals---

net max-home-z => joint.1.home-sw-in
net min-z => joint.1.neg-lim-sw-in
net max-home-z => joint.1.pos-lim-sw-in

Of course, there are also some minor changes to the .INI file too. If you don't catch those, stuff isn't going to work out well. There's only one here:

Before:
 
MIN_LIMIT = -0.01
MAX_LIMIT = 200.0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -1.000000
HOME_LATCH_VEL = -0.500000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO

HOME_SEQUENCE = 1

 
After:

MIN_LIMIT = -0.01
MAX_LIMIT = 200.0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -1.000000
HOME_LATCH_VEL = -0.500000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = YES
HOME_SEQUENCE = 1


Presumably, if a limit signal is seen during homing, an error will be created unless you include that line. Easy thing to overlook!

So I will now test out the theory on the bench. Luckily, the headers on the 7i76 have removable plugs, so I can unplug the existing microswitches and plug in the machine's microswitch inputs instead. 

Sorted - works nicely. Rather a PITA to implement but I guess it will get easier with practice.

No comments:

Post a Comment

Final assembly and test of the spindle nose adaptor - RESULT!!

After the recent distraction caused by the 3D scanner, resurrecting the 3D printer and buggering about with the throttle bodies for my Honda...