Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM discussion #67

Open
chamnit opened this issue Dec 15, 2016 · 314 comments
Open

ARM discussion #67

chamnit opened this issue Dec 15, 2016 · 314 comments
Labels

Comments

@chamnit
Copy link
Contributor

chamnit commented Dec 15, 2016

Freely discuss your opinions on an ARM platform for Grbl, moving forward after v1.1.

@alpharesearch
Copy link
Contributor

I think Grbl success is partly to the fact because of standardising on Arduino. It it easy to get an Arduino all over the world. This allows for easy entry with Grbl.
So my question is what board with the right hardware fits the bill for the future. I didn't spend much thought on this yet, but i was interest if someone has any good idea.
Like the Teensy 3.5/6, however these boards are not FOSS as far as I understand. This may be an issue for some people. The Arduino Due is only M3 and @Strooom suggested to use something with M4F for faster floating point math.
I just think it would be good to have one common platform at first to develop and test and know this works.
The next question is how easy is it to connect this to stepper drivers end stops buttons displays etc pp.

@chamnit
Copy link
Contributor Author

chamnit commented Dec 15, 2016

There have been a lot of questions about what Grbl is going to do and how it'll move into the ARM world. Several dozen in the past and again just today from (@alpharesearch and @Strooom). I think it's time to start publicly talking about Grbl's long term strategy now that v1.1 is finally out.

I have an extremely strong feeling against monolithic processor models with a very large codebase, supporting everything on one chip. This does two things:

  • Even if its designed to be modular, it's much more difficult to port the code to another processor, whether it be newer, faster, better, or has a new built-in technology.
  • You constantly have to worry about breaking something or screw with the critical timing of the core motion processes. This is a headache I'd like to avoid and is the main reason why I've never accepted pull requests.

To improve the core motion control problem that everyone wants, it's critical to retain tight control of what the processor is doing at anytime. So, I think Grbl should remain somewhat independent of the noise and provide just a set of high-bandwidth communication methods to it, not just USART serial. This will allow Grbl to continue developing the hard motion control problem.

As for what processor gets used by Grbl ARM, personally I don't think it really matters. Here's why:

  • Grbl, on a slow 16Mhz 8-bit 328p processor, runs great for a vast majority of CNC applications and then some. The new laser mode has been reported to do raster jobs with 0.1mm pixels at a rate of 700 pixels/sec. I've heard a report that Smoothie on a 32-bit ARM 100MHz Cortex M3 can only do 0.5mm pixels at a rate of 500 pixels/sec. I know that it's not quite apple to apples and just one data point, but I was quite surprised that Smoothie isn't running at least 10 times faster. It seems like it's only a minor speed improvement.
  • If Grbl's code is that efficient, Grbl should run on any ARM processor selected and run very well on it. Even if Grbl uses a much cheaper Cortex M0 processor, it is theoretically 4x-10x times faster than the 328p. If Grbl on an M0 can just be 2x-3x faster in real-world performance, this can still address a nearly all of the CNC needs now and in the future.
  • With my experience as a researcher, developing fast and efficient code and algorithms always trumps using a faster processor. I think Grbl on an M0 will be fine. Grbl on an Cortex M4F could be way overkill.
  • If Grbl ARM is written to be small, portable, and independent of peripheral support, the processor selected shouldn't matter. It should be easily portable by design to a Cortex M4F if needed or to any manufacturer.

@alpharesearch : I totally agree with you that Grbl is successful because of the easy of trying CNCing with an Arduino and being able to compile custom or new versions easily through the IDE. I think the Teensy is a good platform, but isn't that great for OEMs due to the bootloader issue. This is why I'm targeting the SAMD21 Cortex M0 series. In my tests, it's more than adequate for everything I intend to do in the short term. It retains the core principal of keeping Grbl easily accessible due to the increasing popularity of the platform.

As for supporting peripherals, I think this really needs to be a separate community project, MIT-licensed, and on a separate MCU directly connected to Grbl ARM as a co-processor model. This will bring in the interest and the help of OEMs and allow users to help out with the project. There is no worry about breaking the motion controller timing and critical processes. The co-processor idea isn't anything new, but I think it really needs get rolling and be officially supported.

@usbcnc
Copy link

usbcnc commented Dec 15, 2016

I have done initial porting of 1.1e to stm32F103RBT6, it can be viewed here https://github.com/usbcnc/grbl.
The spindle control porting should be done next week. (I am a little busy this week).
It does use USB VCP. It does run on my desktop CNC 3020.

I use free coocox IDE to compile and program (STlinkV2).
I am new to CNC and cannot judge the performance difference. I will be more motivated if more people are interested.

@Strooom
Copy link

Strooom commented Dec 15, 2016

@alpharesearch I think the succes of GRBL is due to:

  • good performance on a standard Arduino Uno, which is cheap and available
  • running very well on a wide range of HW, due to plenty of configuration settings

