Wednesday, 24 February 2021

How to add 7i85 board to 5i25/7i76 combo

Although I'm not quite ready to integrate my X and Z linear encoders with my LinuxCNC system, I have the 7i85 board already. I 'll need that to support the extra encoders above the single instance that the 7i76 supports. generally that's going to be used for the spindle encoder that you'll want if you want to measure actual spindle speed and the all-important rigid tapping.

Here's an overview of some of the Mesa cards.

The 7i85 is a "dumb" card ie it has no FPGA onboard, so doesn't require reflashing to set up the various IO. Instead, the 5i25 within the PC needs to be told to expect a 7i85 to appear on the end of the 25 way parallel cable.

The default firmware provided in the 5i25 when they ship it is configured for 1 or 2 of the 7i76 daughterboards. So I need to change the firmware within the 5i25. There's a bitfile for a 7i76 / 7i85 pairing, so the process is like this:

  • Download the 5i25 zip file from Mesa Electronics containing all the available bitfiles.
  • Use the mesaflash utility to flash the 5i25_7i76_7i85.bit bitfile into the 5i25.
  • Reboot the PC to power cycle the 5i25 so the changes take effect (yes I forgot).
The 7i76 should continue to operate as before (no need to reconfigure it). The 7i85 (being a dumb board) should simply appear as additional IO on the 5i25 board. In this case I should be able to set up as many as 4(?) encoder inputs and something like 5 RS485 interfaces.

Luckily, mesaflash is included in the std LinuxCNC install, so as long as you avoid capitalising the first letter and remember to issue the sudo command first, it will go like this:

muzzer@LinuxCNC:/lib/firmware/hm2/5i25/configs/hostmot2$ sudo mesaflash --device 5i25 --write 5i25_7i76_7i85.bit
Checking file... OK
File type: BIT file
Boot sector OK
EEPROM sectors to write: 6, max sectors in area: 16
Erasing EEPROM sectors starting from 0x100000...
Programming EEPROM sectors starting from 0x100000...
Board configuration updated successfully.
Checking file... OK
File type: BIT file
Boot sector OK
Verifying EEPROM sectors starting from 0x100000...
Board configuration verified successfully.

You must power cycle the hardware or use the --reload command to load a new firmware.

That worked and the 7i76 config remained intact - TFFT!

HTD3 timing belts and pulleys - how can they be this crap?

What now, fatty?
Bastard nightmare. Having finally assembled my precision ground ballscrew, back-to-back thrust bearings and servo motor, there is a shit load of backlash between the motor and the ballscrew, equivalent to around 100um of linear motion. Even a blind man could see this in the dark.

WTF?? Is it the belt or the pulleys? Almost certainly the pulleys you'd think, as the belt surely isn't going to be shipped like that. On the other hand, the pulley stock used in the production of these (mainly hobby) pulleys is probably flung out by the skip load in some shithole in China with little regard for quality.

So what should it look like then?
Let's find out what we should be seeing when we look at an HTD3 pulley:


Sure enough, when you look for the "approved" dimensions for the HTD3 tooth profile, you find:

To summarise - approx 1.9mm across the throat and 1.1mm across the top of the teeth. 
And what do we find?

Let's call that 0.6 - 0.7mm across the teeth. So I'm seeing around 0.5mm backlash on each pulley, equivalent to ~1mm total backlash. You can hear the wind howling through the gap between the belt and the pulley. Jesus shit and piss.

With a circumference of around 72mm for the 24t pulley, 1mm of backlash is equivalent to ~70um. That's in the sort of ballpark I'm expecting - ballpark being the operative word here.

So that makes a mockery of my ground ballscrews and 2500 steps per rev servo motor. 

The choice seems to be to randomly buy a load of HTD3 pulleys from a wide range of suppliers and hope some are actually better than this - or perhaps try my hand at making my own. Never one to avoid an unnecessary complication, I may be tempted to go for the latter. Dumb fuck or what? Watch this space...

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

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


# ---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


# ---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
# --- ALL-HOME ---
net all-home <= hm2_5i25.0.7i76.0.0.input-02

# ---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


# ---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
# --- MIN-X ---
net min-x <= hm2_5i25.0.7i76.0.0.input-01
# --- MAX-HOME-Z ---
net max-home-z <= hm2_5i25.0.7i76.0.0.input-02
# --- MIN-Z ---
net min-z <= hm2_5i25.0.7i76.0.0.input-03

# ---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


# ---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:

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



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

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.

Sunday, 14 February 2021

Spindle encoder bracket for the Bantam

What up?
I need an encoder for the Bantam spindle if I want to do threading later, which I certainly do. I have a spare one that came with The Shiz. Seems to work fine, despite scribblings on it suggesting it had failed. I'll need to keep an eye on it but after an inspection and cleanup, it looks good to go.
I bought a couple of 36t HTD 5mm pitch, 9mm width pulleys for this. I reckoned the diameter should be sufficient for me to bore one of them out enough to fit on the spindle tail, leaving just enough room for a grub screw to hold it in place.

Spindle pulley:
So let's bore it out. First, set it up, using 4 nuts to pack out the jaws - the steel belt guides prevent clamping directly, as they are pretty flimsy.

I need to open up the 8mm pilot hole to 1-5/8" (~41mm). 

This 25mm drill is the biggest I have.

Then it's a question of boring it out to size


Let's check it carefully

That looks pretty close

After cleaning off some of the crap and rust from the spindle tail, it slides on - just.

Encoder pulley:
The encoder has a 1/4" (6.35mm) shaft but the pulley has an 8mm bore. Time to make up a bush.


Spot on - it also provides the correct spacing of the pulley body from the encoder.

The encoder is a bit tricky to fit into the space available. It could either fit here....

...or here.

That's a convenient stud. I could replace the nut with a standoff. A plan comes together...

Mounting bracket:
But first, I need to make up a bracket for the encoder. This is some 1/4" loominum plate, chopped roughly to size in the bandsaw. I'll finish it later as it comes together.

Usual thing - drill....

....then bore out to size.

With a stepped bore, I can hold it in place with a couple of M5 screws. Then I can rotate the body to get the wiring to emerge where it's most convenient. 

It's tight in there but it looks almost workable. I can visualise a standoff in that gap to mount the bracket and allow belt tensioning adjustment...

Final assembly:
After some belt sander work on the bracket, we seem to be getting there.

That's pretty much it - just a bit of finessing with the belt sander and a carbide burr required. And yes, the cover DOES fit over the top of the gear train still. Just.

The cunning standoff concept worked out well. I have a female-female threaded standoff with 7/16" BSW (close enough to 7/16 UNC) at one end and M12 at the other. So it screws onto the banjo locking stud and allows the encoder bracket to be bolted to the other end as shown above. I can adjust the belt tension by swinging the bracket, although it hardly needs any as it turns out.

Finally, I will need to drill and tap both pulleys for a couple of M5 grub screws to finish the job off.

Grub screws and final assembly:

The placement of the grub screws is fairly critical, so best use The Shiz with the Renishaw touch probe to find the centre of the boss, then spot drill the hole position. 

Drilled through 4.2mm (M5 tapping) then counterbored 6mm before tapping M5. Sorted.

The spindle pulley has less meat (about 6mm), so needs a bit more thought. 8mm spot faced using a centre-cutting end mill, then spot drill and drill 4.2mm before tapping M5. Then a specially shortened grub screw (belt sander) to avoid contact with the belt. Nice.

So that's it all done and dusted. It goes together nicely, no contact / grinding bits. Cable tie to avoid the wiring getting digested by the gears.

Finally, refit the cover. Yes, it fits - just.

Job done!

Saturday, 13 February 2021

LinuxCNC homing sequences - setting up homing in Probe Basic Lathe


I got homing sort of set up using the PNCConf utility and copied the changes into the Probe Basic setup - simply by copying the resulting .hal file across. That's he advanage of using the same name for the .hal file as the one autocreated by PNCConf for the Axis version.

I found I had to invert the switch polarity to get homing to work when I copied the .hal file from Axis to Probe Basic. I also had to add to add the parameter value for this line in the .hal file...

setp hm2_5i25.0.encoder.00.scale [SPINDLE_0]ENCODER_SCALE going into the .ini file and inserting his line:

P = 0.0
I = 0.0
D = 0.0
FF0 = 1.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
MAX_OUTPUT = 2000.0

I guess PNCConf must have inserted that into the Axis .ini file, although the vast majority of the changes are contained within the .hal file.

To avoid LinuxCNC bombing out at startup. So it appears that the .ini file had to have that minor change made in addition to the .hal file changes.


Ho hum. But I have homing working wih Probe Basic now. However, there are 4 different schemes for the homing sequence and the various distances etc need to understood and set to suitable values. It's not difficult to understand in principle but you have to understand the naming and operating modes they have chosen to use before you can sensibly set values. So far I have been operating the microswitch whilst watching the GUI to figure out where to press and release it, mimicing the homing moves.

The homing sequences etc are defined here.


I don't plan to use the index pulse yet, so I should select one of the first 2 options.


So I need to set HOME_SEARCH_VEL and HOME_LATCH_VEL, as well as setting HOME_USE_INDEX to zero.

Each of the "Joints" has the following section:

HOME_OFFSET = 10.000000
HOME_SEARCH_VEL = -3.316667
HOME_LATCH_VEL = -0.500000
HOME_FINAL_VEL = 0.000000

How to set this stuff?


