3PakCNC Control Board¶
Above: The 3PakCNC Control Board Design! Read on to learn how to make your own!
Project Plan¶
I will make a ESP 32 board that control three stepper motors for the X Y & Z stepper motors on the Foam Crawler CNC Machine.
- Design ESP-32 based board in KiCad
- Mill the board
- Stuff the board
- Test and trouble shoot the board
- Program the board with FluidNC
- Configure FluidNC using my Foam Crawler GRBL documentation as a reference.
- Run test g-Code
Background¶
I have built several ESP32 based circuit boards so far. I have always dreamed of designing my own circuit board to control a CNC machine. Using a ESP32 and FluidNC will allow me to run my Foam Crawler CNC machine wireless via a web interface. I spent about 4 weeks studying various ESP32 control boards, so I could learn enough to select the features I wanted for my final project, but still be able to finish my project.
FluidNC¶
One of the coolest features of the ESP32 is it’s built in bluetooth and wifi. This will allow streaming of g-code to my cnc machines with ant tablet, old android phone, or computer via the FluidNC web interface!
Streaming Gcode to ESP32 Grbl via BlueTooth
Pinouts¶
In order for my custom 3PakCNC board to work properly with FluidNC I needed to learn about what pinouts were best to use. ESP32 Pin Reference Furthermore I needed to see what pins did what functions on a 3 axis GRBL control board. So I looked at Bart Dring’s ESP32 CNC Test PCB V4.1. Since this was my first time making my own CNC control board, I used this board as a reference for my 3PakCNC board design.
KiCad design¶
Here is an early version of the 3PakCNC board design.
The through hole mounting of the step stick sub boards was very annoying and blocked the number of traces that could pass through. I decided to add mounting holes for M3 screws and to round the corners of the board. A cut out dip was added to the top of the board to allow traces to get to the interior of the ESP32, but not block the antenna.
This is a late version of the board with text labels
Rivet Vias¶
I once again used Favorit Rivets as vias to make a double sided board. I used 1.0mm ID rivets:
ID | OD +/- 0.03 mm | Drill ⌀ | Shaft L +/- 0.10 mm | Head ⌀ +/- 0.15mm | wall d +/- 10% |
---|---|---|---|---|---|
1.0mm | 1.4mm | 1.5mm | 2.5mm | 2.2mm | 0.2mm |
Each Rivet costs:
Order Code | Description | Price per 1k | Price Each |
---|---|---|---|
700-028-2 | Favorit RIVETS 1.0mm ID | $52.50 | 0.525¢ |
I’m using 6 vias, so total cost is $3.15
CAM¶
I once again prepared my boards for CAM, by exporting SVG files from KiCad via File, Export, SVG… then selecting Copper layers: F.Cu, B.Cu, Edge.Cuts and then clicking Export. This exports a file called *-brg.svg with * being your KiCad project name. In my case 3PakCNC-brd.svg
Next cleaned them up in Inkscape. I used these steps as I have documented previously: clean-traces-in-inkscape.
The final SVG works well on many levels, including the fact that it can be viewed directly here and simply left click save as and you can use the file too!
3 Workpiece steps in Easel CAM
F.Cu layer milling 1hr 16min! Longest board so far.
Holes for vias, mounting and ESP32 heatsink
Edge cuts, including clearance for antenna
I overlay-ed the inkscape graphics over my KiCad board to make sure I didn’t delete any traces to be milled.
Milling¶
I milled a piece of scrap machinable wax into a base for mounting my circuit boards to. I used Suretape DF 65 tape. This tape works very well for holding down machinable wax and circuit boards.
I printed on paper my board design life size, this allowed me to see where to avoid putting tape under through holes where the end mill would get gummed up cutting into tape.
Double checking placement
Work piece X postion
Work piece Y postion
I milled my board on a Inventables Carvey desktop CNC mill. This machine was kindly donated by Zach Kaplan of Inventables! I really like the ease of use, and lighting of the Carvey.
Here are the tools I use for milling. Note rocket shaped air blaster, this thing is great for keeping my collets and tooling clean! This air rocket was a gift from my friend Walter.
0.25mm (0.0100”) Taper stub end mills for trace pocketing
Feed Rates¶
Feed Rate For 0.0100” (0.25mm) dia Tapered Stub End Mill The calculated feed rate for my 0.0100” (0.25mm) dia Tapered Stub End Mill is:
0.0100” (0.25mm) dia - multiply your peak spindle RPM by 0.00328 with 20 IPM (500 mm/min) z-axis plunge rate.
12000 * 0.00328 = 40 IPM or 1000 mm/min
So Cut Settings for Easel are:
Manual: Feed rate = 1000 mm/min Plunge rate = 500 mm/min Depth per pass = 0.3 mm All other settings as default.
Ready to send g-code!
Milling commences!
Pockets around traces milled! I always completely mill out pockets around my traces for a few reasons. 1. I like how it looks 2. I have my own mill at home, so time is not an issue. 3. It’s less likely I’ll short traces to ground.
Here I am using a print out from KiCad to make sure I didn’t miss any features on my traces, before I move ahead.
Finished board with mounting and via holes and edge cut.
Wow! I am really exited to have gotten to this point. It took me several years to learn about GRBL and designing my own CNC control board! From the start of my board design to this point took me about one month of work!
Close up of board! This board is so big that I need a larger board vise to hold it!
Stuffing¶
Stuffing isn’t just for Turkey’s!
Interactive BOM¶
I used the BOM below to hand pick and place my components.
Above: Click image to access the HTML Interactive BOM (iBOM) generated by KiCad.
I printed the iBOM and out some clear double stick tape on it. Then I selected the components from my Stanley bins and my Digi-Key order and stuck them in the iBOM
Soldering¶
Then soldered everything on my board.
My new Rx prescription safety glasses with clip on magnifiers really help me see much better when working with small items.
Testing¶
I used the KiCad “Net Inspector” to highlight individual nets, for trouble shooting. I used my USB to serial programmer and plugged it into the FTDI header on my board.
Next I checked my board for shorts with a multi-meter. There were no shorts.
I jumped the 5vdc pin to the 3.3vdc regulator to power the ESP32 during programming. I need to add a jumper to switch between 12-27vdc and 5vdc in the future.
I powered up the FTDI cable with my USB hub and verified that 5v and 3.3vdc were present, they were and the measurements were 5.05 and 3.27vdc. I also felt the chips on the board to see if they were not hot, indicating a short or other issue.
I then ran a lsusb command to make sure I could see the USB to Serial converter, and I got the expected response: Bus 003 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
ESP32 Bootloader Mode¶
The ESP32 must be put in bootloader mode before uploading any type of code. With a FTDI Cable connected to provide power, put the ESP32 into bootloader mode by:
- Press and hold Switch 2 Program (GPIO0) hold though next step
- Clicking Reset button Switch 1
- Releasing the Switch 2 Program
Next I fired up the Arduino IDE and uploaded a hello world Serial ESP32 program.
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("Hello World");
delay(2000);
}
I uploaded the program above (after making sure Tools Board ESP32 Dev Module was selected) I then opened serial monitor in the ardunio ide to see the response from the ESP32. And I got!:
NOTHING! :(
Let’s check that the buttons work and that the 3v is on the power pin of the ESP32.
3.29vdc was getting to pin 2 of the esp 32. Let’s check buttons.
Well what do you know! The Reset button for some reason did not have a trace that connected to ground in KiCad. I’m wondering if this had to do with the fact that I started with a copy of another project and then modified that project for this board. I’m not sure. So I added a jumper from the switch to GND to fix the issue.
I then put the board in programming mode, and tried uploading the hello world Serial ESP32 program above again. The program uploaded. I opened serial monitor and pressed the reset button to run the program… and got:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1324 ho 0 tail 12 room 4 load:0x40078000,len:13508 load:0x40080400,len:3604 entry 0x400805f0 Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World
Brownout detector was trigg⸮ ⸮ ⸮⸮ ~
Awesome, I fixed my board! This was one of the shorter trouble shooting sessions I’ve had! Next time I’ll design the whole board from scratch in KiCad! “The Brownout detector was trigg⸮ ⸮ ⸮⸮ ~ ” in the above hello world, was because I powered down the board mid program.
Ok let’s see if I can load up something more complex, like FluidNC! But first I need to take a nap, I’ve been up since 3:30am and it’s now 4:22pm!
Setting Stepper Current¶
before connecting stepper motors it’s a good idea to set current limits on the stepper drivers. In my case I have 8825 polou compatible drivers with potentiometer adjustment. I found this site whcih explined the process very well: DRV8825 Adjust Stepper Current
The driver boards have 100mOhm resistance so the following formula applies”
Imot = 2 * Vref Or Vref = Imot / 2
Note the DRV8825 driver boards I’m using have a max of 2.2A, so on my X & Y stepper motors they will be slightly under powered
So
Stepper | 100mΩ Divider | Target Amps | Vref | |
---|---|---|---|---|
NEMA 28 X&Y Axes KL23H251-28-4A | 2 | 2.2 A | 1.1 V | |
NEMA 17 Z Axis SM42HT47-1684B | 2 | 1.68 A | 0.84 V |
Micro Stepping¶
Z 2x Y 4x X 4x
Jumpers
Axis MODE0 MODE1 MODE2 Microstep Resolution Z High Low Low Half step X&Y Low High Low 1/4 step
FluidNC¶
Next I went to the FluidNC Wiki to learn how to upload the firmware to my board.
I followed the instructions at: https://github.com/bdring/FluidNC/wiki/FluidNC-Compiling to install the latest pre-compiled version of FluidNC.
Here are my actual steps I took on linux mint beyond what is explained on the wiki above:
- Put the ESP32 in programming mode by holding the PRG button, double click the RST button and then release the PRG button.
- Open a terminal window in the same directory of the unzipped files
- Since this is the first time programming this board, run the command:
sh install-fs.sh
- Note: You may need to put the ESP32 in programming mode again during the step above when “Connecting........__” appears
- I then uploaded the wifi firmware with the command
sh install-wifi.sh
- Note: You may need to put the ESP32 in programming mode again during the step above when “Connecting........__” appears
- I then followed the instructions on the wiki
See the FAQ to learn more about the Connecting .........._..... issue.
At the completion of the sh install-wifi.sh
command the following trailer code was displayed and the board entered FluidNC terminal:
Starting fluidterm
--- Fluidterm on /dev/ttyUSB0 115200,8,N,1 ---
--- Quit: Ctrl+] or Ctrl+Q | Upload: Ctrl+U | Reset: Ctrl+R ---
[MSG:INFO: FluidNC v3.4.7]
[MSG:INFO: Compiled with ESP32 SDK:v4.4.1-1-gb8050b365e]
[MSG:INFO: Local filesystem type is SPIFFS]
[MSG:WARN: Cannot open configuration file:config.yaml]
[MSG:INFO: Using default configuration]
[MSG:INFO: Axes: using defaults]
[MSG:INFO: Machine Default (Test Drive)]
[MSG:INFO: Board None]
[MSG:INFO: SPI not defined]
[MSG:INFO: Stepping:RMT Pulse:4us Dsbl Delay:0us Dir Delay:0us Idle Delay:255ms]
[MSG:INFO: Axis count 3]
[MSG:INFO: Axis X (-1000.000,0.000)]
[MSG:INFO: Axis Y (-1000.000,0.000)]
[MSG:INFO: Axis Z (-1000.000,0.000)]
[MSG:INFO: Kinematic system: Cartesian]
[MSG:INFO: Using spindle NoSpindle]
[MSG:INFO: STA SSID is not set]
[MSG:INFO: AP SSID FluidNC IP 192.168.0.1 mask 255.255.255.0 channel 1]
[MSG:INFO: AP started]
[MSG:INFO: WiFi on]
[MSG:INFO: Captive Portal Started]
[MSG:INFO: HTTP started on port 80]
[MSG:INFO: Telnet started on port 23]
Grbl 3.4 [FluidNC v3.4.7 (wifi) '$' for help]
[MSG:INFO: '$H'|'$X' to unlock]
Next I was able to talk to it, using $ commands:
- $ displays the command list
- $S displays the current parameters and there S commands to set them.
FluidTerm¶
FluidTerm or FluidNC terminal is run by issuing the command sh fluidterm.sh this brings you into FluidNC terminal where you can configure your board and then save those parameters.
Next I wanted to connect to my boards webui. To do this I read FluidNC Wifi and Bluetooth Setup
In FluidTerm I entered the command: $STA Which gave the following report back:
$Report/Status=1 $Sta/SSID= $Sta/Password=** $Sta/IPMode=DHCP $Sta/IP=0.0.0.0 $Sta/Gateway=0.0.0.0 $Sta/Netmask=0.0.0.0
Next I tried the $AP command which returned:
$AP/SSID=FluidNC $AP/Password=** $AP/IP=192.168.0.1 $AP/Channel=1
** covers the default password which is 12345678
So I went and connected via WiFi to FluidNC, suposedly this should end up with the launch of a webui. But that didn’t happen. I needed to change the IP since 192.168.0.1 was the same as my WiFi router.
I wanted to setup my board to work on my wifi network, so I issued the following commands
$AP/SSID=MTekFluidNC
$AP/IP=192.168.0.242
$AP/Channel=3
$WiFi/Mode=AP
$Sta/SSID=242_2G
$Sta/Password=your_wifi_router_password
$Sta/IPMode=DHCP
$Sta/IP=192.168.0.242
$Sta/Gateway=192.168.0.1
$Sta/Netmask=255.255.255.0
I then ran a $AP
and $STA
commands and the board echoed back:
$AP/SSID=MTekFluidNC $AP/Password=** $AP/IP=192.168.0.242 $AP/Channel=3
$Report/Status=1 $Sta/SSID=242_2G $Sta/Password=** $Sta/IPMode=DHCP $Sta/IP=192.168.0.242 $Sta/Gateway=192.168.0.1 $Sta/Netmask=255.255.255.0
I then pressed Ctrl+] to exit fluid terminal.
FluidTerm works well for initial setup, but it was slow going.
WebUI¶
Time to try webui for FluidNC! I rebooted my board, and on my laptop shut down wired networking and connected to MTekFluidNC via WiFi. Then I went to the ip address I assigned earlier 192.168.0.242
And bam! the WebUI appeared! Cool
SHORT fries board!¶
Well I had a bad stepper driver module with a short in it, and it fried my regulator and ESP32 chip! Frack! Here is a thermal image that I realized later was telling me what was going on :(
3PakCNC Version 2!¶
I decided to re-design the 3PakCNC board. I needed to make some correction and changes anyway, my micro sd card slot was upside down, many of my capcitors were very far from what they should filter. I also used way too large of a voltage regulator, with a 3amp output. I think this led to my parts being fried with high current, rather that just heating up a bit and shutting down. I will use a 1.5A regulator this time.
KiCad EDA¶
Schematic¶
PCB Design¶
CAD Files¶
Following are the SVG files I used to mill my board:
Right click and save to use these files to mill your own 3PakCNCv2 board.
CAM¶
Milling¶
Stuffing¶
Rivet Vias¶
Dan peened these rivets a little too hard, almost cutting through the copper cladding.
Testing¶
Soldering¶
Walter says, “How can we use scrap around us? How can we use the scrap around us!” Thinking this way I thought how can I scrap fab.
I used the flags that I usually throw out from small crimp connectors to create a solderable trace jumper!
Interactive BOM v2¶
I used the BOM below to hand pick and place my components.
Above: Click image to access the HTML Interactive BOM (iBOM) generated by KiCad.
FluidNC Settings¶
Next I went to the FluidNC Wiki to learn how to upload the firmware to my board.
I followed the instructions at: https://github.com/bdring/FluidNC/wiki/FluidNC-Compiling to install the latest pre-compiled version of FluidNC.
Here are my actual steps I took on linux mint beyond what is explained on the wiki above:
- Put the ESP32 in programming mode by holding the PRG button, double click the RST button and then release the PRG button.
- Open a terminal window in the same directory of the unzipped files
- Since this is the first time programming this board, run the command:
sh install-fs.sh
- Note: You may need to put the ESP32 in programming mode again during the step above when “Connecting........__” appears
- I then uploaded the wifi firmware with the command
sh install-wifi.sh
- Note: You may need to put the ESP32 in programming mode again during the step above when “Connecting........__” appears
- I then followed the instructions on the wiki
See the FAQ to learn more about the Connecting .........._..... issue.
At the completion of the sh install-wifi.sh
command the following trailer code was displayed and the board entered FluidNC terminal:
Starting fluidterm
--- Fluidterm on /dev/ttyUSB0 115200,8,N,1 ---
--- Quit: Ctrl+] or Ctrl+Q | Upload: Ctrl+U | Reset: Ctrl+R ---
[MSG:INFO: FluidNC v3.4.7]
[MSG:INFO: Compiled with ESP32 SDK:v4.4.1-1-gb8050b365e]
[MSG:INFO: Local filesystem type is SPIFFS]
[MSG:WARN: Cannot open configuration file:config.yaml]
[MSG:INFO: Using default configuration]
[MSG:INFO: Axes: using defaults]
[MSG:INFO: Machine Default (Test Drive)]
[MSG:INFO: Board None]
[MSG:INFO: SPI not defined]
[MSG:INFO: Stepping:RMT Pulse:4us Dsbl Delay:0us Dir Delay:0us Idle Delay:255ms]
[MSG:INFO: Axis count 3]
[MSG:INFO: Axis X (-1000.000,0.000)]
[MSG:INFO: Axis Y (-1000.000,0.000)]
[MSG:INFO: Axis Z (-1000.000,0.000)]
[MSG:INFO: Kinematic system: Cartesian]
[MSG:INFO: Using spindle NoSpindle]
[MSG:INFO: STA SSID is not set]
[MSG:INFO: AP SSID FluidNC IP 192.168.0.1 mask 255.255.255.0 channel 1]
[MSG:INFO: AP started]
[MSG:INFO: WiFi on]
[MSG:INFO: Captive Portal Started]
[MSG:INFO: HTTP started on port 80]
[MSG:INFO: Telnet started on port 23]
Grbl 3.4 [FluidNC v3.4.7 (wifi) '$' for help]
[MSG:INFO: '$H'|'$X' to unlock]
Next I was able to talk to it, using $ commands: 1. $ displays the command list 2. $S displays the current parameters and there S commands to set them.
FluidTerm¶
FluidTerm or FluidNC terminal is run by issuing the command sh fluidterm.sh this brings you into FluidNC terminal where you can configure your board and then save those parameters.
Next I wanted to connect to my boards webui. To do this I read FluidNC Wifi and Bluetooth Setup
In FluidTerm I entered the command: $STA Which gave the following report back:
$Report/Status=1 $Sta/SSID= $Sta/Password=** $Sta/IPMode=DHCP $Sta/IP=0.0.0.0 $Sta/Gateway=0.0.0.0 $Sta/Netmask=0.0.0.0
Next I tried the $AP command which returned:
$AP/SSID=FluidNC $AP/Password=** $AP/IP=192.168.0.1 $AP/Channel=1
** covers the default password which is 12345678
So I went and connected via WiFi to FluidNC, suposedly this should end up with the launch of a webui. But that didn’t happen. I needed to change the IP since 192.168.0.1 was the same as my WiFi router.
I wanted to setup my board to work on my wifi network, so I issued the following commands
$AP/SSID=MTekFluidNC
$AP/IP=192.168.0.242
$AP/Channel=3
$WiFi/Mode=AP
$Sta/SSID=242_2G
$Sta/Password=your_wifi_router_password
$Sta/IPMode=DHCP
$Sta/IP=192.168.0.242
$Sta/Gateway=192.168.0.1
$Sta/Netmask=255.255.255.0
I then ran a $AP
and $STA
commands and the board echoed back:
$AP/SSID=MTekFluidNC $AP/Password=** $AP/IP=192.168.0.242 $AP/Channel=3
$Report/Status=1 $Sta/SSID=242_2G $Sta/Password=** $Sta/IPMode=DHCP $Sta/IP=192.168.0.242 $Sta/Gateway=192.168.0.1 $Sta/Netmask=255.255.255.0
I then pressed Ctrl+x to exit fluid terminal.
FluidTerm works well for initial setup, but it was slow going.
WebUI¶
Time to try webui for FluidNC! I rebooted my board, and on my laptop shut down wired networking and connected to MTekFluidNC via WiFi. Then I went to the ip address I assigned earlier 192.168.0.242
And bam! the WebUI appeared! Cool
Foam Crawler Configuration¶
GRBL ESP32 Settings Chart¶
Label | Value | Help | ||
---|---|---|---|---|
$0 | 3 | Step pulse, microseconds | ||
$1 | 250 | Step idle delay, milliseconds | ||
$2 | 0 | Step port invert, mask | ||
$3 | 0 | Direction port invert, mask | ||
$4 | 0 | Step enable invert, boolean | ||
$5 | 1 | Limit pins invert, boolean | ||
$6 | 0 | Probe pin invert, boolean | ||
$10 | 1 | Status report, mask | ||
$11 | 0.01 | Junction deviation, mm | ||
$12 | 0.002 | Arc tolerance, mm | ||
$13 | 0 | Report inches, boolean | ||
$20 | 0 | Soft limits, boolean | ||
$21 | 0 | Hard limits, boolean | ||
$22 | 0 | Homing cycle, boolean | ||
$23 | 3 | Homing dir invert, mask | ||
$24 | 200 | Homing feed, mm/min | ||
$25 | 2000 | Homing seek, mm/min | ||
$26 | 250 | Homing debounce, milliseconds | ||
$27 | 1 | Homing pull-off, mm | ||
$30 | 10000 | Max spindle speed, RPM | ||
$31 | 0 | Min spindle speed, RPM | ||
$32 | 0 | Laser mode, boolean | ||
$N1 | ||||
$N0 | ||||
$100 | 13.333 | X steps/mm | ||
$101 | 5.899 | Y steps/mm | ||
$102 | 50 | Z steps/mm | ||
$110 | 8000 | X Max rate, mm/min | ||
$111 | 8000 | Y Max rate, mm/min | ||
$112 | 4000 | Z Max rate, mm/min | ||
$120 | 3000 | X Acceleration, mm/sec^2 | ||
$121 | 3000 | Y Acceleration, mm/sec^2 | ||
$122 | 200 | Z Acceleration, mm/sec^2 | ||
$130 | 610 | X Max travel, mm | ||
$131 | 1220 | Y Max travel, mm | ||
$132 | 35 | Z Max travel, mm |
I’ll use the chart above to transfer settings to FluidNC
Configure¶
Upon startup of the FluidNC WebUI the following appears in the Commands window of the FluidNC WebUI:
$/axes/x/max_travel_mm
$/axes/x/homing/mpos_mm
$/axes/x/homing/positive_direction
$/axes/y/max_travel_mm
$/axes/y/homing/mpos_mm
$/axes/y/homing/positive_direction
$G
$/axes/x/max_travel_mm=1000.000
ok
$/axes/x/homing/mpos_mm=0.000
ok
$/axes/x/homing/positive_direction=true
ok
$/axes/y/max_travel_mm=1000.000
ok
$/axes/y/homing/mpos_mm=0.000
ok
$/axes/y/homing/positive_direction=true
ok
[GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F0 S0]
ok
<Alarm|MPos:0.000,0.000,0.000|FS:0,0|WCO:0.000,0.000,0.000>
<Alarm|MPos:0.000,0.000,0.000|FS:0,0|Ov:100,100,100>
<Alarm|MPos:0.000,0.000,0.000|FS:0,0>
Next I clicked the “clear alarm” bell button in the GRBL window of the ESP3D for FluidNC WebUI
the following then appears in the Commands window of the FluidNC WebUI:
$X
[MSG:INFO: Caution: Unlocked]
ok
Next I went to the FluidNC tab, and then selected the Config Items button. And used the GRBL ESP32 Settings Chart to setup the config box items. You will need to customize these settings for your machine as well.
Troubleshooting¶
A weird thing was happening, from the FluidNCWebUI in chrome, I first cleared the alarms by clicking the bell icon to enable the steppers. Then I tried jogging X, Y and Z. However, whenever I sent a command to move any axis the steppers would jerk and nothing would happen. Then I noticed that the steppers would enable a few seconds after the jog completed and the current would spike on my lab power supply. During a long jog travel of the X axis, I tried spinning the x stepper shaft and it turned easily, then when the move stopped the stepper would activate and I could no longer turn the shaft. I also noted a very low current draw when jog commands were in progress. It seemed like the steppers were being disabled during jog moves.
I decided to post this issue on the FluidNC Discord channel:
FluidNC Discord¶
I posted my issue on fluidnc_help thread of the FluidNC Discord. Here is the dialog:
MTek (They/He) — Today at 6:44 PM I’m getting a weird response on the new board I designed. When I run a jog command the steppers disable themselves instead of enable themselves. I can spin the stepper shafts by hand, then when the jog commands stop the steppers lock again.`
daxliniere — Today at 6:50 PM Sounds like you need to invert the signal between ESP32 and your stepper drivers. MTek (They/He) — Today at 6:51 PM Thanks! I was looking for a config setting to do that, but can’t find it 😦
daxliniere — Today at 6:52 PM Add :low after the pin. e.g. Change shared_stepper_disable_pin: I2SO.0 to shared_stepper_disable_pin: I2SO.0:low
I went to my config.yaml file and searched for shared_stepper_disable_pin:
and found
axes:
shared_stepper_disable_pin: gpio.13:low
I changed this line to
shared_stepper_disable_pin: gpio.13
And my board started moving all the stepper motors via the FluidNCWebUI! Amazing! Thanks daxliniere!
Heat Hypothesis¶
I noticed that both my boards, V1 and V2, had been getting very hot while idle. This may be due to the steppers being enabled instead of disabled during idle. Although I want the steppers activated to hold their position during normal operations, the hot board and warm steppers while in an alarm state upon startup may indicate the enable pin being high when is should be low (off).
Success!¶
After 8 weeks of work and two complete versions of my board the steppers are now working! I almost cried when things worked. This is by far one of the most complex electronic projects I have ever done. I think I may be hooked!
Here is a video of the stepper motors moving and tuned up for the Foam Crawler CNC Machine:
Wow! I just built my own CNC control from scratch! Now I can use this board to control my final project Foam Crawler CNC machine!
Configuring FluidNC¶
config.yaml file¶
The config.yaml file is stored in the memory of the ESP32. To make permanent changes you need to download this file and edit in text editor or programming editor like Atom. Once you are done editing this file on your computer you can upload it through the FluidNCWebUI and over write the file there.
NOTE editing the FluidNC Settings: Config Items does not permanently save, this area is just for testing.
Microstep Resolution¶
The first step I needed to complete was to make sure my Microstep Resolution was set correctly.
I am using clones of the Pololu TI DRV8825 Stepper Motor Driver Carriers so I needed to look up the jumper configuration I was running. On the DRV8825 chip microstepping is handled with the following pins:
- Pin 9 is ENABLE (Turns the steppers on and off)
- Pin 10 is M0 (MODE0)
- Pin 11 is M1 (MODE1)
- Pin 12 is M2 (MODE2)
If a jumper is added to these pins 5VDC jumps into these pins pushing them high.
For X and Y I had jumpers on pin 11 MODE1 of the DRV8825, so based on the following chart from the Pololu link above:
MODE0 | MODE1 | MODE2 | Microstep Resolution |
---|---|---|---|
Low | Low | Low | Full step |
High | Low | Low | 1/2 step |
Low | High | Low | 1/4 step |
High | High | Low | 1/8 step |
Low | Low | High | 1/16 step |
High | Low | High | 1/32 step |
Low | High | High | 1/32 step |
High | High | High | 1/32 step |
X and Y on my board are therefore:
MODE0 | MODE1 | MODE2 | Microstep Resolution |
---|---|---|---|
Low | High | Low | 1/4 step |
And Z has only pin 10 MODE0 jumped resulting in:
MODE0 | MODE1 | MODE2 | Microstep Resolution |
---|---|---|---|
High | Low | Low | 1/2 step |
Steps per mm maths¶
This means that the maths to get the steps per mm is:
My steps per mm calculations:
X axis steps_per_mm¶
Steps/rev: 360 deg / Step Angle 1.8Deg = 200 Microsteps: 4 micro steps per step (1/4 step) Belt Pitch: 3mm Pulley Teeth: 20
srev is the number of steps per revolution for the motor fm is the microstepping factor (1, 2, 4, 8 etc.) p is the pitch Nt is the number of teeth on the pulley attached to the motor shaft.
srev * fm / p * Nt 200 * 4 / 3 * 20 = 800 / 60 = 13.333 steps per mm [steps_per_mm]
Y axis steps_per_mm¶
Belt Pitch: 3mm Steps/rev: 360 deg / Step Angle 1.8Deg = 200 Roller Diameter: 42.9mm Microsteps: 4 micro steps per step (1/4 step)
srev is the number of steps per revolution for the motor Nf is the number of teeth on the final (passive) pulley fm is the microstepping factor (1, 2, 4, 8 etc.) Nm is the number of teeth on the motor pulley Dr is the diameter of the roller
srev * Nf * fm / Nm * piDr 200 * 20 * 4 / 20 * (3.14159 * 42.9) = 16000 / 2695.48422 = 5.936 steps per mm
However, as expected, the variable slip vs grip nature of the grip taped Y Axis rollers needed steps per mm adjustment.
Using the helpful info GRBL Steps Per mm – How to Fine Tune Your Settings I re-calibrated.
On a 441.7 mm move the actual cut length was 444.5
Updated Steps/mm = (Current Steps/mm) x (Commanded Travel) / Actual Cut Length
5.936 * 441.7 / 444.5 = 5.899
5.899 Adjusted steps per mm
Z axis steps_per_mm¶
8mm Metric Acme Lead Screw This Tr8*8-2p(4 starts) trapezoidal Lead Screw results in a pitch of 8mm. Pitch of a lead screw is the distance traveled with one revolution. In this case one revolution results in 8mm movement. If you are not sure of a threaded rod pitch simply put a nut on it and rotate it 1 revolution and measure the distance moved.
Z motor (steps/rev): 360 deg / Step Angle 1.8Deg = 200 Z Microsteps: 8 micro steps per step (1/8 step) Z threaded rod pitch (mm): 8 Pulley Teeth: 1 (direct drive)
srev is the number of steps per revolution for the motor fm is the microstepping factor (1, 2, 4, 8 etc.) p is the pitch Nt is the number of teeth on the pulley attached to the motor shaft. For direct drive use 1.
srev * fm / p * Nt 200 * 2 / 8 * 1 = 400 / 8 = 50 steps per mm
Axis | Steps per mm | Setting Command |
---|---|---|
X | 13.333 | $100=13.333 |
Y | 5.899 | $101=5.899 |
Z | 50 | $102=50 |
Max Feed Rates max_rate_mm_per_min¶
Jogging the machine was painfully slow. So I updated the following Max rate, mm/min
X 8000
Y 8000
Z 4000
Acceleration acceleration_mm_per_sec2¶
Acceleration could be increased as well
X 3000
Y 3000
Z 200
Turn on and off Steppers idle_ms:¶
255
turns the stepper motors on indefinitely after making a move holding them in position. This leads to more energy use and hot steppers, but to make sure stuff is not bumped out of position this option is helpful.
250
turns off the stepper motors after 25 milliseconds (default)
For the Foam Crawler, there is significant cutting force applied during cutting and my Z-Axis is low friction I decided to use the 255
option.
Max travel¶
Note: I need to install homing switches and enable homing before this feature will work!
The Foam Crawler has a work envelope of:
X = 620mm
Y = 1220mm (max foam sheet length readily available Y Axis is actually infinite)
Z = 35mm
X 620
Y 1220
Z 35
Invert axes direction¶
X and Y axes were backeards or inverted in the FluidNCWebUI. In order to flip them around I could invert two pairs of physical wires on the stepper motors. Or I could change the following parameters in the config file:
x: direction_pin: gpio.14:low Y: direction_pin: gpio.15:low
I changed the config file.
FoamCrawler config.yaml file¶
When you build your own foamn crawler, you can skip most of the configuration by downloadign my custom FoamCrawler config yaml file here:
NOTE: Remember to restart your machine and ESP32 after uploading the config.yaml file via FluidNCWebUI, FluidNC, Manage local files.
Notes for future projects¶
ESP32 FabKit¶
Eventually I will make my own version of a ESP32 devkit module, called the “ESP32 FabKit Module” it will be simpler and contain less parts than espressif’s devkit. It will use a serial port instead of a USB port for programming. A USB to Serial converter (like the FTDI USB TTL cable or your own USB to serial programmer) will be required to initially program the ESP32 FabKit.
FabStick¶
I will also make my own stepper motor driver carrier boards based on the Pololu DRV8825 Stepper Motor Driver Carrier or the Pololu DRV8434S SPI Stepper Motor Driver Carrier using a TI DRV8434S Driver. I will add these sub-boards to the 3PakCNC v2 motherboard.
A SilentStepStick TMC2130 driver carrier board might be interesting for quieter operation as well.