Still, I think it makes (IMHO) an entry-level CNC controller. After some years of experience, you may want something with more features and more performance :

  • more axis, more limit switches, 3rd order speed profile, larger buffers... (just to name some that I'd like).

As GRBL on an Arduino already does an excellent job at that entry-level, I think the ARM-version should go in the direction of that 'next-after-entry-level' controller. GRBL will still be there when you build your first machine..

When you are upgrading your CNC (or other machine) with this kind of controller, it only makes sense if you also upgrade your hardware. (motor controllers - spindle - bearings - ...) so in the total picture, the cost of the controller board is very small, and should play no important role.

@chamnit I agree that GRBL does a great job on the 16 MHz 328P, but (IMHO) this comes with a price of complexity of the code : in order to fit in the ROM/RAM/CPU-cycles, features are implemented in ingenious, smart ways, but not easy to understand and certainly not easy to modify or extend. Other examples are buffer sizes which are rather small, due to the limited resources on the Arduino (eg. its Rx buffer is too small for GCode maximum block size of 256 bytes). The move to ARM should (IMHO) also relax those constraints. By having 'plenty' of ROM/RAM/CPU I think the code could be more modular and simpler, with more people contributing to it.

I am not aware of Teensy bootloader problems: I program it via the Arduino IDE, I agree you need to manually put it in program mode - minor inconvenience imho.

About Teensy SW not being open - I am not aware of that either - would like more info on that. In general it is my opinion that the ARM sw libraries are better quality than the Arduino...

Thanks for this great discussion!

@Stroom, there is only one @Strooom :-)

@chamnit
Copy link
Contributor Author

chamnit commented Dec 15, 2016

@Strooom @usbcnc : Grbl ARM will not be a direct port of Grbl on the 328p. For same reasons that (one and only) @Strooom stated. Grbl's code is the way it is because of flash, memory, and speed constraints. You simply can't modularize things without effect any one of those. As for complexity, it's not complex to me! :) But don't worry, I plan on re-writing things to be of a more functional programming style so it's easier to test and port.

@Strooom : I hear you on all those things: more axes, higher order motion control, more inputs, and larger buffers. All of that can be accommodated on the SAMD21 series. There is a J-variant that has 64-pins. In the off-chance it isn't adequate, it'll be easy to port to STM or Freescale, as @usbcnc and others has already shown.

The plan has always been to be the LinuxCNC replacement at a minimum. Things like real-time feed hold and overrides needed to be figured out first. Which they now have. Higher-order motion control is next, along with more axes. The crux of the higher-order motion control problem has been solved already. Now it's implementation. A better streaming interface is already planned as well to remove streaming constraints, particularly at high data rates.

Like I said before, I don't accept pull requests in large part due to the sensitivity of maintaining a jitter-free step output without effecting performance. If a separate co-processor model is used and created, the host for Grbl (that would stream directly to it and support LCDs, joysticks, SD cards, Wifi, BLE, native USB, etc.) can be contributed to by everyone. There is no concern of breaking the motion controller with code alterations. You just have to maintain a stream of motions for Grbl ARM to execute. Like you said, the cost of the micro controller is nothing. So having one Grbl ARM controller and a Grbl Host controller is completely feasible and the right way to approach this problem for future proofing.

As for Teensy, Teensy's bootloader chip is proprietary and $8 a piece. This makes it very unfavorable for OEMs or hardware people, but it also protects the Teensy from out-right clones. I understand why Paul has this model, but it's not ideal for companies to use Teensy, which is why you don't see a lot of Teensy-based hardware.

Also, I still don't plan on using any Arduino or Teensy libraries, which Grbl never has. Things are being built on existing software frameworks from manufacturers that are not GPL based.

@alpharesearch
Copy link
Contributor

I was thinking more about a reference design (line the Arduino now) that just works for end users. I guess a plus would be if some of the existing components like stepper drivers can be recycled and other components like displays and buttons from other systems can be used. I just think it would be nice if people can use mainly off the shelf part and create a system with ease and quick.

@Strooom I think is Teensy HW is the only thing that is not open, but the SW should be all good. By the way I personally have no issues with that.

@chamnit if I look around for M0 and M4F development boards at mouser it looks like both have plenty of options and many are priced the same ($10-$40). Do you have a particular development board with M0 in mind?

@gerritv
Copy link

gerritv commented Dec 15, 2016

SAMD21 example is Arduino Zero. Sparkfun also has a SAMD21G board. The best example is Atmel SAMD21 Xplained board. It is inexpensive and has a J chip, with the full 64 pins. Also has a hardware debug interface on the board which makes it IMO the only choice for development.

Keep the drivers etc off the Grbl board. If you don't then you are stuck with whatever that design is. No changing pins, adding/altering interfaces etc. Keep your HW designs modular.

One thing to keep in mind is that ARM specifies the core cpu and a very few peripherals only. (e.g. interrupt controller). All the other stuff such as USB, I2C, SPI, Can etc is up to the chip vendor. And they all do that differently for the most part. Thus it is not enough to say M0 ARM, you need to pick a vendor to get the details.

@chamnit
Copy link
Contributor Author

chamnit commented Dec 16, 2016

So I spent some time today re-analyzing my decision for SAMD21 and did some benchmarks of the important metrics. While the SAMD21 is indeed at least 3 times faster than the 328p, I'm starting to have doubts again about it. It'll definitely work short-term, but it might be too short. I'll be stuck in another 328p situation. (Surprisingly the stm32F103RBT6 is only twice as fast as an SAMD21. Good but not great.)

This brings me back to the Teensy. There was a time I was committed to the Teensy 3.x series, but the bootloader issue was the main problem. Does anyone have a workaround for this?

@Strooom
Copy link

Strooom commented Dec 16, 2016

Teensy's bootloader chip is proprietary and $8 a piece

I was not aware of this.
From a personal point of view, 8$ looks justified. From an OEM point of view I understand it may be a problem.
I am a defender of the 'fair share' : for a long term success, all contributors need to get a fair share of the profits and credits. So when considering Teensy as a candidate for the future of GRBL, we need to discuss this with Paul Stoffregen and the top 5 'customers' (Carbide3D, Inventables, Openbuilds, ...)

It's a non-technical thing, but also important to get solved, and better to tackle it early.

@alpharesearch
Copy link
Contributor

I just try to understand the situation, please correct me if I have a wrong assumption.
As far as I understand using Teensy for development would at first would lock Grbl to Freescale Kinetis K64 ARM MCUs. The Teensy has a proprietary programming interface (is this a bootloader too?) that can be used with Arduino IDE. This allows for a easy entry for anybody that used Arduino before.
Do the OEMs create their own boards from scratch right now? What other programming interface/bootloader exists for the Freescale Kinetis K64 ARM MCUs (from my short google search it looks like there is a "FRDM-K64F: Freedom Development Platform for Kinetis K64, K63, and K24 MCUs" with open source hardware and bootloader)?
I would guess if OEMs have multiple options, include a original Teensy with their product or make there own programming interface/bootloader or use the FRDM-K64F design and bootloader.
I just noticed the FRDM-K64F board today for the first time, would this be a reference design option?

@Strooom
Copy link

Strooom commented Dec 16, 2016

@alpharesearch FRDM-K64F looks interesting. Will look into its spec over the weekend.

@109JB
Copy link

109JB commented Dec 16, 2016

It seems most of this discussion is in terms of what platform to use. As an end user, who is by no means as expert in programming, microcontrollers, etc, all I can say is that the means of uploading the Grbl firmware should be easy or I think you will be driving a bunch of potential users away. The current method of uploading via the Arduino IDE is super simple and user friendly. I am not saying that this method has to be the one, but something just as easy would be best. Perhaps once a platform is chosen, a simple interface for uploading can be created by one of the gurus here.

My only other comment about the platform is that it should have enough input and output pins to allow for future expansion. 4 or more axes, limits separate from home switches, spindle encoders, axis encoders, all come to mind.

As for non-platform specific enhancements for Grbl, My biggest vote would be for Spindle feedback for lathe threading and mill rigid tapping- Lack of ability to thread on a lathe makes Grbl almost useless on a lathe since threading is pretty common for lathe operations. On a mill this isn't as big a deal, but would definitely be a benefit. I believe this limitation sends a lot of potential users away for a couple reasons. People who have lathes don't want to switch back and forth the controller they use and so will chose something else like linuxCNC or Mach3/4, and then on their mills they are likely to use the same program rather than have to learn another one. Also, some people using only milling machines will also use them for lathe operations by mounting a chuck to the mill spindle. I do this myself from time to time. and it would be awesome to be able to sync and thread in that case too. This would of course require adding the feedback and also the G-code commands for threading.

@chamnit
Copy link
Contributor Author

chamnit commented Dec 16, 2016

Ok. I think I was jumping the gun a bit on the Teensy or an alternative to the SAMD21. I was reminded of a long term plan that makes the speed of the MCU not as important. However, I think it'd be wise to have the Teensy (or another faster MCU) as a backup. I'll make sure to decouple all MCU processes to facilitate this.

@109JB : As for number of pins, the SAMD21 J variant has 64 pins. Plenty for 4+ axes and limit pins. Even the normal G-variant has enough (38 I/O, 48 total), but they are often not all connected or used for dedicated SPI, USB serial, etc.

I hear you on the lathe threading. It's actually something pretty easy to do. Rigid tapping, on the other hand, is a little more difficult because you need a spindle capable of precise synchronized motions.

@Protoneer
Copy link
Contributor

Protoneer commented Dec 16, 2016 via email

@usbcnc
Copy link

usbcnc commented Dec 16, 2016

Program and debug on STM32 is very easy with STlink. It took just 2-3 seconds to erase and program 35KB flash. I always have STLink connected even while running GRBL.

I found, however, in order to DEBUG, the USB feature cannot be used. You have to have USART since USB re-enumeration will kill the debug session. (I normally use Win GRBL simulation to debug so this is not an issue for me).

There is a big family of STM32 from F1 to F4. I use coocox which is free IDE and it serves the purpose well.

@jahnj0584
Copy link

I think it might be time to specialize the use of GRBL instead of pleasing everyone. Lathe tapping, 4th axis, servos+encoders (isnt that just a hardware anyways that sends its own stop command?) are all pretty specific things that should use community made specialty plug-ins or something along those lines. If GRBL just did 3 axis control as well or better then mach 3 (which it almost is!) we'd have a very good firmware. Ive never ran into any issues yet where grbl was the cause of it in over my year of use (over 200 hours).

We should perfect grbl and its/a GUI software of choice for the UNO before switching rails to the specialty stuff that isnt so hobbiest in nature. If you are able to afford encoders, a 4th axis, spindle control + VFD I REALLY doubt a 50-200$ control board will be an issue as well. What about making your own GRBL board, like the tinyG after version 1..2 or whatever is next? More input pins for ground, spindles, relays, limit switches, door locks, maybe even auxiliary power/Lights , etc without just being another 20$ breakout board for mach.

@109JB
Copy link

109JB commented Dec 16, 2016

Lathe tapping, 4th axis, servos+encoders (isnt that just a hardware anyways that sends its own stop command?) are all pretty specific things that should use community made specialty plug-ins or something along those lines.

No they aren't. They have to be incorporated into the motion planner (Grbl).

