# Thoughts on designing a new controller

**URL:** <https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453>\
**Category:** Electronics\
**Created:** [July 8, 2019, 5:13pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453 "2019-07-08T17:13:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [July 8, 2019, 5:13pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/1 "2019-07-08T17:13:29Z")

</div>

I really like the idea of Web Ground Control and I absolutely think something like that is the future. I would like to start designing a controller specifically to work with Web Ground Control.

CNCs using stepper motors are VERY sensitive to timing because the motors require precise and high frequency pulses to move. A closed loop system like ours should be a lot more forgiving about timing (especially if the processor is much faster than the motors) so I think we may be able to get rid of the Arduino entirely and control the motors directly from something like a Raspberry Pi. It’s still a theory, but I’m interested in playing around with it more.

My first thought is to use the Raspberry Pi Zero W which gives us a good amount of processing power, SPI, and wifi/bluetooth in a small package. The SD card is a pro and a con. I like that it easy to replace the software completely with a new SD card, but also it adds cost and I am a little bit worried about dust getting in there. The need to solder on headers is also not ideal, but workable.

Something like the Raspberry Pi compute is built for that type of thing, but it doesn’t include WiFi and is not easy to reprogram for the end user (and being hackable is important).

Does anyone have any other suggestions for little cheap wifi boards which could run a little web server and some PID loops?

**Edit:** On the other end of the spectrum something like the [Air602](https://www.seeedstudio.com/Air602-WiFi-Module.html) for $1.90 is designed to be soldered directly to a PCB. The cons are that it doesn’t have the huge support community that the Pi does, and with 1Mb of storage we aren’t going to be having any fancy pictures in there.

---

<div class="post-metadata">

**Author:** ![cmullins70](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/cmullins70/32/6194_2.png) [@cmullins70](https://forums.maslowcnc.com/u/cmullins70)\
**Post date:** [July 8, 2019, 5:30pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/2 "2019-07-08T17:30:49Z")

</div>

When people come to us looking to move to a production with a PI (which used to be tough to get wholesale, but that’s becoming less of an issue) we would recommend redesigning around a [Beagle Board](https://beagleboard.org/). There is a vendor making these as a SIC, but that would be overkill here.

---

<div class="post-metadata">

**Author:** ![Gero](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/gero/32/17487_2.png) [@Gero](https://forums.maslowcnc.com/u/Gero)\
**Post date:** [July 8, 2019, 5:43pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/3 "2019-07-08T17:43:41Z")

</div>

Thanks for the link!

Edit:

> [@bar](#):
>
> but it doesn’t include WiFi and is not easy to reprogram for the end user (and being hackable is important).

@bar can you specify that? That would mean excluding anything with an OS. More like the Arduino with a pre-loaded and unchangeable firmware?

Looking for OS with GPIO this is my favourite till date, still not ordered.  
I would attempt a MX Linux (not tested i guess) as a first try.

> **[ODROID-XU4 Special Price – ODROID](https://www.hardkernel.com/shop/odroid-xu4-special-price/)**

Kind regards, Gero

---

<div class="post-metadata">

**Author:** ![Jamtek](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jamtek/32/12604_2.png) [@Jamtek](https://forums.maslowcnc.com/u/Jamtek)\
**Post date:** [July 8, 2019, 7:21pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/4 "2019-07-08T19:21:53Z")

</div>

So, the thinking is that the motor board would sit on top of the pi or SBC like one of the hats currently available?

> **[Raspberry Pi CNC Board V2.60](https://www.pishop.us/product/raspberry-pi-cnc-board/)**
>
> American Raspberry Pi Shop. One stop shop for all your Pi needs. Raspberry Pi add-ons, HATs, accessories, Starter Kit, Media Center kit, RetroPi Arcade kit, Ultimate Kit, and many other project kits. PiShop.us is approved Raspberry Pi re-seller and...

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [July 8, 2019, 7:39pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/5 "2019-07-08T19:39:41Z")

</div>

Well, that would certain solve the settings sync issue 🙂 with webcontrol. One of my concerns, and I don’t know the answer and I think you alluded to it, is whether the RPi is able to manage all the user interface requests as well as maintain the motors. I don’t know what’s required timing wise, but some of the user interface functions of webcontrol (particularly the sending a complex piece of the gcode to the client) can bog down the RPi. Maybe it can be optimized to handle it.

Are you thinking this is a way to eliminate the custom motor controller shield and allow other ones to be used?

---

<div class="post-metadata">

**Author:** ![MartinJ](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/martinj/32/2688_2.png) [@MartinJ](https://forums.maslowcnc.com/u/MartinJ)\
**Post date:** [July 8, 2019, 8:05pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/6 "2019-07-08T20:05:28Z")

</div>

I’m very much not into the hardware aspect (I like working with my databases, dangit).

It would be interesting to have all the smarts in a single box, though. What about the [UDOO](https://www.udoo.org/) boards that are like a combination of an RPi and Arduino. We’d still need the extra board for controlling the motors, though.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 12:49am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/7 "2019-07-09T00:49:14Z")

</div>

I would go with a regular pi, or with a Beagle Bone Black, the extra cost is  
minimal, and it’s really good to be able to dedicate a processor core to the  
real-time stuff and have others available to deal with the network and other  
processing.

Using a Pi is a common way to go, using a BBB gives you the real-time processors  
on-board so that it can do real time work.

I am very interested in the possibility of using absolute encoders on the motor  
outputs that you can read via serial, what would pretty much eliminate real-time  
requirements.

the difference between the 8MHz arduino and the 1500 MHz cores on the pi can  
also make up for a lot of ‘real time error’

another direction to consider would be something like the ESP32, dual 240MHz  
cores with wifi, so you could have one core managing the machine and another  
doing the webserver.

Overall, I think going with the pi would be the best long-term option as the  
work done there can basically be used on any linux-based machine in the future.

David Lang

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 12:51am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/8 "2019-07-09T00:51:36Z")

</div>

This is why using a Pi3 or Pi4 would be better than a Pi0. the bigger ones have  
4 cores, so one can get bogged down while another is still free to manage the  
hardware (there are software complications with having multiple  
processes/threads and communicating between them, but that’s reasonably well  
understood territory, even if it is something people struggle with a fair bit.

David Lang

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [July 9, 2019, 1:20am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/9 "2019-07-09T01:20:55Z")

</div>

My thought it that if you are trying to avoid a custom built motor controller, then I think it’s worth pursuing. If a custom motor controller is still planned then I don’t really see the advantage of doing so since the Arduino (or whatever) is relatively cheap component to add in.

But I have thought about creating a motor controller with an embedded microcontroller that is strictly running the PID loop. The rpi would do all the gcode processing and just send set points to the controller over serial and the controller would be responsible for the pwm/encoder processing and reporting error. Doing it this way, you could implement a traditional two motor maslow with one board and a four motor maslow with two boards.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 2:01am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/10 "2019-07-09T02:01:26Z")

</div>

If you are trying to go as cheap as possible, than an arduino like-thing that  
has enough ommph to run a webserver as well is the way to go.

If you are looking to never have to re-write the firmware again, than something  
that runs Linux (Pi or BBB) would be the way to go.

David Lang

---

<div class="post-metadata">

**Author:** ![Metalmaslow](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Metalmaslow](https://forums.maslowcnc.com/u/Metalmaslow)\
**Post date:** [July 9, 2019, 2:03am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/11 "2019-07-09T02:03:18Z")

</div>

I’d go with a pi 3b+ or 4 because there seems to be more user support. the pi zero is only $17 less.

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [July 9, 2019, 2:07am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/12 "2019-07-09T02:07:27Z")

</div>

> [@dlang](#):
>
> If you are trying to go as cheap as possible, than an arduino like-thing that  
> has enough ommph to run a webserver as well is the way to go.

The new teensy 4.0 (not out yet) I think will run at 600 mhz from what I can tell. It has enough pwm/gpio for everything… 3.3v though… but that’s the trend anyway.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 2:14am UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/13 "2019-07-09T02:14:25Z")

</div>

I don’t know of any 3+ motor controller boards that are common enough to depend  
on existing in the future.

the BBB has the motor cape  
[https://www.mouser.com/ProductDetail/BeagleBoard-by-GHI/MRTCPE-BBBCAPE?qs=%2Fha2pyFaduiOgqSAsM3PmoV8AG441awWEN%2FsuSRFv5OHM7nwGSy3F3I2YXJXNd2n](https://www.mouser.com/ProductDetail/BeagleBoard-by-GHI/MRTCPE-BBBCAPE?qs=%2Fha2pyFaduiOgqSAsM3PmoV8AG441awWEN%2FsuSRFv5OHM7nwGSy3F3I2YXJXNd2n)  
4 motors at up to 3A@46v

David Lang

---

<div class="post-metadata">

**Author:** ![JWoody18](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jwoody18/32/13066_2.png) [@JWoody18](https://forums.maslowcnc.com/u/JWoody18)\
**Post date:** [July 9, 2019, 5:36pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/14 "2019-07-09T17:36:47Z")

</div>

I agree with David. At $35 the Pi3 or Pi4 is not a material cost compared to the consumables that are involved in regular CNC work.

You’ll get all the GPIO pins on board and benefit from a large and robust ecosystem for hardware and software. Also daily overlooked is the long availability timeline. The Pi foundation is committed to multi year supply because people are building products around them.

Also the pi4 has two HDMI outputs so you could have both the current software as well as a new dashboard or visualization screen if desired.

Also the pi4 has multiple ram options at 1g, 2g or 4g. Not sure how much ram is needed but allowing for say 2g minimum leaves the door wide open for innovation by the community.

I agree with having a multi core system and dedicating a ore for the UI and others for motor controllers. I came from a professional video background where we were processing dozens of live HD video streams for broadcast and we did exactly this as the timing requirements are low ms with extreme consistency. We were using Intel CPUs but same idea.

Also the extra pins on the PI can be used for controlling relays for dust extraction or the auto zeroing sensor etc that others have shown here.

If you are concerned about the SD card you could always PXE boot the pi from a host PC. And run in RAM. We did both. Firmware was on a flash device. It loads to a ram disk and executed from there. So the flash was for storage and mostly read only except some critical logs. For a subsystem we had it PXE boot from the main host and run from ram. That way we would provide the 24/7/365 required. Also the system find very fast when everything is in RAM. If 1G would do them spec a 2G board and boot from SD in to RAM. Helps improving timing and removes disk IO bottleneck risk.

We did a stacked set of images. When running in RAM you can overwrite what is below you. So we had Kernel at the bottom then a base OS image then an OS app image and then our custom apps. So this way you can have the base OS extremely stable and constant and update just the OS app layer or your custom layer on top. Loading the new image just requires a reboot once downloaded.

Also you can apt-Get install things love for temporary use and they vanish on reboot. For gcode file storage if you want to keep it local that could be on the SD. By minimizing writes to just gcode and some basic logs life expectancy of the flash should be many years.

Jeff

---

<div class="post-metadata">

**Author:** ![Keith](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/keith/32/1332_2.png) [@Keith](https://forums.maslowcnc.com/u/Keith)\
**Post date:** [July 9, 2019, 6:28pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/15 "2019-07-09T18:28:04Z")

</div>

> [@JWoody18](#):
>
> about the SD card

Another thought with the SD card is that it would provide a really easy way to initially distribute the software. Installing an image on the SD card seems like a pretty straightforward process, though I’ve only done it once with a rPi, and that a while ago.

---

<div class="post-metadata">

**Author:** ![JWoody18](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jwoody18/32/13066_2.png) [@JWoody18](https://forums.maslowcnc.com/u/JWoody18)\
**Post date:** [July 9, 2019, 6:40pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/16 "2019-07-09T18:40:26Z")

</div>

It is very straight forward and well documented how to write an image to the SD card from a PC or Mac.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [July 9, 2019, 7:57pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/17 "2019-07-09T19:57:39Z")

</div>

> [@Gero](#):
>
> Edit:
> 
> ![](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/40/10_2.png) bar:
> 
> > but it doesn’t include WiFi and is not easy to reprogram for the end user (and being hackable is important).
> 
> @bar can you specify that? That would mean excluding anything with an OS. More like the Arduino with a pre-loaded and unchangeable firmware?

If we were to use the Raspberry Pi compute anyone who wanted to modify the software would need one of [these adapters](https://www.raspberrypi.org/products/compute-module-io-board-v3/) which seems like a hassle.

> [@dlang](#):
>
> another direction to consider would be something like the ESP32, dual 240MHz  
> cores with wifi, so you could have one core managing the machine and another  
> doing the webserver.

This seems like very exciting option to me. Great recommendation. I am going to read up more on these. This seems like a good solution which would basically replace the Arduino Mega with something else comparable and modern.

Thanks for the recommendations everyone! I will keep reading up on all of these and I’ll post my progress when I make any.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 10:20pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/18 "2019-07-09T22:20:53Z")

</div>

And while the SD cards do wear out and eventually fail (and can get corrupted  
from power loss), you do need to upgrade periodically, so it’s not all bad to  
re-image/replace the card 🙂

we just need to have the config saved off on a PC so it doesn’t need to be  
recreated from scratch, or put a small amount of EEprom/flash on the motor  
controller card for such long-term items.

David Lang

---

<div class="post-metadata">

**Author:** ![Jamtek](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jamtek/32/12604_2.png) [@Jamtek](https://forums.maslowcnc.com/u/Jamtek)\
**Post date:** [July 9, 2019, 10:27pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/19 "2019-07-09T22:27:30Z")

</div>

If we are looking at ESP32 boards and the like does MicroPython or CircuitPython (AdaFruit branch of MicroPython) come into play?

I am not familiar with either, but seems to be a trend in micro-controller development. You can program the supported boards without the Arduino IDE and with native USB, they show up as a drive letter on your PC when connected, and their is no longer a need to compile code and push it over a serial link.

> **[adafruit/circuitpython](https://github.com/adafruit/circuitpython)**
>
> CircuitPython - a Python implementation for teaching coding with microcontrollers - adafruit/circuitpython

> **[MicroPython - Python for microcontrollers](https://micropython.org/)**
>
> MicroPython is a lean and efficient
> implementation of the Python 3 programming language
> that includes a small subset of the Python standard library and is
> optimised to run on microcontrollers and in constrained environments.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [July 9, 2019, 10:39pm UTC](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453/20 "2019-07-09T22:39:24Z")

</div>

possible, but I would be a bit surprised. The firmware is already written in C  
and while these are far more powerful than an Arduino, I’d rather use that power  
to drive the machine than to drive the python interpreter 🙂

David Lang

[Next page](https://forums.maslowcnc.com/t/thoughts-on-designing-a-new-controller/10453.md?page=2)
