grblHAL on a Teensy 4.1

PhilB

Well-known member
grblHAL is an open source motion control system for CNC machines like mills, router, lathes, laser cutters and anything that uses stepper motors or servos. It is the 32-bit version of Grbl that originally ran on 8-bit Atmel based Arduinos. It runs on a number of ARM chips including the iMXRT1062 on the Teensy 4.0 and 4.1.

But, you don't need a CNC machine or even a breakout board to try it out. You can use it on a barebones (aka naked) Teensy. You don't even to build grblHAL from source - I have made a number of prebuilt binaries the Teensy 4.1 available on github. If you want to try building grblHAL, the source code is here. Instructions for building it are available in the Wiki.

I have a blog post about how to bring grblHAL up on a Teensy 4.1.

Pin assignments:
Pin Assignment.jpg
 
Hi Phil, first up great work on what you have done so far, I have a friend that bought your boards and gave me the heads up on grblHAL.
I am looking to migrate to something else from Linuxcnc, I think this is the way I will go.

I will surely have more stupid questions in the future but for now, is it likely in the future that grblHal will have a servo fault input?
I can do this in hardware easily by tying my servo fault from the drive to the estop loop in cabling so I am not too worried about it.
What happens with the safety door input? Does the machine pause or move to a set position if its running gcode? This could possibly be tied to a servo fault as if I don't have a door switch I will know what is going on.

Cheers.

Russell.
 
Hi Phil, first up great work on what you have done so far, I have a friend that bought your boards and gave me the heads up on grblHAL.
I am looking to migrate to something else from Linuxcnc, I think this is the way I will go.

I will surely have more stupid questions in the future but for now, is it likely in the future that grblHal will have a servo fault input?
I can do this in hardware easily by tying my servo fault from the drive to the estop loop in cabling so I am not too worried about it.
What happens with the safety door input? Does the machine pause or move to a set position if its running gcode? This could possibly be tied to a servo fault as if I don't have a door switch I will know what is going on.

Cheers.

Russell.

I see no evidence of stupid questions... In fact, your servo questions are insightful.

There may be a servo error input added to grblHAL in the future though there are plenty of ways to handle it now - 2 of which you noted.

Using EStop input works fine. I encourage you to allow an EStop switch to work as well. Not having an emergency stop capability on a powerful machine is bad practice. I wrote a blog entry about EStop.

Door Open input is a good solution though has some semantics you will need to understand. When the Door Open signal is de-asserted, the machine will resume running the GCode program. The sender application will tell you door is open.

Unused limit switches could be used though that has implications for Homing. The sender will only say there was a limit trigger.

This gets a bit messy when you throw in Normally Open vs Normally Closed outputs from multiple servos (wire parallel vs series). Plus, currently it only handles open collector/open drain outputs. It is possible to support logic/push-pull outputs with a wee-bit-o-circuitry.

You aren't the first person to ask about servos and several of my customers are using the Door solution.
 
Thanks for the quick reply.

I will definitely keep using traditional estop circuitry, I use an estop contactor that simply drops out power to all servo drives and spindle drive. I'm not worried about losing machine position, had a job recently where Linuxcnc was generating an internal following error and faulting on position error (I am using step/dir servo drives) and had to restart the job at least 10 times before I found what was wrong, I just re-home and restart.

In my experience the panic button is best used when bad things are happening, usually a servo drive will generate a following error in that situation anyway as well so if they are linked together that's fine with me, I'm sure Ill work out what happened.

I live in a wet tropics area and this time of year we get high heat and humidity which kills my shed PC's on a regular basis so I am looking to move away from traditional PC based control, or at least make it far easier for PC replacement.

Cheers.

Russell.
 
I've run into that. It is a candidate for the worst error message ever. Developer wall of shame material. Easy fix though the error message does absolutely nothing to point you in the right direction. When using the Arduino IDE to install a zip library, the zip file has to be outside the Arduino directory tree.

It's documented somewhere but still pretty obscure. I don't understand why it should be a problem at all.
 