Lathe threading requires that the axis motion be coordinated with the rotation of the spindle. The axis motion needs to slow down if the spindle slows down and speed up if the spindle speeds up.

Nobody said servos with encoders, but feedback from an encoder mounted on a stepper can be used to halt the machine if missed steps are encountered. Not a full feedback system, but a simple monitor. This can be done outside of the motion control, but can also be monitored inside which would be more robust.

If GRBL just did 3 axis control as well or better then mach 3 (which it almost is!) we'd have a very good firmware.

And lathe threading, rigid tapping, etc are reasons why more don't use GRBL. the motion planner is already there except for higher stepping rate which a faster MCU will take care of.

We should perfect grbl and its/a GUI software of choice for the UNO before switching rails to the specialty stuff that isnt so hobbiest in nature. If you are able to afford encoders, a 4th axis, spindle control + VFD I REALLY doubt a 50-200$ control board will be an issue as well.

GRBL for the UNO is maxed out. It has been said many times before. There is no more room. What GUI of choice? Grbl should still stay away from GUI development because GUIs are going to be a matter of choice. Also, who says a spindle encoder is expensive? How about 99 cents, which is how much an optical sensor costs that can do lathe threading. It is what I have on my lathe right now with LinuxCNC. I would love to switch my hobby lathe over to Grbl, but not without lathe threading.

I am a hobbyist and saving money anywhere means that money can be spent somewhere else, whether that is a 4th axis, or whatever. BTW, what exactly is not hobbyist in nature when it comes to a 4th axis or lathe threading. Many hobbyists use these features. Just because it isn't part of you hobby vision doesn't mean it isn't part of another persons. The cost of going to a board with a lot of pins is not an issue cost wise anyway, but an UNO number of pins just isn't enough.

If you want GRBL to compete with Mach3 or LinuxCNC, you have to support the things that they can do.

@gerritv
Copy link

gerritv commented Dec 17, 2016

I am a hobbyist machinist on fixed income (retired in 2007) so cost conscious. I would love to get lathe threading, full gcode (threading, drilling etc codes), and a way to slave a stepper to spindle so that when spindle rotates, the stepper moves as well, but with a selectable 'gear ratio'. This enables hobbing gears (yes you can make your own cutters), cutting helixes etc, things that I can't do on my manual machines.

As 109jb wrote, none of these things are expensive, thus well with reach of hobbyists. I don't want to run Mach3/4, been there. Also don't want to run Linux anything, been there. Grbl, on the Uno and on whatever is next are more than adequate for hobby and non-hobby use. You even get to choose the GUI you prefer as there is a large selection, supporting a broad range of machines from homemade routers to Bridgeport milling machines.

@chamnit
Copy link
Contributor Author

chamnit commented Dec 17, 2016

Thank everyone for the kind words. I do plan on expanding the g-code parser to fully support the remaining g-codes. I'll have to assess what makes sense, but likely remain on LinuxCNC's standard and first install canned cycles. There's just a lot more that can be done with the additional flash and RAM by (finally) moving away from the 328p.

@jahnj0584 : I may do something with hardware at some point, but it's too early. Some of the longterm development path is still a little undefined. I'd like to clear that up so the hardware will support it when the time comes.

@CreativeRobotics
Copy link

My first thought as I read this was the SAMd21 because it is being integrated into the Arduino product lineup but also because it can be flashed with a USB bootloader and implimented as a very minimal PCB with just a crystal, USB connector and voltage regulator. As a hobbyist this is very appealing because I can think of designing a custom board, or just using one of the boards from Sparkfun or Adafruit, and at very low cost.

I use GRBL for CNC milling at the moment so the speed enhancements with respect to laser cutting aren't a priority (but that may change) - my preference would be for extending GCode support, something that would be enabled with the extra flash and RAM on the D21, and for the option of an extra axis and a spindle encoder.

In terms of long term development, by basing it on the D21 and keeping it within the Atmel family of MCU's the peripherals set will be the same across the whole family of MCU's and I would also expect that some of the more powerful SAM devices based on M3 or M4 cores might appear as official Arduino products using a derivative of the SAMD USB bootloader - this would (I assume) provide an easier migration path away from the D21 whilst maintaining the out-of-the-box ease of use for customisation that comes from staying with 'Official' Arduino products and toolchain (As opposed to going with Teensy)

@Strooom
Copy link

Strooom commented Dec 17, 2016

@gerritv Gerrit, could you elaborate a bit more on why you prefer GRBL to Mach and Linuxcnc? Its important to identify those strengths and not loose them in the future version.

@CreativeRobotics
Copy link

@Strooom
Cost, Simplicity, platform independence:
For myself I like GRBL because it isn't tied to one OS like Linux and not everyone is a Linux user - I use Solidworks and CamBam for CAD and CNC work. Ultimately the only hardware that GRBL is tied to is the ATMega 328p. MACH is not free so for a hobbyist on a budget GRBL on an Arduino is a much better option.

@gerritv
Copy link

gerritv commented Dec 17, 2016

