Machine Building Preparation¶
Dual H-Bridge chip Board¶
Ref. Norwway bootcamp

![]() |
![]() |
|
![]() |
![]() |
![]() |
BOM¶
| Item | Qty |
|---|---|
| Xiao RP2040 | 1 |
| DRV8421A Dual H-Bridge Stepper Driver | 1 |
| 100uF | 1 |
| 0.1uF 1206 | 1 |
| S4B-XH-SM4-TB or 1x4 SMD Pinheader |
1 |
| 1x2 SMD Pinheader | 1 |
| 1x7 SMD Vertical Pinsocket | 2 |

| Moduler Things | BootCamp Leon2024 | BootCamp Norway2026 |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| OA2, OA1, OB1, OB2 | OA1, OA2, OB1, OB2 | Out1, Out2, Out3, Out4 (OA1, OA2, OB1, OB2) |
| stepperDriver.cpp | ||
| #define AIN1_PIN 6 // on D4 | #define AIN1_PIN 7 // on D5 | #define AIN1_PIN 29 //(IN1) on D3 |
| #define AIN2_PIN 7 // on D5 | #define AIN2_PIN 0 // on D6 | #define AIN2_PIN 6 //(IN2) on D4 |
| #define BIN1_PIN 28 // on D2 | #define BIN1_PIN 2 // on D8 | #define BIN1_PIN 4 //(IN3) on D2 |
| #define BIN2_PIN 4 // on D9 | #define BIN2_PIN 4 // on D9 | #define BIN2_PIN 28 //(IN4) on D9 |
| #define APWM_PIN 27 // on D1 | #define APWM_PIN 6 // on D4 | |
| #define BPWM_PIN 29 // on D3 | #define BPWM_PIN 3 // on D10 | |
| simple_stepper.ino | ||
| #define PIN_LIMIT 26 // on D0 | #define PIN_LIMIT 29 // on D3 | #define PIN_LIMIT 26 // on D0 |
| Reference | ||
| Moduler Things site(Tips) | FA24_JPN FA24_NGA FA25 |
class page |
DRV8421A sample code¶
DRV8421A sample code (click to view)
| DRV8421A_sample.cpp | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
Stepper Motor¶


Rated Volatage 2.8 V
Current/phase 1.65 A
Resistance/phase 1.68 OHM
Inductance/phase 3.2 mH
Holding Torque 3.2 Kg-cm
Orientation Torque 150 g-cm
Firmware¶
In gitlab (arduino and python)
.
└── simple_stepper
├── cobs.cpp
├── cobs.h
├── COBSUSBSerial.cpp
├── COBSUSBSerial.h
├── fixedPointUtes.cpp
├── fixedPointUtes.h
├── lutgen.js
├── motionStateMachine.cpp
├── motionStateMachine.h
├── serializationUtes.cpp
├── serializationUtes.h
├── simple_stepper.ino
├── stepperDriver.cpp
├── stepperDriver.h
└── stepperLUT.h
| stepperDriver.cpp | |
|---|---|
4 5 6 7 8 | |
| simple_stepper.ino | |
|---|---|
6 | |
Note
using the RP2040 at 200MHz
Python¶
Python code
The code is designed for Python >= 3.10
Dependencies:
pyserial >= 3.4
cobs >= 1.1
% python3 --version
Python 3.13.5
# Check pyserial version (if installed)
% python3 -c "import serial; print(serial.__version__)"
3.5
# Install or update pyserial if missing or outdated
% python3 -m pip install --user --upgrade pyserial
# Check cobs version
% python3 -c "import cobs; print(cobs.__version__)"
1.2.1
# Install or update pyserial and cobs if needed
% python3 -m pip install --user --upgrade pyserial cobs
.
├── __pycache__
│ ├── cobs_usb_serial.cpython-312.pyc
│ └── motor.cpython-312.pyc
├── cobs_usb_serial.py
├── coreXY.py
├── coreXYZ.py
├── linearAxis.py
├── main_test_gantry.py
├── main_test.py
├── motor.py
└── two_axis.py
Code¶
Serial port
% ls /dev/cu.usb*
/dev/cu.usbmodem1101
| linearAxis.py | |
|---|---|
33 | |
linearAxis.py (click to view)
| linearAxis.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
CoreXY¶
coreXY.py (click to view)
| coreXY.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
CoreXYZ + UI (Not yet tested)¶
https://core-xyz.com/theory.html
coreXYZ.py (click to view)
| coreXYZ.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
Screw shop¶
Next Spiral development¶
DRV8421A MicroPython Implementation (1/32 Microstepping) with PIO (Not yet tested)¶
firmware.py (click to view)
| firmware.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
COREXYZ¶
coreXYZ.py (click to view)
| coreXYZ.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |











