Engineer In Wonderland

CNC lathe: Big thanks to kind open-source folk

The cnc lathe project needs a controller to replace the 40 year old custom controller within the lathe.

EinW BSMCE04U STLink v2

It is a shame this has to be done, as it was capable of automated thread cutting, which appears to be the holy grail of home-build cnc lathes.

Find more on the cnc lathe project here


The in-built controller might even still be fully functional, but it was designed in the 1980s to work with a BBC Micro via a parallel port, and sourcing a reliable one of those, then buying the correct software, seems to be asking for trouble.


That said, Denford, the manufacturer of my lathe, continues to make educational cnc machines in West Yorkshire and is supportive of folk messing around with its older models.

EinW cnc control flow loRes

Information flow in a small cnc machine

Mine lathe is a Starturn (the original Starturn, not the ‘4’ or ‘8’) and I have bought a BSMCE04U (pictured) controller board to get it going.

This can be bought for under £20 and includes a 32bit STM32F103-derived processor plus opto-isolation on all the interfaces that need it.

BSMCE04U boards arrive programmed to interface via USB with much-loved Mach 3 software running on a PC – Mach 3 usually insists on a parallel port link to the stepper driver, but adding BSMCE04U (unmodified) allows this link to be USB instead.

I am not familiar with Mach 3, but am somewhat familiar with grbl g-code interpreter hardware.

Originally designed to run on Arduinos, grbl firmware takes gcode (machine control language) and turns it into control signals for stepper motors, a process which includes taking the physical dynamics of the machine into account. As such, the interpreter includes dozens of programmable parameters that represent the physical machine, such as how far the its mechanisms move in each direction for each stepper motor step, allowable maximum travel velocities and maximum accelerations.

Enter the first hero of this story, Terje Io, a software engineer who started grblHAL, one of the 32bit branches of original (8bit) grbl, and who has created a special branch of grblHAL for the BSMCE04U (scroll down to ‘Mach 3 USB BOB…’).

Io has also created a number of other significant open-source cnc programmes (find Terje Io’s GitHub here to view them), including one that automatically builds grblHAL to a users specification.

Forgive me and correct me if I have got this wrong, but as far as I know, grbl was started by Simen Svale Skogsrud, has been developed and maintained by Sonny Jeon, and together with Arduino-compatible hardware is the reason that today’s low-cost hobby cnc machines have been possible.

Io’s port of grblHAL onto BSMCE04U was popularised by Jim Fong in the blog Jim’s Embeddedtronics.

Following that blog, it was easy to put the correct pre-compiled grblHAL onto my BSMCE04U using a cheap STLink V2 clone (pictured) to do the programming (note, not all of the STLink V2 clones have the same pin-out on the 10pin connector end, despite looking similar externally).

It worked first go, without drama, which is why am writing my thanks to all the kind people above.

My board had a clone instead of a genuine STM32F103 – an APM32F103RCT6 from Apexmic (aka ‘Geehy Microelectronics’) – but the whole thing still worked. Fong’s blog includes helpful comments from folk who found ways to programmed versions of this board with a number of different F103 clones. My board, dated 2023, also had the desirable four-position programming port in which to solder a connector – some need a little more work.

I wanted to drive this using Io’s ioSender gcode sender software, but was not sure how to get it onto my PC, so instead used UGS (‘universal gcode sender’), another excellent open-source programme, this time by Will Winder).
Update: ioSender turned out to be easier than it looked – follow at this grbl blog – it does not install, but runs anew each time.

If automatic thread cutting is eventually to be a function of the little cnc lathe, the BSMCE04U will have to be replaced with something that can read an encoder that reports the live rotational position of the lathe chuck so that it can move the cutting tool in synchronisation.

Phil Barrat’s (Brockwood Design’s) T41U5XBB grblHAL gcode interpreter hardware can apparently do this after a couple of pcb mods, so that might be on a future shopping list if all goes well.

I have previously mentioned Barrat’s Raspberry Pi Pico-based grblHAL board, and he now also has one based around the Raspberry Pi RP2350 mcu chip – surely all the PIOs on that chip could be engaged t make a spindle encoder interface – if only I had studied software….

Anyway, before the grblHAL-ified BSMCE04U can be tried at all, time has to be found to remove thousands of tiny sharp brass chippings from, well, every moving part….

Steve Bush

Steve Bush is the long-standing technology editor for Electronics Weekly, covering electronics developments for more than 25 years. He has a particular interest in the Power and Embedded areas of the industry. He also writes for the Engineer In Wonderland blog, covering 3D printing, CNC machines and miscellaneous other engineering matters.

Leave a Reply

Your email address will not be published. Required fields are marked *

*