@Strooom Grbl means 1 less PC for me to feed and care for. Mach3 requires a parallel port, Mach4 requires an expensive (to me) external driver board which I am then locked into (can't use it with anything else). Linux I want nothing to do with anymore in any shape or form. Too many years with Unix, and too much manual messing about.
Grbl also provides me with choices of GUI, if I ever get into laser stuff then I can use an appropriate gui for that, etc.. For my current needs I use my GrblPanel, etc.

Lastly I am very impressed with Sonny's analytical approach to the implementation. I have been around computers, both hw and sw since 1965. It is not often that I see good product management and feature control combined with good design. Coupled with his approach to machine safety it is a great combination.

@109JB
Copy link

109JB commented Dec 17, 2016

Having used TurboCNC (DOS), Mach3 (Windows), LinuxCNC (Linux), and Grbl, here are the benefits and shortcomings of Grbl as I see it:

Benefits:

  1. Grbl offloads step generation to a platform that only does step generation and it does this at a very low cost. This is very important in my opinion and is the prime reason I even tried Grbl in the first place. I got to the point where I realized that external step generation was necessary and trying Grbl cost me $5 compared to getting a Mesa board setup for LinuxCNC at about $200. Options to do this are also available for Mach3 and other setups, but always at a much higher cost than Grbl. Generally $100-$200 more than the Arduino that runs Grbl. For me as a hobbyist, that is a significant cost.

  2. Since Grbl runs on an Arduino, the User interface can be on just about any platform, from another Arduino, a Raspberry Pi, a Windows, Linux, or Mac box, or whatever can send serial data. This allows using obsolete laptops, that would generally not be suitable for LinuxCNC or Mach. I currently use a free netbook to run my user interface for Grbl, instead of having to have a desktop PC, monitor, and keyboard.

Current Grbl Shortcomings (My view and in order)

  1. Lack of spindle synchronization for lathe threading, which is definitely a deal killer in regard to lathe usage.
  2. Only 3 axis, would like at least 4 preferably 5 or more
  3. No backlash compensation
  4. No cutter radius compensation (can be overcome to some degree with CAM)
  5. No native canned cycle support (I have canned cycles in my GUI so not as significant anymore)

@chamnit
Copy link
Contributor Author

chamnit commented Dec 17, 2016

@109JB : Your list looks remarkably like my short-term development path. :)

@p3p
Copy link

p3p commented Dec 17, 2016

It's nice to see you discussing how to move forward away from the 328p, Arduino has done some amazing things for hobby electronic projects but for the last few years it has seemed to be holding them back, Marlin Firmware (for 3D printers) are also in a transition phase to ARM.

ARM mbed OS5 is rather large, but can be cut down significantly through configuration to pretty much just the HAL, I'm still not sure it will have the performance or an acceptable footprint but I just I thought I would make sure you are aware of how far that project has come along and how many devices are supported, mbed-cli means it's not cloud based anymore which is a godsend. The main issue I still have with mbed is that "supported" is relative apparently.

I'm looking forward to seeing how this progresses.

@chamnit
Copy link
Contributor Author

chamnit commented Dec 17, 2016

@p3p : From what I can tell, most ARM manufacturers have a HAL through their software frameworks. I still don't know enough about them all to say how good or bad they are, but Atmel's ASF seems ok. Switching between Atmel MCUs looks to be straightforward, because they have plenty of examples to pull from. The NXP-Freescale Kinetis framework (Teensy) is very similar. Grbl's core doesn't use very many peripherals, just a few timer interrupts and some basic I/O. As long as this core is kept separate from everything else, Grbl ARM should be able to go to any platform and stay flexible for future developments.

@p3p
Copy link

p3p commented Dec 17, 2016

@chamnit ARMs mbed still relies on the manufacturers HAL, I guess its more of a HAL abstraction layer, but I agree that with the minimal use of peripherals in grbl core it wouldn't be worth the overhead, especially if you go with the grbl co-processor design and keep any extra interfaces separate (sdcard, ethernet ect)

@phil-barrett
Copy link

Yeah, 13 LED, rookie error. sigh.

Good point on the EEPROM. Does EEPROM Emulation as discussed in the PJRC Teensy 4 description page not work for you? I reworked the doc and added alternate pin assignments if any of the i2c channels were to be needed. One channel is on the back side pins

@phil-barrett
Copy link

phil-barrett commented Feb 13, 2020

oops, here's the doc
teensy 4 pinouts.pdf

I also added a "simple machine" definition. The goal is to ensure that people don't need to use the SMT pins in order to prototype a simple machine.

@coredump
Copy link

coredump commented Feb 13, 2020 via email

@phil-barrett
Copy link

Support for external EEPROM via i2c is also good, if possible to use both. There are some shields that are starting to add some i2c eeprom chips (I mean, I am adding one to my shield project, but I am sure there are others).

On Thu, Feb 13, 2020 at 11:52 AM phil-barrett @.***> wrote: Yeah, 13 LED, rookie error. sigh. Good point on the EEPROM. Does EEPROM Emulation as discussed in the PJRC Teensy 4 description page not work for you? I reworked the doc and added alternate pin assignments if any of the i2c channels were to be needed. One channel is on the back side pins — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#67?email_source=notifications&email_token=AAAM55IFZ2NBIZPIJWRM7GLRCV3D5A5CNFSM4CZY5V2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELVXSVY#issuecomment-585857367>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAM55PG2JS4NJHUNKLCRATRCV3D5ANCNFSM4CZY5V2A .

Yes, agree it's worth allowing. Plus I2C is a very useful expansion bus so having the ability for at least one channel is a good thing.

@phil-barrett
Copy link

I think I would be remiss if I didn't suggest that we might move this conversation to https://github.com/terjeio/grblHAL/ (or some other more appropriate venue). If no one cares, I'm fine continuing here.

@terjeio
Copy link

terjeio commented Feb 13, 2020