I have been using grblHAL on a Teensy 4.1 with a breakout board that @PhilB sells on Tindie, since mid December 2020. I used it to replace LinuxCNC to drive a parallel port CNC controller box that I originally made about 10 years ago. The GRBLhal breakout board is hardwired to the parallel port interface, no other changes were necessary. It works well. I purchased the board with my own funds and I have no business relationship with Phil other than as a satisfied customer.
 
I have been using grblHAL on a Teensy 4.1 with a breakout board that @PhilB sells on Tindie, since mid December 2020. I used it to replace LinuxCNC to drive a parallel port CNC controller box that I originally made about 10 years ago. The GRBLhal breakout board is hardwired to the parallel port interface, no other changes were necessary. It works well. I purchased the board with my own funds and I have no business relationship with Phil other than as a satisfied customer.

Thanks for the kind words, Mark. Always happy when someone gets up and running.
 
I've tried building grblHAL for Teensy4 Arduino project and keep getting errors relating to LwIP. Specifically it can't find the headers lwiopts.h, opts.h etc. I'm assuming LwIP is not installed correctly. I have downloaded a couple of versions but what should I be using and where should it be installed. I've added the libraries through Arduino but still no luck in compiling. Can somebody shed some light on this please?

Rgds,
Peter.
 
I've tried building grblHAL for Teensy4 Arduino project and keep getting errors relating to LwIP. Specifically it can't find the headers lwiopts.h, opts.h etc. I'm assuming LwIP is not installed correctly. I have downloaded a couple of versions but what should I be using and where should it be installed. I've added the libraries through Arduino but still no luck in compiling. Can somebody shed some light on this please?

Rgds,
Peter.

What does the build output say about the library? That may contain some clues.

When you installed it, did you use "install from zip file?" for the networking libraries? If that is the case, then you need to make sure the zip file is not in the Arduino directory structure when you do that.
 
Thanks PhilB, No zip in the Arduino directory structure but I believe it was a problem with the folder structure of the LwIP package I installed. I just downloaded the QNEthernet library, installed it and now grblHAL compiles for me under Arduino 1.85 . What is the recommended LwIP package. What are you using?

Rgds,
Peter.
 
Hi Phil-

New user here. I'm using the Teensy 4.1 on your breakout board w/ ethernet. I'm still building the actual machine, but everything on the Teensy side looks and is working great! Thank you for all of your work!!

I'm wondering if it is possible to have the commands that are received on ethernet echoed over the I2C or the Ser1 header. I'm experienced with designing my own embedded systems using PIC microcontrollers and MPLABX, but the arduino ecosystem is absolutely new to me. I'll figure it out, but I wanted to first see if it is something that is already implemented, or if there is a reason to avoid doing that. I'm basically going to receive the information with a PIC and print the gcode on a local display at the machine.

Thanks again!
-Daniel
 
Hi Phil-

New user here. I'm using the Teensy 4.1 on your breakout board w/ ethernet. I'm still building the actual machine, but everything on the Teensy side looks and is working great! Thank you for all of your work!!

I'm wondering if it is possible to have the commands that are received on ethernet echoed over the I2C or the Ser1 header. I'm experienced with designing my own embedded systems using PIC microcontrollers and MPLABX, but the arduino ecosystem is absolutely new to me. I'll figure it out, but I wanted to first see if it is something that is already implemented, or if there is a reason to avoid doing that. I'm basically going to receive the information with a PIC and print the gcode on a local display at the machine.

Thanks again!
-Daniel

It is possible if you are willing to modify the grblHAL software. UART1 is available and fairly easy to use. I suggest you ask that question on the github discussion page for grblHAL

However, if you just want confirmation that the GCode block (aka line) was consumed by the motion controller, you could use ioSender. The Program tab of the Main display area will show the lines that the motion controller has accepted as well as mark any errors. If you are getting garbled comm, it will show up as errors. Here's a walkthrough of ioSender.

Finally, if you are writing your own code to send GCode to the motion controller, there is feedback that you can look at. Check the above linked discussions section.
 
It is possible if you are willing to modify the grblHAL software. UART1 is available and fairly easy to use. I suggest you ask that question on the github discussion page for grblHAL

However, if you just want confirmation that the GCode block (aka line) was consumed by the motion controller, you could use ioSender. The Program tab of the Main display area will show the lines that the motion controller has accepted as well as mark any errors. If you are getting garbled comm, it will show up as errors. Here's a walkthrough of ioSender.

Finally, if you are writing your own code to send GCode to the motion controller, there is feedback that you can look at. Check the above linked discussions section.

Great! Thank you for the info, and the quick reply!

-Daniel
 
Hello,

Its been a while since I've used the Arduino IDE. I'm trying to install grblHAL per the directions here: https://github.com/grblHAL/core/wiki/Compiling-GrblHAL

I do not have a prior Arduino library in the Arduino library directory.

I've downloaded "core" and "iMXRT1062" as ZIP files from Git here: https://github.com/grblHAL/core and here: https://github.com/grblHAL/iMXRT1062

When I use Sketch/Add Library on core, it installs. But when I do the same for iMXRT1062 the IDE gives an error that no valid libraries are in the ZIP file.

I'm sure it's something stupid, but I can't figure it out. Any help would be greatly appreciated. Thanks.
 
The source zip file can't be in the Arduino directory tree. Move it outside the tree and try again. The error message ranks up as close to the all time worst ever. That it has not been fixed is a mystery to me.
 
I wasn't aware it was in the Arduino tree -- unless there's a looser definition of that than I know.

I created a new directory for the ZIP files in the root of an extra drive on my PC. I generally use this extra drive for data storage for programs, but install all programs on the C drive.

I also tried downloading them into yet another new directory. Also, when I examine the contents of the iMXRT1062-master ZIP file, I cannot find any files named "library" until I get to the grblHAL_Teensy4 directory.

If I understood these 2 files better, I think I could just treat the whole thing as a Sketch with many source files. Is it the case that iMXRT1062-master and the core-master files can be merged under one directory? At that point, I could just either rename something to an INO, or create an INO file. What do I not understand about that?

I appreciate your help.
 
Last edited:
Is the iMXRT1062-master ZIP file supposed to contain a library file?

No matter where I place this ZIP file, Arduino insists it has no valid library.

The only thing in my Arduino/libraries directory is a readme text file.
 
Phil, Any chance you have the eagle files for the latest board? I found the schematic on Github and was able to import into easyEDA, but could not find the actual eagle board file. I use JLCPCB all the time and would love to get this setup in EasyEDA for anyone to order it. I just ordered 5 test boards using the gerber files you had and the total for bare boards was $21.52 shipped to my house!! And the crazy part is that I will have the board in less than a week usually. Great work by the way, I want to upgrade my CNC with this ASAP!!!
 
I see this an old thread and hopefully this question is appropriate. I am very novice to the whole Teensy and arduino capabilities and I possess none of the coding expertise.
I want to run three steppers that are not configured in a true three axis configuration. They will be feeding three parallel elements. I have built a table of values in revolutions per input setting. I don't think it matters if the machine thinks it's dealing with a 3 axis machine as they would just be numbers?
My question is will the canned software take user define tables?
Thanks,
Tony
 
I see this an old thread and hopefully this question is appropriate. I am very novice to the whole Teensy and arduino capabilities and I possess none of the coding expertise.
I want to run three steppers that are not configured in a true three axis configuration. They will be feeding three parallel elements. I have built a table of values in revolutions per input setting. I don't think it matters if the machine thinks it's dealing with a 3 axis machine as they would just be numbers?
My question is will the canned software take user define tables?
Thanks,
Tony
Sorry for taking so long to reply, didn't see any notification (broken in the SW switch?).

No, grblHAL doesn't take tabular input. However, you can load a GCode file onto an SDCard and run it from there. GCode is probably a better solution than setting up a bunch of tables in code. You can modify them without recompiling and have a lot of control over acceleration, speed (feed rate). Your stepper revolutions can be set up as a distance and you can set up the steps/mm in settings to make it work the way you want.
 
Back
Top