OpenValence Download

Barnacle mod

An M5Stack Stamp-P4 wired onto the OSSM R+D reference board, rev 2.3. The P4 runs Nucleus and sends A/B quadrature straight to the motor. The board's ESP32-WROOM-32D stays on as an I/O helper.

Eight wires from seven Stamp pads. The R+D board gets no new parts.

WIP Firmware. nucleus-p4b, the Nucleus build for the barnacle, and the WROOM shim firmware are prereleases. Status

What it is

The Stamp-P4 takes over motion. Three wires (A, B, GND) carry A/B quadrature from the P4's LP core to the motor's pulse and direction inputs. On a stock R+D build the motor connects to J12, the 4-pin header (PU+, PU−, DIR+, DIR−), plus power on J2. On the barnacle J12 stays empty.

Five more wires go to J8 on the R+D board, a 10-pin header that is normally unused; the barnacle uses it for the P4 link: 5 V, GND, a serial link each way, and TRIP. The WROOM runs the shim firmware. It reads motor current, motor voltage and the button, drives the RGB LED, and reports to the P4 at 115200 baud.

Motor power stays on J2 SERVO POWER. The current sensor sits in that path, so the helper sees motor current only while the motor draws from J2.

The barnacle wiringTwo groups of wires end on Stamp-P4 pads 7 to 19. Five wires come from J8 on the R+D board: pin 1 GND to pad 13, pin 2 to pad 17 TX, pin 7 to pad 7 TRIP, pin 9 to pad 19 RX, and pin 10 5V to pad 15. Three go to the motor: pad 9 A to PUL+, pad 11 B to DIR+, and pad 13 GND to PUL− and DIR−, jumpered at the motor. Pad 13 carries both ground wires. J8 pins 3 to 6 and 8 stay unused. Motor power stays on J2.R+D board · J8 1 GND · ALM− 2 TX in · ALM+ 3 GND · PED− 4 spare in · PED+ 5 spare out · ENA− 6 5V · ENA+ 7 TRIP · DIR− 8 5V · DIR+ 9 RX out · PUL−10 5V · PUL+motor power stays on J2Stamp-P4 · pads7 TRIP9 A11 B13 GND15 5V17 TX19 RXMotor · signal inPUL+DIR+PUL−DIR−ENA ALM PEDnot connectedA/B pulse inputpad 13: two GND wireson one pad
  • 5V, red
  • GND, black
  • TX, yellow: P4 to WROOM
  • RX, green: WROOM to P4
  • TRIP, orange: active low
  • A, blue
  • B, violet
Both groups of wires end on Stamp pads 7 to 19. Both grounds land on pad 13. Wire colors are a suggestion.

Stopping the machine

The R+D board has no motor power switch and no Modbus link to the motor. In this build, the motor's enable line, ENA, is unconnected. Software cannot cut motor power.

Two things stop the motor: the P4 stops its A/B output, or the E-stop cuts power. Wire the E-stop as the reference build does. Use a latching switch that breaks the AC mains to the power supply (step 6).

Overcurrent protection stays with the motor. The current and voltage the helper reports are for monitoring and homing.

Parts

PartQtyNotes
M5Stack Stamp-P41The ESP32-P4 module. It has no radio of its own.
M5Stack Stamp-AddOn C61Wi-Fi and BLE. Plugs into the Stamp's SDIO connector.
OSSM R+D board, rev 2.31With its ESP32-WROOM-32D.
Wire8 runs5 from the Stamp to J8, 3 from the Stamp to the motor's signal input. Wire and connectors are the builder's choice; straight wire works.
Electrolytic capacitor1220 to 470 µF, 6.3 V or more, for the Stamp's 5 V.
USB to RS485 adapter1For the motor setup in step 0.
Latching E-stop1Rated for your mains voltage and the supply's input current.
Heat shrinksomeFor any splice and the capacitor leads.

Tools

Build

0. Set up the motor

The R+D board has no Modbus link to the motor. Set up the motor first, over its own RS485 port (Modbus RTU), with the USB to RS485 adapter. Caution: the motor misreads quadrature in pulse and direction mode. Set the command input to A/B pulse input.

The motor setup tool finds the motor at 9600, 19200, 38400 or 115200 baud and applies the barnacle's settings. It runs in Chrome or Edge on a desktop. It is a work in progress. Unplug the adapter when you are done: the barnacle does not use RS485.

1. Flash the firmware

Flash both boards before any wire goes on, from the web flasher in Chrome or Edge on a desktop. The flasher loads the newest release. On a board that is already wired, disconnect the wires from J8 first.

  1. Flash the WROOM over the R+D board's USB-C, with nothing else powering the board. Open the flasher's Helper card. Use barnacle-shim 0.1.82 or newer. After this, the WROOM needs USB only for recovery.
  2. Flash the Stamp-P4 over its own USB-C. Open the flasher's Barnacle card. It loads nucleus-p4b. To have it join your network on first boot, fill in Pre-program Wi-Fi before you write.

Later updates go over the network from Phosphor. On the machine's System page, the Firmware card takes the release's app image (nucleus-p4b-version-app.bin, from the release on GitHub). Press Update. Then double-press PAIR at the machine: on the barnacle, S2 on the R+D board.

Each nucleus-p4b image carries the WROOM's firmware. When the WROOM runs any other build, the Stamp installs its copy over J8. The install starts as soon as no motion runs and takes about 40 s (an estimate, not yet measured). The machine loses its home position when the update starts: home the machine again when the update finishes. Motion started during the update stops the update. The WROOM keeps its old firmware, and the update starts over once motion stops. A WROOM on a barnacle-shim release older than 0.1.82 cannot take updates this way. The machine logs that and works as before until you flash the WROOM over USB once.

2. Prep the Stamp

Plug the Stamp-AddOn C6 into the SDIO connector, at the lower left of the Stamp's top side, beside the USB-C.

Find pad 1: top left, at the camera connector end. The left column runs 1 to 19, top to bottom. On that column the odd pads are through-hole and the even pads are castellated only. The wiring uses the through-hole pads, so it solders like any through-hole part.

Stamp-P4, top view, with the seven wired padsThe M5Stack Stamp-P4 seen from the top, 22 by 28 mm, drawn to scale from M5Stack's footprint. Pads 1 to 19 run down the left edge and 20 to 38 down the right edge at 1.27 mm pitch. The odd pads on the left and the even pads on the right are through-hole. Pads 46 to 65 run along the top edge (RMII, then MIPI DSI) and 39 to 45 along the bottom, with pad 42 a wide ground pad under the USB-C connector, which overhangs the bottom edge. The ESP32-P4 sits in the upper middle with the camera connector above it and the flash to its right. The SDIO connector, where the Stamp-AddOn C6 plugs in, sits at the lower left beside the USB-C. The barnacle wires pads 7 to 19 from the back: 7 LPG8 TRIP, 9 LPG1 A, 11 LPG0 B, 13 GND, 15 VBUS 5V, 17 G27 TX, 19 G26 RX.cameraESP32-P410 x 10 mmflashSDIO · C6USB-C46 G3247 G3648 G3549 G4150 G3351 G3152 G2853 G3054 G2955 G5256 GND57 D0_N58 D0_P59 GND60 CK_P61 CK_N62 GND63 D1_N64 D1_P65 GNDRMIIMIPI DSI39 SYS_5V40 USB2 DP41 USB2 DM43 G2444 G2545 LPG342 GNDwired from the back1 LPG152 LPG143 LPG124 LPG115 LPG106 LPG97 LPG8TRIP8 LPG79 LPG1A10 G5011 LPG0B12 G4913 GNDGND14 5VIN15 VBUS5V16 LPG417 G27TX18 LPG619 G26RX20 G2321 G2222 G2123 G2024 G1925 G1826 G1727 G1628 3V329 LPG1330 G37 U0TXD31 G3932 G38 U0RXD33 G3434 EN35 LPG536 G35 BOOT37 LPG238 GND
Top view, to scale from M5Stack's footprint. Rings are through-hole pads, per M5Stack's pinmap; plain pads are castellated only. Pads 1 to 19 and 20 to 38 sit at 1.27 mm pitch. Part positions on the module are approximate; the USB-C overhangs the bottom edge by about 2.3 mm.

Pad 15 is the Stamp's USB-C VBUS. From there, 5 V passes an overvoltage switch (AW32901) and a CH213K ideal diode to the module's 5 V rail. An SY8089 buck, rated 600 mA, makes 3.3 V. So 5 V can come in on pad 15.

  1. Bring the wires, or a 7-pin header, in from the back of the Stamp. Put them into pads 7, 9, 11, 13, 15, 17 and 19. On the top side a header body would sit on the SDIO connector.
  2. Solder from the top.
  3. Check for bridges to the castellated pads between them: 8, 10, 12, 14, 16 and 18.