EEPROM emulation works, the easiest to add I have to say, but I am not fond of storing settings in flash. I am using the Arduino IDE for building so a fair bit of low-level code is already present, however I try to bypass as much as possible for speed.

Having an I2C port can be useful for other stuff too, my BoosterPack design has one with a level shifter for selectable 3.3V or 5V operation. Currently I use it for a keypad (jogging etc) and for communicating with the ATC I am experimenting with.

Is anyone prepared to do some testing?

@coredump
Copy link

@terjeio I am getting a Teensy 4 delivered tomorrow, but I don't have a machine hooked up yet, but I want to test anyway

@phil-barrett Maybe there's a forum or Discord or something? This issue became the best place to learn about GRBL/others running into ARM/modern MCUs

@phil-barrett
Copy link

phil-barrett commented Feb 13, 2020

@tereio I will do some testing for sure. Not on a real machine right away but have bits and pieces I can cobble together to at least see it running steppers and various inputs like limits and such. I've got too many projects going to switch my machine over right now. I've been planning a rebuild of the electronics so can do some real machine testing at that point and I'll want to make a break out board for it. Probably weeks away from a real test.

I believe Paul at PJRC has EEPROM emulator for teensyduino. It really is a very high quality Arduino IDE add on.

And, I want to say, thanks for doing this. I really do appreciate your efforts.

@terjeio
Copy link

terjeio commented Feb 13, 2020

I need a few days before I can commit a driver to my gitHub account. Discussion can then move over there.

Major bits still missing are input signal handling and native USB > serial.

@justinclift
Copy link

justinclift commented Feb 13, 2020

Maybe there's a forum or Discord or something?

Under the "Controllers" category on MakerForums is probably a decent place:

    https://forum.makerforums.info/c/controllers/99

There are several GRBL projects already on there (AVR, LPC, ESP32), so it'll be in good company. 😄

@terjeio
Copy link

terjeio commented Feb 14, 2020

Driver for Teensy 4.0 is now up.

EDIT: info for speed freaks - stepper isr execute time is 250 - 400ns...

@jrbe
Copy link

jrbe commented Mar 5, 2020

I agree with the thinking that grbl was successful because it started on standard hardware. Now that it is successful it can reach further out if the hardware is solid.
If a group got together (or an individual) designed a great open source board with either an arm chip built into it or a socket for a teensy and made Gerber and assembly files available for anyone to have boards made this could jump start the next chapter of grbl. It would likely get cloned but it would be more about opening the doors for expanding a new direction for grbl and more powerful tools / hardware to run different cnc's.
KiCAD or other open platforms and JLCPCB or other board houses once covid19 let's up.
My jumbled wish list: silent stepper drivers, power loss resume capability, laser, spindle, coolant, thc, limit switches for all, USB, Ethernet? display, offline controller.

@phil-barrett
Copy link

phil-barrett commented Mar 5, 2020

I agree though would add the most important need is a binary distribution based on a standard pinout so people don't need to install Arduino to build the binaries.

Terje's GRBL/HAL is very capable and runs on a broad number of ARMs. The Teensy 4 (imxrt1062) port is working pretty well. Needs more testing - which I have been doing on my board - GRBL Teensy 4. People are welcome to use it. I've placed a version on OSHPark but honestly, it's cheaper and faster to go JLCPCB or others. They built my first batch of PCBs and did a good job - 6 days from start to finish, last week. 10 boards for $22 USD. I intend to release it into Open Source once finished and will provide full gerbers. There is a pinouts document in the repository that defines the Teensy 4 pinout scheme for GRBL/HAL. As a starting point, at least. The Teensy 4.1 is coming and will be able easily support a 5 axis machine.

I have a couple other designs that work with other processors - I am getting ready to fab a MKRZERO version though it's limited pin count means it will be for a fairly small machine.

@jrbe
Copy link

jrbe commented Mar 5, 2020

Phil, that's great! Thanks for this!
I had struggled finding a pin out for teensy / grbl/hal.
Where I've struggled in general is trying to Google all of this grbl stuff. One thing I haven't found is a wiki for any next step grbl stuff. A wiki is extremely helpful in reducing the step learning curve of something like this. If there isn't one yet my preference would be a visible to all Trello board sort of like this, https://trello.com/b/BKAcXAzq/wiki that way all of the how to info is in one place.
If the boards have a USB or maybe Ethernet a loader program could be made like, https://speeduino.com/forum/viewtopic.php?f=13&t=2547 to eliminate the arduino stuff and could also hunt down available code versions for the user.

@paulvdhoeven
Copy link

It's been a while since I last checked in here (or used my own CNC).
Recently I stumbled upon BigTreeTech, which is a Chinese company which loads its board with (custom?) versions of GRBL.

If you have a look at for example: Bigtreetech Skr V1.3 3D Printer Board 32Bit on Aliexpress:
https://nl.aliexpress.com/item/32981807406.html

It's hard to compete as a hobby with such prices. USD17 for a board with a LPC1768. (Without stepper motor drivers).
Bigtreetech seems to be a fairly Open Source friendly company. They make (and sell) lots of boards and have their own github repo's:

https://github.com/bigtreetech

They also have boards with STM32F407ZGT6
Some boards seem to have "Marlin", others with "GRBL".
Documentation seems fairly complete, though I have not tried to compile or flash such a board.
On first sight it seems to be a more cost effective and much neater solution than building something around the "Teensy's".