This variable has units of machine-units per second. The default value is zero. A value of zero causes LinuxCNC to assume that there is no home switch; the search stage of homing is skipped.

If it is non-zero, then LinuxCNC assumes that there is a home switch. It begins by checking whether the home switch is already tripped. If tripped it backs off the switch at HOME_SEARCH_VEL. The direction of the back-off is opposite the sign of HOME_SEARCH_VEL. Then it searches for the home switch by moving in the direction specified by the sign of HOME_SEARCH_VEL, at a speed determined by its absolute value. When the home switch is detected, the joint will stop as fast as possible, but there will always be some overshoot. The amount of overshoot depends on the speed. If it is too high, the joint might overshoot enough to hit a limit switch or crash into the end of travel. On the other hand, if too low, homing can take a long time.


This variable has units of machine-units per second. Specifies the speed and direction that LinuxCNC uses when it makes its final accurate determination of the home switch (if present) and index pulse location (if present). It will usually be slower than the search velocity to maximize accuracy. If HOME_SEARCH_VEL and HOME_LATCH_VEL have the same sign, then the latch phase is done while moving in the same direction as the search phase. (In that case, LinuxCNC first backs off the switch, before moving towards it again at the latch velocity.) If HOME_SEARCH_VEL and HOME_LATCH_VEL have opposite signs, the latch phase is done while moving in the opposite direction from the search phase. That means LinuxCNC will latch the first pulse after it moves off the switch. If HOME_SEARCH_VEL is zero (meaning there is no home switch), and this parameter is nonzero, LinuxCNC goes ahead to the index pulse search. If HOME_SEARCH_VEL is non-zero and this parameter is zero, it is an error and the homing operation will fail. The default value is zero.


This variable has units of machine-units per second. It specifies the speed that LinuxCNC uses when it makes its move from HOME_OFFSET to the HOME position. If the HOME_FINAL_VEL is missing from the ini file, then the maximum joint speed is used to make this move. The value must be a positive number.

That seems to be the background. I'll need to figure out the distances and speeds when I have the X and Z axes finally running.....

Wednesday, 10 February 2021

Setting up Probe Basic Lathe for LinuxCNC - and making config changes


Many of the GUIs available for LinuxCNC are pretty clunky. To be fair, they have often been designed by engineers rather than graphic designers. But the result is that many of them look like a spreadsheet or a tragic Powerpoint fail. 

The Pathpilot interface that Tormach developed around LinuxCNC is a pretty cool example of how it CAN be done. 

Recently, there have been a couple of interesting developments in the GUI department, such as the QtPyVCP interface, particularly the Probe Basic version. The installation info is shown on their website.

The Github repository contains the lathe version. So I managed to get this installed in minutes..... 

And.... then of course the penny dropped that this is a sim version only. In other words it will operate as a pretend machine on your desktop but there's no "real" version yet. If I'm to get this thing running my lathe, I'll have to mess about with the config files to connect my real world components (motors, switches, VFD etc). 

You might hope to get some support from the forum on this part but then you'd be forgetting that this is the LinuxCNC community we are talking about - they are focused on developing the features. While they may be generally supportive, you seem to need to have gone through a rite of passage before you can be engaged with fully and you also need to be fairly expert in Linux and the workings of LinuxCNC.

I posted a couple of times, asking for some guidance, hoping that somebody would explain what to do. Then I worked it out for myself - very LinuxCNC! The bottom line is that you can't use the PNCConf tool to edit the Probe Basic config. You have to do it yourself.

The resulting .ini file is posted on the forum in that link. In summary:

  • The .ini file defines the configuration parameters.
  • The .hal file lists the "connections" 
And to go from a sim system to a "real" system, you basically change the .ini file so that you are communicating with actual peripherals rather than pretend / simulated things. It's the .hal files that make the connections, so you essentially just change the .ini contents to point the installation at the Axis .hal files instead of the Probe basic (sim) .hal files. The .ini file hardly needs to change.

How to make config changes to Probe Basic Lathe?

So, once you've got your system sort of up and running, how would you make changes to the configs as you add more features and peripherals? Well clearly it isn't going to involve the PNCConf tool. There's only one way to do it really and that's to make changes to another installation and work out what has changed. Then make those same changes to the Probe Basic Lathe. 

I have a working system based on the default "Axis" GUI. This is supported by the PNCConf tool, so I can add my peripherals, configure Axis with PNCConf until it works and then compare the before and after versions to identify what has changed.

Here's what I found when I reduced the number of stepgens to 2, added "X limit all", "Z limit all" and "X Home" switches and configured the spindle encoder. I used Visual Studio Code to do a Diff (compare) and highlight the changes:

So I can easily see that I need to paste the following code in if I want to implement the spindle encoder:

# ---Encoder feedback signals/setup---
setp    hm2_5i25.0.encoder.00.counter-mode 0
setp    hm2_5i25.0.encoder.00.filter 1
setp    hm2_5i25.0.encoder.00.index-invert 0
setp    hm2_5i25.0.encoder.00.index-mask 0
setp    hm2_5i25.0.encoder.00.index-mask-invert 0
setp    hm2_5i25.0.encoder.00.scale  [SPINDLE_0]ENCODER_SCALE
net spindle-revs             <=   hm2_5i25.0.encoder.00.position
net spindle-vel-fb-rps       <=   hm2_5i25.0.encoder.00.velocity
net spindle-index-enable     <=>  hm2_5i25.0.encoder.00.index-enable

I'd never have figured that out. 

As for the limit and home switches I've just added, I can see I need to replace this section (which I think was unintended anyway):

# external input signals

# --- JOINT-SELECT-A ---
net joint-select-a     <=  hm2_5i25.0.7i76.0.0.input-00

With this:

# 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

And the X limit / home switches need this to be replaced:

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

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

With this:

# ---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

For Z, replace this:

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

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

With this:

# ---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

Well that seems to be reasonably straightforward. A bit of a pain in the arse but workable.

Saturday, 6 February 2021

Pulley slotting using Centroid Intercon conversational programming

I got a 5mm pitch timing pulley from some guy on ebay, ready to slide straight on the servo motor to drive the Z axis. That turned out to be a rookie mistake. I agree it appears to be 5mm pitch but it's not compatible with the HTD pulley and belt I got from Bearing Boys. Bollocks. So I got another one, this time from Bearing Boys.

The Z axis pulley is one of those "pilot hole" ones ie has only a 5mm or so pilot hole drilled through the centre, requiring you to drill / bore it out to suit your application. In my case, I need a 14mm bore with a 5mm key. I'll bore the hole in the lathe (manually of course!) and then slot it in The Shiz.

First, the boring work:

Setting up

Drill 12.5mm

Bored out to 14mm. Spot on....

"Snug" fit

Then the key part:

There's no point buggering about in Fusion to create a simple toolpath for the slotting operation. having said that, I'm not up to manually creating myself. Or even if I were, I expect it would take longer and be more fraught than using the Intercon conversational programming feature in the Centroid software. This seems like a good time to get reacquainted with it, having only used it a couple of times, some time ago.

You start out with a blank file and add operations using the forms they present you with. This looked like a good start:

Hmmph. That won't work. Requires some spindle rpm ideally. For that it seems you need to add a "spindle" line like this:

Then the "rectangular pocket" operation:

This is what it created:

; ICN_PATH = C:\intercon\Slot clearing.icn
; --- Header ---
N0001 ; CNC code generated by Intercon v4.50
; Description: Slot clearing
; Programmer: Muzzer
; Date: 05-Feb-2021
  M25 G49 ; Goto Z home, cancel tool length offset 
  G17 G40 ; Setup for XY plane, no cutter comp 
  G21 ; millimeter measurements 
  G80 ; Cancel canned cycles 
  G90 ; absolute positioning 
  G98 ; canned cycle initial point return 
; --- Tool #22 ---
;Tool Diameter =    4.0000  Spindle Speed = 6000
;4mm e/m carbide
  G49 H0 M25 
  G0 X0.0 Y0.0
N0002 T22 M6
  S6000 M3
  G4 P3.00 ; pause for dwell
  G43 D22
; --- Rectangular Pocket ---
N0003 X0.0 Y9.055 Z3.0 H22
  G1 G91 X0.0 Y0.0 Z-3.0 F100.0
  X0.0 Y0.0 Z0.0 F50.0
  X0.0 Y-1.555 Z-0.417 F100.0
  X0.0 Y1.938 Z0.0 F100.0
  X0.0 Y0.312 Z0.0 F50.0
  X-0.625 Y-1.125 Z0.0 F100.0
  G0 G90 X0.0 Y8.0 Z3.0
; --- End of Program ---
N0004 G49 H0 M25
  G40 ; Cutter Comp Off 
  M5 ; Spindle Off 
  M9 ; Coolant Off 
  G80 ; Cancel canned cycles 
  M30 ; End of program 

Looked good to me. What could possibly go wrong etc.

Off we go:

Check the key fits before removing the part. Nice.

Then drill 4mm and tap M5 for an M5 grub screw. First place the hole for the grub screw:

Use the same 4mm end mill to drill the hole:

All done. Slightly shortened (12.5mm, was 19mm) long key way.

Job done, fits together.

All I have to do now is order the correct length timing belt (325mm) to replace the 300mm one The Stupid Fat Bloke ordered. WTF was he thinking about?

How to add 7i85 board to 5i25/7i76 combo

Although I'm not quite ready to integrate my X and Z linear encoders with my LinuxCNC system, I have the 7i85 board already. I 'll n...