The through-hole pads sit 2.54 mm apart. A 2.50 mm pitch header also goes in: over 7 pins each end pin sits 0.12 mm off its pad's center.

4. Wire the motor

Three wires from the Stamp to the motor's signal input.

The motor wiringThree wires run from the Stamp-P4 pads to the motor's signal input. Pad 9, A, goes to PUL+. Pad 11, B, goes to DIR+. Pad 13, GND, goes to PUL− and DIR−, jumpered together at the motor. ENA, ALM and PED stay open. The motor is set to A/B pulse input. Pads 7, 15, 17 and 19 go to J8 on the R+D board.Stamp-P4 pads7 TRIP9 A11 B13 GND15 5V17 TX19 RX7, 15, 17, 19: to J8Motor, signal inPUL+DIR+PUL−DIR−ENA: openALM: openPED: openABGNDjumper atthe motorA/B pulse input
A and B swapped only reverses direction. The ground jumper sits at the motor end.

The motor's opto inputs take 3.3 V straight from the P4, with no level shifter. That works on the bench and over 3 m of shielded Cat5 from an ESP32-S3. The P4's pins drive the same as the S3's: 20 mA by default, 40 mA source and 28 mA sink at drive strength 3.

Pad 13 takes two ground wires, this one and the one from J8 pin 1. Put both in the pad, or splice one onto the other close to the Stamp.

5. Wire J8 on the R+D board

Five wires from the Stamp to J8. J8 is normally unused on the R+D board; its connector is on the back.

SignalStamp padJ8 pin
TRIP77
GND131
5V1510
TX172
RX199
OSSM R+D board rev 2.3, top view, not to scaleThe R+D reference board seen from the top, not to scale, parts in their true relative places. J10 PWR IN at the top left, then S1 RESET, the ESP32-WROOM-32D module at the top center with its antenna at the edge, and the RJ45 remote port at the top right. The USB-C connector J3 is on the right edge. On the left edge, the U6 current sensor (IO36) sits above J2 SERVO POWER. Along the bottom edge runs J8, a 10-pin header that is normally unused, pin 1 square at the left next to button S2; its connector is on the back. Transistors Q3, Q4 and Q5 sit below pins 5, 7 and 9. The barnacle uses J8 pins 1 GND, 2 TX in, 7 TRIP, 9 RX out and 10 5V. J12, the 4-pin header the motor connects to on a stock build and empty on the barnacle, sits center bottom, and the expansion headers sit bottom right as four vertical columns, left to right J6 3V3 with 4 pins, J9 GPIO (IO2, IO15, IO33, IO22 top to bottom), J7 GND with 4 pins and J4 RS232 with 3 pins (GND, TX, RX top to bottom), pin 1 square at the top of each.not to scale+J10 PWR INsupply inS1RESETantennaESP32-WROOM-32Dthe I/O helperruns the shim firmwareRJ45remote portANA1, ANA2J3 USB-CCP2102, UART0flashes the WROOMU6CH701 hall sensorIO36: CURRENTJ2 SERVO POWERmotor power out1GND2TX in34567TRIP89RX out105VJ8connector on the backS2 BTNQ3Q4Q5DIR−DIR+PU−PU+J12, empty hereJ63V3IO2IO15IO33IO22J9GPIOJ7GNDJ4RS232
Not to scale; parts in their true relative places. J8's connector body is on the back of the board, the only connector there, so its pins are drawn from the top. The five used pins are in their wire colors.

J8 pins 7 and 9 sit between 5 V pins (6, 8 and 10). A wire one position off puts 5 V on a P4 pin, and the P4 does not survive it. Measure before the wires reach the Stamp (step 7).

Fit the capacitor at the Stamp end, across 5V and GND. Keep it within a few centimeters of pads 15 and 13. Connect its negative lead to GND. The capacitor supplies the Wi-Fi transmit bursts.

6. Wire the E-stop

Put the latching E-stop in the AC mains feed to the power supply, as on the reference build. Pressing it powers down everything: the motor, the R+D board and the Stamp. The P4 boots unhomed when power returns, so you home again before the next run. Keep the motor's DC supply on J2 SERVO POWER: the current sensor sees only what flows through it.

7. Pre-power checks

  1. With nothing powered, check continuity on every wire, end to end, against the point-to-point table.
  2. Check for shorts between neighboring Stamp pads, most of all 15 (5V) and its neighbors 13 (GND) and 17 (TX).
  3. With the wires not yet on the Stamp, power the R+D board. At their Stamp ends, measure to GND: the 5V wire reads about 4.5 V. TX, RX and TRIP read 3.3 V or less. Anything near 5 V on a signal means a wire sits on the wrong J8 pin.
  4. Confirm the motor is in A/B pulse input mode (step 0) with ENA, ALM and PED unconnected.

8. First power-on and current check

  1. Unplug USB-C from the Stamp.
  2. Connect the wires to the Stamp with the meter's milliamp range in series with the 5V wire.
  3. Power the R+D board. Read the Stamp's draw with Wi-Fi active. Expect about 350 mA average, with bursts near 600 mA. If the draw is well above that, the R+D 5 V rail has no room left. Stop and find out why.
  4. Take the meter out, reconnect the 5V wire, then power the motor.

Before the first run, confirm jog speed, jog accel and input jerk once in Phosphor's Setup, then home.

Reference

Point to point

SignalStamp-P4 padOther endNotes
TRIP7 · LPG8R+D J8 pin 7 (DIR−)Open collector from Q4 (WROOM IO27). Low means tripped. P4 internal pull-up on.
A9 · LPG1Motor PUL+3.3 V quadrature from the P4's LP core.
B11 · LPG0Motor DIR+3.3 V quadrature. LPG0 and LPG1 double as 32 kHz crystal pins; no 32 kHz crystal is fitted, so both are free.
GND13 · GNDMotor PUL− and DIR− (jumpered), and R+D J8 pin 1Two wires on one pad, or a short splice.
5V15 · VBUSR+D J8 pin 10 (PUL+)About 4.5 V: the R+D 5 V rail sits after a Schottky diode. Pins 6 and 8 are the same rail.
TX17 · G27R+D J8 pin 2 (ALM+)P4 to WROOM. Lands on WROOM IO13, which has a 10 kΩ pull-up to 3.3 V on the board.
RX19 · G26R+D J8 pin 9 (PUL−)WROOM to P4. Open collector from Q5 (WROOM IO14). P4 internal pull-up on.

R+D J8 pinout

J8 is a 10-pin header, normally unused on the R+D board; pin 1 is the square pad. In and out are from the WROOM's side. Q3 to Q5 are BC817 transistors with 220 Ω base resistors. They only sink, and their collectors are the minus pins.

PinPin nameOn the R+D boardBarnacle use
1ALM−GNDGND
2ALM+WROOM IO13, 10 kΩ pull-up to 3.3 VTX in, from the P4
3PED−GNDunused
4PED+WROOM IO4spare in
5ENA−Q3 collector, from IO26spare out
6ENA+5 Vunused
7DIR−Q4 collector, from IO27TRIP, active low
8DIR+5 Vunused
9PUL−Q5 collector, from IO14RX out, to the P4
10PUL+5 V5V to the Stamp

WROOM helper pin map

FunctionWROOM GPIOWhere
Link RX, from the P4IO13J8 pin 2
Link TX, to the P4IO14Q5 to J8 pin 9, TX inverted in the shim
TRIPIO27Q4 to J8 pin 7, active low on the wire
Motor currentIO36, ADCCH701 hall sensor in series with J2, 10k/20k divider
Motor voltageIO39, ADC1:40 divider
ButtonIO23S2
RGB LEDIO25WS2813
ANA1, ANA2IO35, IO34RJ45 remote port
Spare in, spare outIO4, IO26J8 pins 4 and 5

The shim leaves UART0 (IO1, IO3) alone. The CP2102 owns it, so the WROOM still flashes over the R+D board's own USB-C.

Power budget

The Stamp takes 5 V from the R+D board's 5 V rail: an LMR14006 buck rated 0.6 A, after a B1100 Schottky diode, so about 4.5 V at J8. The board's own loads share it. These numbers are estimates; step 8 measures the largest.

Load on the R+D 5 V railAveragePeak
Stamp-P4 and C6, Wi-Fi onabout 350 mAabout 600 mA, transmit bursts
R+D 3.3 V loads: WROOM with its radio off, RGB LED40 to 100 mA
Current sensorabout 10 mA
Total, against 600 mA400 to 450 mAabout 700 mA, brief

The average fits. The 220 to 470 µF capacitor at the Stamp carries the short peaks.

Do not power the Stamp from the R+D board's 3.3 V. That rail comes from an ME6211C33 regulator in SOT-23-5, which would dissipate about 0.4 W at the Stamp's load, more than that package can shed.

Pad 15 is the same net as the Stamp's USB-C VBUS. With the J8 wires connected, a computer on the Stamp's USB-C also powers the R+D board's 5 V loads. Disconnect them before you flash over USB, or update over the network from Phosphor (step 1).

The link uses only parts already on the R+D board.

How RX, TRIP and TX cross the R+D boardThree signal paths. RX: the WROOM's inverted UART TX on IO14 drives transistor Q5 through 220 ohms; Q5's collector is J8 pin 9, which runs to the P4's G26, held at 3.3 V by the P4's 45 kilohm internal pull-up. Q5 can only pull the line low. TRIP: IO27 drives Q4 the same way; its collector, J8 pin 7, runs to the P4's LPG8 with the same internal pull-up, so the line idles high and a trip pulls it low. TX: the P4's G27 drives J8 pin 2 directly into the WROOM's IO13, which has a 10 kilohm pull-up to 3.3 V on the R+D board.RX · WROOM to P4IO14 TX220 ΩQ5J8 93.3 V45 kΩG26 RXTRIP · active lowIO27220 ΩQ4J8 73.3 V45 kΩLPG8 TRIPTX · P4 to WROOMIO13 RX3.3 V10 kΩJ8 2G27 TXBlue boxes: inside the Stamp-P4.
Q4 and Q5 only sink. The P4's 45 kΩ internal pull-up sets the high level at 3.3 V.

Troubleshooting

The Stamp does not power up
Measure pad 15 to pad 13: about 4.5 V. No voltage: check the wire on J8 pin 10 and the GND wire to J8 pin 1.
A signal wire reads near 5 V
It sits one position off on J8, onto pin 6, 8 or 10. Fix it before the Stamp goes on.
The motor does not move
Check the motor is in A/B pulse input mode (step 0) and that PUL− and DIR− are jumpered to GND at the motor.
The motor runs the wrong way
A and B are swapped. Swap the two wires at the motor.
TRIP reads tripped all the time
With the helper running, J8 pin 7 idles at 3.3 V. Low: the shim holds IO27 high or has hung, or the pin 7 wire is wrong.
No data over the link
Check that TX on pad 17 connects to J8 pin 2. Check that RX on pad 19 connects to J8 pin 9. Both ends run at 115200 baud. The shim inverts its TX.
Motor current reads zero
The motor draws its power from somewhere other than J2. Move the motor power connection to J2 SERVO POWER.
A home is refused before it moves
The helper reads current with the motor at rest, or has no current zero yet. It takes the zero with the motor still, about 4 s after power-on. Power-cycle the R+D board with the motor still, then home.
A home fails: the link to the helper is lost
The link to the WROOM stopped during the home. Check the wires on J8 pins 2 and 9, then home again.
The Stamp resets when Wi-Fi transmits
The 5 V sags on transmit bursts. Check the bulk capacitor is fitted at the Stamp end and its polarity is right.
The R+D board lights up while you flash the Stamp
USB-C on the Stamp feeds the R+D 5 V rail through the 5V wire. Disconnect the wires to J8, or update over the network from Phosphor.
The WROOM will not flash
Flash it over the R+D board's USB-C. The CP2102 there owns UART0. The web flasher has a Helper card for it.

Status WIP

The firmware is WIP. Both pieces are prereleases on the web flasher.

  • nucleus-p4b, the Nucleus build for the barnacle: A on LPG1, B on LPG0, TRIP on LPG8 (active low), the link on G27 (TX) and G26 (RX) at 115200 baud, internal pull-ups on RX and TRIP.
  • The WROOM shim firmware: streams button, current and voltage to the P4, drives the RGB LED on request, and pulls TRIP on a current spike during homing, at the threshold the P4 sets for each home. Outside homing the current sensor only reports. It takes its updates from the P4 over J8, and runs a new image as a trial until the P4 confirms it.
  • The motor setup tool for step 0.
  • The web flasher for the Stamp-P4 and WROOM images, from Chrome or Edge.