I accidentally bumped into this company on Aliexpress and bought a "TFT 1.5-V2.0" from them, just because it was about the cheapest PCB with both an TFT with touch screen and STM32F103VCT6. I have not powered the board up yet.

@phil-barrett
Copy link

I did not see a GRBL board there. The company looks very focused on the 3D Printing market with Marlin support. It would be possible to port GRBL to those boards and there may be a port out there. There is no question that "China Inc" can produce very low cost products. For CNC, I want something focused on that rather than a repurposed 3D Printing controller.

@langwadt
Copy link

langwadt commented Jul 8, 2020

I run grbl on a bigtreetech board with an STM32F407 and TMC5160 drivers

@phil-barrett
Copy link

did it come stock or did you have to load it yourself? which grbl variant are you using?

@langwadt
Copy link

langwadt commented Jul 8, 2020

my own port of gbl-mega

@paulvdhoeven
Copy link

SuperGerbil: Another STM32F103C8T6 fork.

While researching info to put an STM32 fork of Grbl on a (probably clone, you know, "China"...) I bumped into SuperGerbil (3D printer board with 5 step-sicks) and MiniGerbil. (For laser engraver with 2 step-sticks).

It's also STM32F103C8T6 and it was a kickstarter in 2018.
These boards were made from the start to be shipped with GRBL and they have their own fork on github.
They're also on Hackaday, and there you can read a nice overview for the motivation that got SuperGerbil started.

https://supergerbil.com/
https://awesome.tech/sg-board-configuration/
https://www.kickstarter.com/projects/2118335444/automate-anything-with-super-gerbil-cnc-gcode-cont/comments
https://github.com/paulusjacobus/SuperGerbil
https://hackaday.io/project/162136-super-gerbil-the-stm32-based-gcode-controller

@jerseyguy1996
Copy link

Has anyone ever considered using the Adafruit Feather/Metro M4 products for running GRBL? I'm an awful programmer so I wouldn't even know the steps involved in making GRBL run on different platforms. Is it a huge lift?

@paulvdhoeven
Copy link

The ATMEGA's are a bit strained for GRBL, but apparently lots of folks are still happy with them, but I never bothered.
I only have experience with the STM32F103C8T6 (aka "Blue Pill"). It has about 4x (or more) the performance of the AVR chips and it also has a real USB port built into the chip, so no fussing with baudrates because those just get ignored by the drivers. It "just works" for me (on my Linux box).
grblHAL (mentioned above) may be worth looking at. It apparently has ports for lots of variants (SAMD, LPC, STM32, ESP32, Teensy).

GRBL already runs reasonably well on the old AVR's and all those mentioned above are much speedier. I am very doubtful that the fast Teensy 4 has any benefit for GRBL.
I do not know if a serious attempt of streamlining has been done for the uC's above, or if they are just straight code ports. Even without making use of DMA and multiple ISR levels on more modern CPU's, the 4x raw performance boost seems to be plenty to not have to bother with such things. If GRBL gets more functionality (S-curve acceleration, toolpath offset or other fancy features) then making more use of hardware features of a particular uC may get more useful, but as of now it probably don't matter much which one you pick.

If you don't want to fiddle with firmware yourself, then I recommend to just buy a board with GRBL already installed.
BigTreeTech is apparently a company who makes such board, and they seem pretty Open Source Friendly.
https://html.duckduckgo.com/html?q=bigtreetech+grbl

@phil-barrett
Copy link

phil-barrett commented Jan 25, 2021

Check out grblHAL. It runs on a variety of ARM processors. It was designed to be portable via a Hardware Abstraction Layer (thus, grblHAL). The big advantage is that all the processors specific code is isolated to basically one file and you don't need to know much about how grbl works. Unfortunately, the SAMD51 is not currently supported.

If you are looking for a 5 axis breakout board and don't mind using a Teensy 4.1 (600 MHz, ARM M7), then take a look here. The cost of the extra speed is marginal.

@terjeio
Copy link

terjeio commented Jan 25, 2021

Has anyone ever considered using the Adafruit Feather/Metro M4 products for running GRBL?

I just took a peek at this board, IMO this is not a good target for anything but a basic grblHAL driver due to the limited number of pins brought out. Not worth the effort even if it is a very capable processor?

I am very doubtful that the fast Teensy 4 has any benefit for GRBL.

That depends on your application. E.g. if you want to do high speed laser raster engraving then I have managed to sustain > 70000 mm/min feed rate with a T4.1 (planner buffer size @ 1400 entries). For that a fast CPU and plenty of RAM is required.
grblHAL supports a growing number of plugins, a processor such as the STM32F103 with its limited amount of flash and RAM does not allow use of a number of these.

BigTreeTech is apparently a company who makes such board, and they seem pretty Open Source Friendly.

grblHAL has driver support for that too, Trinamic support is work in progress.

@phil-barrett
Copy link

phil-barrett commented Jan 25, 2021

GRBL already runs reasonably well on the old AVR's and all those mentioned above are much speedier. I am very doubtful that the fast Teensy 4 has any benefit for GRBL.
I do not know if a serious attempt of streamlining has been done for the uC's above, or if they are just straight code ports. Even without making use of DMA and multiple ISR levels on more modern CPU's, the 4x raw performance boost seems to be plenty to not have to bother with such things. If GRBL gets more functionality (S-curve acceleration, toolpath offset or other fancy features) then making more use of hardware features of a particular uC may get more useful, but as of now it probably don't matter much which one you pick.

