Photo: The infamous Blue Pill
A curve ball during the Gerbil Kickstarter production had been that the AVR328PB microcontroller (similar to Arduino AVR, but with 16 bits PWM) was unexpectedly sold out, world wide! It worked out okay after I found an alternative supplier and there was enough buffer in the Kickstarter to absorb the extra expense.
I decided to delve into the STM32 world and after 4000 pages of datasheets and some experimentation, I discovered that nothing actually worked despite having the right code. After studying up on ARM architecture and online posts, I realised that the user needs to switch on every single peripheral, peripheral bus, clock and glue these parts together via code.
The reason behind this complexity is that ST licensed the ARM cortex processor and built their infrastructure around it. In order to keep energy consumption and EMI to an absolute minimum, they decided that everything should be off by default. ST acknowledged the complexity their approach introduced, and tried to ease the configuration pain with the STM32cube software. While I had some success with it, it didn’t alleviate the burden of reading all the datasheets!
After getting some basic functions working, I started porting the Gerbil design to STM32. Mostly the old 8 bit Gerbil code had to be converted to 32 bits since there are more axes and limits switches to cover. The next challenge was that some functions appeared to be mutually exclusive - either my control lines or my limit switches worked, but not both. I’d stumbled upon an undocumented feature: a GPIO port can be configured to use the internal interrupts functions, but the config is not atomic. In other words, the new config overwrites the old one, so any configuration changes must repeat any configuration settings that need to be preserved.
Photo: my prototype controller
One of the fun aspects was 3d printing a model five axis CNC test mill – after all, I wanted to test five axis motion, but don’t happen to have a pricey five axis milling machine lying around… it turned out to be a great move, as it was light and easy to transport for demonstrations at local makerspaces.
Since feedback from those makers, I’ve been iterating on the PCB design and testing everything out. User testing has included spending a weekend with a clock maker to see his lathes and mill working with Super Gerbil. Another test case upgrading the Nomad 883 mill - Dan stripped out the original controller, and installed the Super Gerbil. The Nomad was originally a three axis machine, but now sports a new custom designed fourth axis.
I’m excited about the potential for community contribution, so will release the design after the Kickstarter. The Kickstarter goes live on the 6th of November at 8am US Eastern time and can be found here https://www.kickstarter.com/projects/2118335444/1112157454?ref=592500&token=88705198.
The DIY CNC Mill featured as my test rig can be downloaded from here https://www.thingiverse.com/thing:3204933 but beware still a work in progress.
With 64 Kb or 128 Kb flash memory (from which 41K used) there’s plenty of room to extend the Grbl ARM code. Two particular features I’d love to see implemented are:
- G76 Gcode command, for tapping and drilling cycles which makes manual drilling of PCBs and breaking the 0.6 mm drills a thing of the past.
- G80..G99 Gcode commands, for ‘canned cycles’ which allows easier Gcode programming, essentially like using nested loops within the Gcode. This would require some rework in the way Grbl parses and executes the G-Code. This is were you can make the biggest Open Source contribution to my Project. I don't know enough of taping and threading to ensure the correct implementation of these new add-on G-Codes so it...
I have added a STM32F103 driver to my grbl port/rewrite (grblHAL) that, amongs a number of extensions, supports most of the canned cycles. IMO threading and/or tapping is not possible to implement on this processor due to the limited number of timers and GPIO lines - but perhaps doable if a second MCU is added to the design...