It isn't that simple. The newer ARM based boards (iMXRT1062 in the Teensy included) have faster speed, larger flash and ram and more pins. grblHAL supports up to 6 Axes (my Teensy board supports 5) and lots of new features via plug-ins like TerjeIo said. The cost of the additional performance and space is pretty much marginal. You may be overpaying by pennies for the extra performance.

And, I think it worth pointing out that the Blue Pill is not a very good example of a "cheap" processor as it is inconsistent in quality and features. The likelihood of getting a Blue Pill with an actual STM processor is pretty low - 6 different fake STM32F103 chips have been identified. Plus, unlike the Arduino, Teensy, Feather, Pico et al, there is no real definition of Blue Pill hardware - you are at the mercy of the vendor's suppliers. Blue Pill is a classic "race to the bottom" scenario. Personally, I think basing a breakout board on a Blue Pill would be a nightmare but if someone feels strongly about they should absolutely do it. grblHAL runs on the STM32F103.

@paulvdhoeven
Copy link

I've also run about 7000mm/min on a "Blue Pill" on my CNC, which has 2Nm closed loop Nema23 steppers and a 1605 ball spindle and microstepping. GRBL is set for 640steps/mm.

$$
$0=10
$1=0
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=0
$23=3
$24=25.000
$25=500.000
$26=250
$27=1.500
$30=24000
$31=400
$32=0
$100=640.000
$101=640.000
$102=640.000
$110=4000.000
$111=4000.000
$112=4000.000
$120=300.000
$121=300.000
$122=200.000
$130=200.000
$131=300.000
$132=300.000

I reduced the maximum speed and acceleration partly because the steppers loose most of their torque at those speeds, but mostly because those fast rapids are too fast to push the emergency stop button if needed. bCNC also does quite a good job in minimizing rapids, so the issue is no big issue anyway.

7000mm/min = 116.67 mm/s
116.67 *640 = 75kHz

I'm not sure, but I think I did tests up to 8000mm/min and it cropped out about there. I don't know if it was because of the stepper motors + drivers, or because of the STM32F103C8T8. I have not taken any measurements to diagnose, just dialed the settings back.

I have not used grblHAL (yet), and have no experience with those plugins.

The "Blue Pills" are unfortunately pretty much a dead end.
https://hackaday.com/2020/10/22/stm32-clones-the-good-the-bad-and-the-ugly/

My last bath of 10 were fakes (had to change programmer ID) and I'm thinking of just throwing them away cause I don't want to waste time on them.
The boards from https://robotdyn.com may still be OK. They are around the same price that the Blue Pills were before the race to the bottom started. For EUR3 it's quite a bargain, but the EUR1.5 versions are just garbage.

STM32F401 or STM32F411 may be a better choice these days:
https://hackaday.com/2021/01/20/blue-pill-vs-black-pill-transitioning-from-stm32f103-to-stm32f411/
But i'm afraid it's just a matter of time before those are also ground to dirt.
Quite a shame. I really like the breadboard friendly form factor, and I don't like the big "discovery" boards with built in programmer. The small ST-Link V2 programmers are quite nice (although those also have multiple variants, and even different pinouts on the 10-pin connector.

Also weird:
From what I remember from LCSC.com, the STM32F103C8T6 was about 40ct "less cheap" then the clones. Last time I checked the price has shot up from "around" USD2 to USD7.5. I've read something about a shortage and long leadtimes for STM32 chips, and also about lots of electronics components in a general sense. Apparently car factories shut down because they can't get the chips to put in the cars.

@terjeio
Copy link

terjeio commented Jan 25, 2021

I've also run about 7000mm/min

I wrote 70000 mm/min 😉
Nearly 120000 lines executed in less than 1:30, a lot of short movements alternating between G0 and G1.
The Teensy 4 is capable of sustaining at least a 300kHz step rate (step pulses falls apart at just over 400KHz).

The Pi Pico is an interesting board, wonder what can be achieved with PIO and the second core... Expect a grblHAL driver soon.

@jerseyguy1996
Copy link

Thanks everyone for the great information! @terjeio I'm loving the idea of the Teensy4.1 running grblHal. This is for a k40 laser engraver that I'm currently running GRBL on an Arduino Nano. It really struggles with raster images and I've noticed that when it runs out of instructions (I assume that's what is happening) the laser head will stop for a split second leaving a little pinpoint burn in the engraved image until it can process some more moves. I'm hoping that a control board that can read in and process gcode faster with larger buffers will help that. I'll read through all of the documentation on your port and I'll probably have questions which i'll post there. Thanks again everyone!

@CreativeRobotics
Copy link

I've been using GRBL for years on my CNC but this is inspiring me to )yet again) consider an upgrade to a D21 MCU and grblHAL.

There were some nice boards available from Mattairtech, and they have a superb arduino boards distrubution that supports the whole range of SAMD21/L21/E21 and D51 MCU's. Unfortunatly they are discontinuing their development boards. If people are really keen to try out a D21 breadboard compatible board with GRBL then I have some home brew ones for the 48 pin D21 - the design philosophy is to break out every single pin in order into a breadboad compatible module so its a close to using the raw MCU as possible. I'm not (yet) selling them commercially but I would consider making a few to order if people really wanted to try one out.

I was contemplating a home brew CNC board using the D21 and with support for six axis. I got as far as sketching out a design that uses the Pololu stepper driver boards, and had them in groups of four with mounting holes for a cooling fan over each group. I might dig out the design and try and finish it - another lockdown project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests