Skip to content
Workshop: repairs and experiments

Bosch dishwasher board SWS4118: our own firmware — relays, sensors, pump, heater (part 3)

Published 19.11.2026
Contents 16
  1. What we already know
  2. The board ground and mains: why the ST-Link must not stay connected
  3. Tools
  4. Where we start: measurements before the first connection
  5. Stage 1: the heater relays and raw sensor readings, off mains
  6. Stage 2: degrees, off mains
  7. A display with buttons
  8. Stage 3: motor signals off mains
  9. The first run on mains: the log only
  10. Current protection and current measurement
  11. Stage 4: the first pump run from the buttons
  12. Power for the power module's gate drivers
  13. Motor parameters for field-oriented control
  14. The next stages
  15. Appendix: ST Motor Profiler
  16. Article changelog

Part three covers the Bosch dishwasher board 702168823.01GA / SWS4118 Rev.4. In part one we copied the EEPROM and the original firmware, and in part two we mapped the board: which microcontroller pin controls what. Here comes our own firmware, stage by stage: from the relays and sensors off mains to the pump's first turns. In this article:

  • what we already know, briefly;
  • why no computer may be connected to the board while it runs on mains, and how we work without a USB isolator;
  • the tools, and the measurements before connecting the ST-Link for the first time;
  • stages 1–3 off mains: the heater relays and the temperature sensor, degrees, the motor control signals;
  • a display with buttons, to see the firmware's state without a computer;
  • the first run on mains: a log in flash memory, and the pin that keeps the board powered;
  • current protection as in the original firmware;
  • stage 4: the pump on mains, the heater rules, and the supply for the power module's gate drivers;
  • motor parameters for field-oriented control, and the next stages.

draft — writing the firmware stage by stage

⚠ Our firmware erases the original one. We made copies of the original in part one; it can be put back with the same ST-Link.

What we already know

All from the measurements in part two and from the stages below:

WhatMicrocontroller pins
heater relays91 (PB5) and 68 (PA9), through 4.7 kΩ
JW2SN relay (pump changeover)60 (PD13); off means the power module drives our pump with the heater (the original firmware starts it the same way)
keeping the board powered on mains7 (PC13): as long as it is high, the board's power supply runs (below)
power module driver supply (VCC)92 (PB6): pulses through a charge pump, no VCC without them; 47 (PB10): apparently the feedback (below)
power module inputs39–44 (PE8–PE13), timer TIM1, through 1 kΩ
phase current shunts35 (PB0), 52 (PB13), 48 (PB11), comparator inputs that shut TIM1 down
heater temperature sensor34 (PC5) and 26 (PA3), through 47 kΩ; the middle wire is ground
clock8 MHz resonator (marked 80.K) on pins 12 and 13
free pins for a display and buttons63–65, 78–80: TIM8 outputs meant for a second inverter the board does not have; they lead to the empty second-module footprint (part two)

The tables converting ADC readings to degrees are in the original firmware (part two); it is the same board, so they can be used as they are.

The board ground and mains: why the ST-Link must not stay connected

The microcontroller drives the power module directly, through 1 kΩ resistors, with no optocouplers (see part two). So its ground is the minus of the 325 V bus, and the bus minus is connected to both mains wires through the bridge diodes. The board ground is not separated from mains: every other half-cycle, when the live wire L is negative relative to earth, it sits at nearly the full mains voltage.

Suppose an ST-Link and a desktop computer are connected to the board at that moment. On a desktop computer the USB ground is tied to the socket earth, so a short-circuit current from mains flows through a bridge diode, the board ground, the ST-Link and the USB cable. The board's ground traces, the ST-Link and the computer's USB port can burn out; at best the RCD trips. If the socket has no earth, the computer case can sit at up to a hundred volts AC through the power supply's filter, and the RCD may not trip. A laptop on battery with nothing else plugged in will not carry a short-circuit current, but its case and ports end up at the board's voltage and are dangerous to touch. If the laptop is plugged into its charger, a monitor or a network cable, it is the same as a desktop.

How to check with a multimeter. The plug is out of the socket and the big capacitor is discharged: check on DC volts that it reads about 0 V. Then three measurements:

  1. Microcontroller ground (pin 74 or pad X20.5) to module pin 1 (COM), continuity: a beep means the microcontroller ground and the module ground are one and the same.
  2. Microcontroller ground to the minus of the big capacitor, continuity or resistance: a beep or under 1 Ω.
  3. The minus of the big capacitor to L and N on the mains connector, diode test, both ways round: red probe on the capacitor minus, black on L or N, 0.4–0.7 V; the other way round, a small reading that rises to OL (the meter is charging the capacitor), which is normal.

If all three match, the board ground is definitely tied to mains. If they do not, that does not prove the ground is separate: a fuse, relay or thermistor may sit in the path. Be just as careful either way.

What our board has already shown. Two observations from the later stages confirm that the microcontroller ground is the power module ground. On mains the pump runs on 3.3 V signals that the microcontroller feeds to the module through 1 kΩ resistors with no isolation at all, which only works with a shared ground. And the shunt pin with no current sits at 0.43 V relative to X20.5, exactly what a 10 kΩ / 1.5 kΩ divider from 3.3 V gives when the bottom end of the shunt (the module's COM) is on the microcontroller ground ("Current protection"). On mains the power bus charges to 296–300 V. Not checked yet:

  • we did not record the direct continuity checks from points 1–3;
  • we have not measured whether the capacitor minus connects to L and N through the bridge diodes; we act as if it does.

A USB isolator would be safer for the computer: a cheap module built around an ADuM3160 chip breaks the electrical connection between the computer and the board, so you can watch the firmware while the board is on mains. But the ST-Link, the wires and the board beyond the isolator are still at mains voltage and must not be touched. We do not have one, so we work without it, in a strict order:

  1. Flash the firmware only with the plug out of the socket and the capacitor discharged (about 0 V); the ST-Link powers the board.
  2. Before switching mains on, disconnect all the ST-Link wires from the board, not just the USB cable from the computer. After switching mains off, wait again and check the capacitor reads about 0 V before touching the board.
  3. What the firmware did while running on mains it writes to a dedicated area of the microcontroller's own flash; read it back later, off mains, through the ST-Link.
  4. Never connect a mains-powered oscilloscope's ground clip to the live board: its ground is also tied to the socket earth, with the same result.
  5. You may measure the live board with a multimeter, since it runs on a battery. Use a meter rated for 600 V, CAT II or higher; put the black probe on the board ground, not on earth; work with one hand and touch only the insulated probes. The meter and its probes are then at the board's voltage too.

The order for starting the pump on mains:

  1. Off mains. Firmware with the relays and sensors; the ST-Link powers the microcontroller. Then the module control signals: check the TIM1 outputs at the module inputs (pins 4, 5, 9, 10, 14, 15) with the power stage unpowered.
  2. Protection in the firmware before the very first pulse: dead time between the high-side and low-side switches, the TIM1 emergency shutdown from the shunts, a start from low voltage with a gentle ramp-up, a watchdog.
  3. The pump's first run on mains (preceded by the log-only run, see "The first run on mains"): all the ST-Link wires disconnected from the board (flash the firmware, then unplug; see above in this section for why); with a USB isolator it could stay connected (the computer would be protected, but the board would still be at mains voltage), but we do not have one. We deliberately do not put an incandescent bulb in series with the mains lead, although it is often done: it would limit the current if something went wrong. So everything rests on the firmware protection from point 2 and on checking the signals off mains in point 1; the board's own mains fuse stays in place. Feed the mains through a residual-current device (RCD), but an RCD does not make the board safe to touch: do not touch the board while it is powered. The pump must have water in it.

Tools

WhatWhy
ST-Link V2to flash the firmware and talk to it without stopping it
STM32CubeProgrammerST's free software; we need its command-line STM32_Programmer_CLI
Arm GNU Toolchainthe free arm-none-eabi-gcc compiler for Arm microcontrollers
multimeterto check the levels on the pins

The firmware is written without ST's libraries, directly on the registers from the RM0316 reference manual: every register write is visible in the code, and nothing extra gets switched on.

The X20 pads labelled: where to connect the ST-Link
The X20 pads from left to right: 1 SWCLK, 2 SWDIO, 3 NRST (optional), 4 PB4 (leave unconnected), 5 GND, 6 3.3 V. The frame colours match the wires on the ST-Link wiring diagram. More in part one.

Where we start: measurements before the first connection

We have neither of the usual safeguards: no incandescent bulb in series with the mains lead and no USB isolator. So we check everything that could cause damage with a multimeter beforehand, and we connect the board to the computer only when it is off mains.

BoardST-Link and USBWhy
off mains, powered by the ST-Linkallowed, after the measurements belowthe only voltage on the board is 3.3 V from the ST-Link itself (once the capacitor is discharged, step 1)
on mainsnever: every ST-Link wire disconnectedthe board ground is tied to mains, and the USB cable would short it to the computer's earth (section above)

No measurement gets around the second rule. In every other half-cycle the board ground sits at mains voltage, and whatever the multimeter showed beforehand, the USB cable will connect it to the computer's earth. So we don't watch the statistics live while the board is on mains; we read them from a log the firmware writes into its own flash memory (section "The first run on mains").

Measurements off mains, before connecting the ST-Link to the computer for the first time. You will also need a USB power meter (USB tester) between the computer and the ST-Link: it shows the current, so you can see what the board draws.

  1. Voltage on the big capacitor: plug out of the socket, multimeter on DC volts, ≈ 0 V; otherwise wait and measure again.
  2. Whether the board ground is tied to mains: the three measurements from "The board ground and mains".
  3. Resistance between pads 6 (3.3 V) and 5 (GND) of X20, both polarities: a small number at first that rises (the capacitors charge) and settles at hundreds of ohms or more. Steadily below ≈ 10 Ω means a short on the 3.3 V rail: do not connect the ST-Link.
  4. ST-Link current without the board: USB tester between the computer and the ST-Link; write the number down, it is the "zero" for step 5.
  5. ST-Link current with the board: connect the ST-Link to X20 with USB unplugged, then plug USB in through the USB tester. Expect a few tens of milliamps more than in step 4. Above ≈ 150 mA, the ST-Link LED going out or the computer reporting a port overload: unplug USB at once.
  6. Voltage on pad 6: ≈ 3.3 V, not below ≈ 3.0 V; lower means the ST-Link regulator can't cope with the board (part one).
  7. The supply voltage as the firmware sees it: after flashing the stage 1 firmware, mailbox field +24 (stage 1), ≈ 3300 mV. A difference from the multimeter of more than ≈ 100 mV: sort it out before the next stages.

What we got. Pad 6 read 3.289 V and the firmware showed 3297 mV (3293–3300 mV in the log): under 10 mV apart, so the ST-Link regulator copes with the board, and there were no restarts from a sagging supply. We did not write down the numbers for steps 3–5; if you repeat this, do, they are useful for comparison.

Why the ≈ 150 mA limit: ST-Link clones have a small 3.3 V regulator rated for 100–200 mA. The microcontroller itself draws a few milliamps at 8 MHz and the rest of the 3.3 V rail a few tens more; anything above 150 mA means something extra is running off 3.3 V or there is a leak.

💡 You can put a USB hub with its own power supply between the computer and the ST-Link: if something goes wrong off mains, the hub's port suffers first, not the computer's. It only protects against overcurrent: the hub does not break the ground connection, and it gives no protection on mains; there the only rule is that the ST-Link is disconnected.

Stage 1: the heater relays and raw sensor readings, off mains

What the stage 1 firmware does:

  1. Right after start-up it drives all the power module inputs (pins 39–44) low, so the module's switches are off; timer TIM1 is not started at all. The JW2SN relay is off.
  2. On a command from the computer it switches on the heater relays: the left one (pin 91), the right one (68) or both. Each switches itself off after 30 seconds unless the command is repeated.
  3. Every 100 ms it measures both temperature sensor inputs (pins 34 and 26) and shows the raw ADC numbers, 0–4095.
  4. A watchdog: if the program hangs, the microcontroller restarts in about a second, and all the outputs are off again.
  5. Statistics (version 2): the microcontroller's supply voltage measured against its internal reference, the lowest and highest value of both sensor inputs since start-up, and the board's start-up number.
  6. A log (version 2): every 10 seconds it writes a record to its own flash memory; we read it after running on mains (section "The first run on mains").

How the firmware talks to the computer. No extra wires or serial port are needed: the ST-Link can read and write the microcontroller's memory without stopping the program. At address 0x20000000 the firmware keeps a "mailbox": a "stage 1 is running" marker, the relay command, the raw ADC numbers, the supply voltage, the statistics and the log state.

The stage 1 mailbox: what is at which offset
OffsetWhat is there
+000x53575331: the stage 1 firmware is running
+04firmware version (2)
+08milliseconds since start-up
+0Ccommand: the computer writes 0xA50000xx, bit 0 is the left relay, bit 1 the right; the firmware clears it
+10which relays are on right now
+14milliseconds left until the automatic switch-off
+18raw ADC of pin 34 (PC5, X13.3)
+1Craw ADC of pin 26 (PA3, X13.5)
+20the reason for the last restart
+24the microcontroller's supply voltage (VDDA), mV
+28ADC of pin 34 since start-up: lowest (low 16 bits) and highest (high 16 bits)
+2Cthe same for pin 26
+30VDDA since start-up: lowest and highest, mV
+34the board's start-up number (from the log)
+38how many log records have been written since start-up
+3Cslot for the next log record (0–127)

The commands for ST's command-line programmer:

# read the mailbox
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -r32 0x20000000 0x40
# switch the left heater relay on for 30 s (right: 0xA5000002, both: 0xA5000003, off: 0xA5000000)
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -w32 0x2000000C 0xA5000001
# before reading the log, stop it until the board restarts
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -w32 0x2000000C 0xA6000000
# read the log: the last 4 KB of flash memory, into a file
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -u 0x0803F000 0x1000 log.bin

How to check it off mains. The plug is out of the socket, the capacitor is discharged, the ST-Link powers the board. The relay coils need 12 V, so the relays will not click off mains; check the pins and test points with a multimeter instead. Points 1 and 6 are the inputs of the left and right transistors that switch the heater relay coils (driver photo in part two); the JW2SN transistor input is the transistor end of the 472 resistor.

CheckExpectedResult
mailbox +000x53575331✔ 0x53575331
left relay on: point 1 relative to ground≈ 0.6–0.8 V; after 30 s, 0 V✔ 0.70 V; after 30 s, 0 V
right relay on: point 6 relative to ground≈ 0.6–0.8 V; after 30 s, 0 V✔ 0.71 V; after 30 s, 0 V
JW2SN relay (pin 60): the transistor input, pin set high from the programmer≈ 0.6–0.8 V; after switching back, the pin reads 0✔ 0.756 V; after switching back, the pin reads 0 (IDR register)
pins 39–44 and 60 at all times0 V✔ 0 V on all six module inputs; pin 60 also 0 (outside the JW2SN check)
ADC of pin 34 at room temperaturethe number from table 1 or 2 near 20 °C (2439 or 2948)✔ 2339: by table 1 that is ≈ 22.7 °C (with no sensor, 4091–4093)
ADC of pin 26 at room temperaturethe same✔ 2863: by table 2 that is ≈ 22.6 °C
mailbox +24 (VDDA)≈ 3300 mV✔ 3297 mV; 3293–3300 mV in the log
mailbox +34 after each restartone higher✔ starts 6–18 follow in order in the log, none from the watchdog
mailbox +38 after a minute6–7 (the start-up record, then one every 10 s)✔ 4 at 32 s, 8 at 77 s
mailbox +3Cnot 0xFFFFFFFF✔ 0x61, then 0x65: the log is being written

If +3C stays at 0xFFFFFFFF, the log is not being written: check the option bytes (STM32_Programmer_CLI -c port=SWD -ob displ) for write protection on the last flash pages.

Off mains the relays do not click, so we measured the input of the transistor that switches the coil (points 1 and 6): 0.7 V there means the microcontroller pin is high and the transistor is on. Two small things we ran into. After writing the command, the programmer reports "Failed to download data": the firmware clears the command at once, so when the programmer reads it back it sees 0. The command has been carried out regardless, and the relay state shows in mailbox +10. And the cheap ST-Link clone connected unreliably; it is more reliable to connect under reset first (the NRST wire on pad 3, mode=UR) and only then switch to hot-plug mode (mode=HOTPLUG).

The stage 1 firmware does not switch the JW2SN relay on, and it drives pin 60 low on every pass of its loop, so simply writing a 1 from the programmer does not work: the firmware sets it back to 0 at once. To test it, we used the programmer to switch the pin over to timer TIM4 (channel 2, which the original firmware used to drive this relay) in forced-active mode (always high): while the pin belongs to the timer, the firmware's writes to the output register have no effect on it. After the measurement we switched the pin back to a plain output and turned the timer and its clock off, and it went low again. We do this check off mains only.

The two ADC numbers show which table from the original firmware (part two) belongs to which input: at 20 °C table 1 gives 2439 and table 2 gives 2948. Measured: pin 34 is table 1, pin 26 is table 2. With this assignment both sensors read almost the same, 22.7 and 22.6 °C; with the tables swapped they would read 38 and 8 °C.

Stage 2: degrees, off mains

The stage 2 firmware does everything stage 1 does and also converts the readings of both sensors into degrees Celsius using the original firmware's tables: pin 34 uses table 1, pin 26 uses table 2 (we worked out which goes with which at stage 1).

How the firmware calculates:

  1. Between table points it interpolates linearly, as the original firmware most likely does too. The result is a whole number of tenths of a degree, with no floating point.
  2. Outside the table (colder than 0 °C or hotter than 125 °C) it does not make up degrees; it reports the sensor state instead.
  3. It reports an open circuit and a short separately. With no sensor the input reads close to full scale (4000 or more), and a short to ground reads close to zero (up to 100).

The mailbox has two new fields, and the marker at the start has changed to 0x53575332, i.e. "stage 2":

OffsetWhat it holds
+40temperature of pin 34 by table 1, in tenths of °C: 234 = 23.4 °C
+44the same for pin 26 by table 2
instead of degrees: 0x7FFF0001 open circuit, …02 short, …04 below 0 °C, …05 above 125 °C

The flash log has not changed; the program that reads it now shows degrees as well.

What we measured. The ST-Link powers the board, the plug is out of the socket, the sensors are connected:

CheckResult
room, thermometer ≈ 23 °Cpin 34: 23.4–23.9 °C; pin 26: 23.2–23.7 °C
heating with a hair dryer, 72 s, a reading every ~1.5 sboth sensors rose smoothly to 58.1 and 53.7 °C and back; 55 readings, no restarts
difference between the sensors while heatingpin 34 read 2–4 °C higher: the hair dryer heated them unevenly

Why we are sure the tables are not swapped: with them the other way round, at 23 °C in the room one sensor would read 39.3 °C and the other 9.5 °C. While heating, the gap between them would reach 30–40 °C, even though they sit next to each other.

It is better to check against a thermometer in water, where everything is at the same temperature. A hair dryer heats unevenly: our thermometer was closer to it and reached 80 °C, while the sensors reached 58 °C. We will do the check in water once the sensors are in the water heater itself.

A display with buttons

The ST-Link must not be connected on mains, so the only way to see the firmware's state live is a display. We took a small 0.96″ OLED module, 128 × 64 dots (SSD1315 controller, I2C bus, 3.3 V supply), with four buttons. It has one colour: a dot is either lit or dark.

We wired it to the free pins 63–65 and 78–80, behind which nothing is fitted on our board (part two). The wires are soldered into the empty footprint for a second power module; those holes connect to the pins through 1 kΩ resistors, so both the I2C bus and the buttons go through them. That does no harm: the firmware found the display at address 0x3C without a single bus error. Power comes from pads 6 (3.3 V) and 5 (ground) of connector X20.

DisplayMicrocontroller pin
SCL63 (PC6)
SDA64 (PC7)
K1 ▲65 (PC8)
K2 ▼78 (PC10)
K3 #79 (PC11)
K4 *80 (PC12)

The screen has several pages: both sensor temperatures, the supply voltage, the relay state, the time since start and the log records; the raw ADC numbers and service data; the stage 3 motor test; and from stage 4 on, the pump pages too (see stage 4). Buttons K1 and K2 switch pages. The firmware works out at start whether a button pulls its pin to ground or to the supply, so we keep our hands off the buttons while powering up.

⚠ On mains the board ground is at mains potential, and so are the display and the buttons. That is why at stages 1–3 the buttons switched nothing on and only turned pages, and we did not touch them on mains. For stage 4 the display module with its buttons sits in a closed insulated enclosure.

Stage 3: motor signals off mains

Before spinning the motor on mains for the first time, we check that timer TIM1 feeds the FSB50550AB power module inputs exactly what we intend. The key point is that the high-side and low-side switches of one phase are never on together: on mains that is a short circuit through the module, and it would burn out instantly.

How we check it without an oscilloscope. A multimeter shows the average voltage. The firmware goes through 12 steps of 20 s each (buttons K3 and K4 step forward and back, so we don't have to wait):

  • static states: 3.3 V on one input, 0 on the rest. This shows that each pin leads to its own module input;
  • 50% PWM on one phase at 20 kHz. Between one switch turning off and the other turning on, the firmware keeps a 2 µs dead time (the module needs at least 1 µs, and the original firmware also uses 2 µs). Without it the high-side and low-side inputs would add up to 3.3 V; with it each one is high only 46% of the time: ≈ 1.5 V each, ≈ 3.0 V together. The missing 0.3 V is the dead time, and an ordinary multimeter shows it;
  • 25% PWM: the high-side input ≈ 0.7 V, the low-side ≈ 2.3 V, so the duty cycle changes in the right direction.

The expected voltages are calculated, not measured. The firmware also checks itself: it reads the levels of all six pins and counts how many times the high-side and low-side input of one phase were high together. Even one such case and it switches the timer off at once and shows FAULT on the display. This is a rough guard against a configuration mistake: a software read will not catch an overlap of a fraction of a microsecond, and the dead time itself is shown by the multimeter.

Stage 3: where to put the multimeter probes on the power module inputs and what each step should show
Meter minus on pad 5 of connector X20 (ground), plus on the circled pins one at a time.

Safety. The test starts only on a command over the ST-Link, and we connect the ST-Link only off mains. On mains the test cannot start, and the display buttons do not start it. The motor is disconnected and the plug is out. Off mains the module's power stage has no supply: the switches do not turn on and nothing spins. We are checking the control signals only.

The module is unpowered now, and its inputs may pull the voltage down a little. If every step reads clearly lower than expected, we measure the same step on the other side of the 1 kΩ resistor that sits on each input, the microcontroller side.

StepsWhat we checkExpectedResult
1, 12everything offall six pins 0 Vmatches
2–7each input on its own: 4, 5, 9, 10, 14, 15its own pin ≈ 3.3 V, the rest 0matches
8–1050% PWM on phases U, V, W≈ 1.5 + 1.5 V, ≈ 3.0 V togethermatches
1125% PWM on phase Upin 4 ≈ 0.7 V, pin 5 ≈ 2.3 Vmatches
allthe firmware's self-check: "high-side and low-side together"0, no FAULT0, no FAULT; the levels of all 8 static steps matched

Result (2026-11-16). The multimeter showed every one of the 12 steps exactly as in the picture: each module input leads to its own pin, at 50% PWM the two inputs of a phase add up to less than 3.3 V, so the dead time is there, and at 25% PWM the voltages split the right way. Throughout the test the firmware never once saw "high-side and low-side together". The motor control signals are ready; next comes the emergency shutdown on shunt current.

The first run on mains: the log only

The first time the board goes on mains, it runs the stage 3 firmware: it does everything stage 2 does (relays, degrees, the log) and also has the display and the motor test. On mains it does not start timer TIM1, it holds the power module inputs low, and there are no relay commands because the ST-Link is disconnected. So nothing switches on from mains: neither the pump nor the heater. It starts the motor test only on a command over the ST-Link. We learn three things:

  • whether the board's own power supply gives a steady 3.3 V: the VDDA voltage in the log;
  • whether both sensors show the same numbers and degrees as off mains;
  • whether the microcontroller restarts from interference while the board is on mains: start-up records with the watchdog as the reason.

The order:

  1. The firmware is written, and the measurements from "Where we start" and the stage 1 checks have passed.
  2. Disconnect every ST-Link wire from the board.
  3. The board lies on a dry insulating surface with nothing metal nearby. The heater is disconnected from the board; the pump is disconnected or has water in it. Feed mains through an RCD. We do not use an incandescent bulb; the fuse on the board stays in place.
  4. Switch on for 1–2 minutes with a switched extension lead placed away from the board: that is 7–13 log records. Do not touch the board. The relays should not click. If one has clicked, or the RCD has tripped, or the fuse has blown, switch off at once and go no further until the cause is found.
  5. Unplug, wait a few minutes, and check with a multimeter that the big capacitor is at ≈ 0 V.
  6. Connect the ST-Link (wires to X20 first, then USB), stop the log straight away and then read it (the commands are under stage 1). Stopping it first means the firmware, now powered by the ST-Link, will not erase the page holding the mains records.

The last start-up in the log is the ST-Link itself powering the board for the readout: the firmware boots and writes its record. "POR+PIN" as the reason at power-on is normal: the microcontroller sets both flags.

What the first run showed. With the stage 3 firmware (version 6) the board ran on mains for about a second: the display lit up and went dark, the log kept a single start-up record and nothing more. The power bus was charged to 296 V all the while. We put the original firmware back for a while: with it, 3.35 V held steadily on mains. So the original firmware does something that keeps the power on, and ours did not. When idle, the original firmware holds 17 pins as outputs at set levels, while ours left them as inputs. We repeated that state in our firmware and narrowed it down by halving: each time we kept half of the pins, switched mains on for 30 s and watched the 3.3 V on a multimeter. After six tries one was left: pin 7 (PC13). As long as it is high, the board's power supply runs. Our firmware now sets it high as the very first thing after start-up. A continuity check showed where it goes: through a diode and a 473 (47 kΩ) resistor to a "1GW 37" transistor next to the power supply. Later, at stage 4, it turned out that with pin 7 alone the board sometimes switched off at a pump start or stop; the firmware now holds all 17 pins at idle the same way the original does (below).

Microcontroller pin 7 (PC13): diode D, resistor 473 and the transistor that keep the board powered from mains
The dashed line only shows the direction of the trace, not its exact route.

The second run (stage 3, version 7) went fine: the board ran on mains for over a minute; the results are in the table.

What is in the logExpectedResult
a start-up record with the reason PORone for every time it goes on mainsone per switch-on
VDDA from the board's own supply≈ 3300 mV and steady throughout3373–3375 mV throughout
ADC of both sensor inputsthe same numbers as off mains (room temperature)the same: 23.8 and 23.6 °C (on the ST-Link, 23.4 and 23.2 °C)
watchdog resets (IWDG)nonenone
interval between records10 s: 0, 10, 20 … s after start-up10 s, records from 0 to 60 s

The log. It takes the last 4 KB of the microcontroller's flash memory: 128 records of 32 bytes in a ring, between about 11 and 21 minutes of running (when a new page starts, the older of the two pages is erased whole, 64 records). Each record has a number and a checksum, so if power is cut in the middle of a write, that record is simply skipped when the log is read. We write new firmware without a full erase, so the log and the boot counter survive; restoring the original firmware (a full 256 KB copy) wipes the log. A record holds the board's start-up number and the seconds since start-up, the VDDA voltage, the lowest and highest value of both sensor inputs over the last 10 s, and for a start-up record the reason: power-on, the reset button or the watchdog. From stage 4 on, a record is written every 60 s at idle and every second while the pump runs (stage 4).

Each of the two log pages is erased about every 21 minutes. At this rate the flash endurance (10,000 erase cycles) lasts about 148 days of continuous running. If the supply voltage is below 2.7 V, the firmware does not touch the flash at all. That is enough for experiments; for permanent use we'll make the interval between records longer.

Current protection and current measurement

The FSB50550AB power module handles 2.0 A continuously (1.5 A at 80 °C) and up to 5 A for no longer than 100 ms, and it has no short-circuit protection of its own: it only shuts down when its gate driver supply VCC sags. So the microcontroller has to protect it, and faster than the program could react.

How the original firmware does it. We took its code apart and found the settings in its initialisation data. Three of the microcontroller's comparators (COMP4–COMP6) watch the voltage on the three phase shunts, a digital-to-analog converter sets the threshold (1806 of 4095, ≈ 1.46 V), and each comparator's output goes to the timer's emergency input. As soon as a shunt voltage crosses the threshold, the timer switches all six outputs to the module off in hardware, without the program. Two independent matches tell us we read it right: the comparators look at exactly the pins that tracing led to the shunts, and we had already read the number 1806 from the live board. Our firmware sets everything up the same way, including the filter that ignores glitches shorter than ≈ 3.6 µs.

Self-test. At every start-up the firmware flips each comparator in turn, as if the current had crossed the threshold, and checks that the timer really switched the outputs off. The outputs to the module stay low throughout, so this is safe on mains too. The pump may start only if all three comparators pass.

Shunts and the threshold in amps. Each phase has two R820 resistors (0.82 Ω) in parallel: we measured 0.41 Ω on all three. The shunt goes to the microcontroller pin through 1.5 kΩ, and there is also a 10 kΩ resistor to 3.3 V. With no current the pin sits at ≈ 0.43 V (multimeter: 0.4272 V), and the calculation for such a divider gives the same. So the comparator sees not the shunt voltage itself but 10/11.5 of it plus 0.43 V, and trips at ≈ 2.9 A [calculated]. That is below the module's pulse limit.

Measuring the current. The ADC measures the same pins for phases U and V: the firmware records the "zeros" at start-up and works out the current in milliamps, taking the divider into account. The phase W pin has no ADC channel, only a comparator input; two phases are enough to drive the motor, since the third current equals minus the sum of the other two.

72 MHz. Before running the motor, we switched the microcontroller from its internal 8 MHz oscillator to the external resonator: 8 MHz × 9 = 72 MHz, as in the original firmware. The PWM pulse width then has 1800 steps instead of 200, which matters for a smooth sine at low voltage. The dead time stayed at 2 µs: the firmware itself measured the fraction of time an input is high at 50% PWM as 45.5% on the high-side input of phase U and 46.2% on the low-side one (46% by calculation).

Stage 4: the first pump run from the buttons

We start the pump from the buttons and watch its state on the display. The firmware does not switch the JW2SN relay on: in its normal state it already connects the module to our pump. Before a start the module gets its gate driver supply (see the section below). Every second of pump operation the firmware logs the phase currents, frequency and voltage; these records go to flash after the stop, so that the processor is not stalled while the motor turns.

How we spin it. There is no rotor position sensor, so the first run uses the simplest open-loop control: three sines 120° apart, the frequency rising smoothly to the chosen one, and the voltage rising with the frequency (3% plus 0.4% per hertz, of half the bus voltage). The rotor follows the rotating field. With too little voltage it stands still and hums, drawing little current; with too much, the current rises and one of the limits below stops the pump. There are eight speeds, as in the original firmware for our pump: 1500, 2000 … 5000 rpm, that is, field frequencies from 75 to 250 Hz (the rotor has three pole pairs, see motor parameters). The amplitude is capped at 90% (from ≈ 218 Hz the voltage no longer rises). The ramp is 100 rpm per second, preceded by 0.3 s for the rotor to settle into position. These speeds are set, not measured: the firmware cannot yet see whether the rotor keeps up with the field.

⚠ The voltage-to-frequency curve is our guess, not data from the original firmware (which uses field-oriented control). At high speed under load the rotor may fall behind the field; the current then rises, and the 1.5 A software limit stops the pump.

Off-mains check: a sine for the multimeter. A separate test drives a very slow field (0.2 Hz) with a large amplitude that a multimeter can follow on the module inputs. It starts only on a command over the ST-Link, and we connect the ST-Link only off mains. The firmware showed the PWM interrupt running ≈ 20,000 times a second, with the widest pulse moving from phase to phase, U → V → W.

Buttons and display. The display module with its buttons sits in a closed insulated enclosure: on mains it is at mains potential. The instructions are on the display itself, in Ukrainian: the «НАСОС» (pump) page shows the state, speed, frequency, voltage, current, run time and the last event, and the bottom line tells what each button does right now; a separate «КНОПКИ» (buttons) page holds the full instructions.

ButtonWhat it does
▲ ▼display pages
* (hold for 2 s)start the pump, always at the lowest speed
*stop
#one speed step up
# (hold for 2 s)"VCC only" test: pulses without a pump start
# during the "VCC only" testnext pulse frequency

Run limits (version 24) (each one stops the pump on its own; the reason goes to the display and the log):

LimitValue
hardware protection≈ 2.9 A, comparators, without the program
software current limit1.5 A, five readings in a row
auto-stopafter 120 s
microcontroller supplybelow 3.0 V: stop
startonly if the protection self-test passed

How the runs on mains went. The heater stayed disconnected throughout. On the first run there was warm water in the pump hose; the dry runs (versions 20 and 21) were deliberate: short, on the bench, without the heater. The "pump must have water in it" rule from "The board ground and mains" is for running with the heater. Everything except the sound comes from the flash log.

  • The first run: the pump stayed silent, with no current in the phases. At first we suspected that the JW2SN relay, when off, leads to the drain pump, and switched it on for the run: the relay clicked, but there was still no current. The real cause lay elsewhere: the power module had no gate driver supply (below). Taking the original firmware apart later confirmed that with the relay off, the module drives our pump.
  • Version 20, the first dry run: the pump followed the field smoothly, at the start, with the field at ≈ 3 Hz, about one turn a second by ear; phase current 14–112 mA; no protection tripped. But the field reached only 10–12 Hz instead of the chosen 50 (speed step 8 at the time) in the 30 s before the auto-stop (it tripped after 30 s back then): the ramp was six times slower than intended. The display was to blame: the firmware spent ≈ 50 ms in a row drawing one line, the main loop stood still, and the ramp added a step only once per pass of the loop. The lesson: we time the ramp by the clock and update the display in small pieces, since the software current limit and the buttons also depend on how fast the loop runs.
  • Version 21: a 2 Hz/s ramp, as intended; in 30 s the field reached 41.6 Hz because we raised the speed step from the button gradually (the field rises only when it has somewhere to go); current 0–129 mA, no protection tripped, no restarts. Whether the rotor kept up with the field at 30–40 Hz we don't know: without water the current is small at any speed.
  • A mess on the screen: on mains (versions 20 and 21) the screen filled with junk, although off mains it works cleanly and the firmware sees no bus errors. Interference apparently scrambles the display controller's settings. So from version 22 the firmware resends the settings every ≈ 0.5 s, and the display recovers by itself; this has not been tried on mains yet.
  • Versions 23 and 24, the speeds: in version 23 we took the speeds from the original firmware, but, as it turned out, from the drain pump's set (a 25…58 Hz field). Working out how the original firmware switches the JW2SN relay before a start showed that with the relay off it runs the 1500…5000 rpm set with three pole pairs, which is our pump. This matches the "about one turn a second" at a ≈ 3 Hz field from the first dry run. Off mains, version 24 ramps at 5 Hz/s to 250 Hz with the amplitude capped at 90%. It has not been run on mains with the new speeds yet.

The heater only while the pump is running. The heater is part of the pump. It is a flow-through heater built for a constant flow of water, and without flow it overheats and can burn out the motor or melt the housing. So the firmware lets the heater switch on only while the pump is running, and any stop of the pump switches the heater off at once. The temperature sensors sit on the heater itself, so we added them to the rules as well. The heater is allowed only when all of these hold:

ConditionValue
the pump is runningstopping the pump switches the heater off at once
water is really flowingthe pump has been turning for at least 4.5 s, the field has ramped up to at least 1400 rpm (set, not measured), and its current is ≥ 80 mA
both sensors are healthythey read between −10 and 95 °C; anything else means an open circuit or a short
the sensors agreewithin 15 °C; a bigger gap blocks the heater until the gap is back to ≤ 13 °C
no overheatingthe hotter sensor above 82 °C blocks the heater until it is back to 77 °C or below
below the set temperatureonce reached, the heater goes off; allowed again after cooling by 2 °C

The set temperature is 50 °C for now; we will change it from the buttons in the heating mode. The status page of the display (labelled «СТАН» on the display itself) shows whether the heater may switch on and, if not, why. These rules are in version 25, which has not been written to the board yet; for the first run the heater is disconnected altogether.

How the original firmware controls the heater, and what we took

At first we chose the heater limits ourselves, with a margin. Then we worked out how the original firmware does it and took most of its rules: they have been proven in the field on thousands of machines.

RuleOriginal firmwareOurs
the pump is runningyes, the main (circulation) pump specificallyyes
water is really flowingpump current ≥ 80 mA, ≥ 4.5 s after the hand-over to the observer (the rotor position estimate), speed ≥ 1400 rpmcurrent ≥ 80 mA (averaged), ≥ 4.5 s from the start of rotation, the field ramped up to at least 1400 rpm (set speed) — softer (see below)
sensors healthy−10…95 °Cthe same
sensors disagreemore than 15 °C blocks the heater, allowed again at ≤ 13 °Cthe same
overheatingsensor 2 above 82 °C blocks the heater, allowed again at ≤ 77 °Cthe same, but we watch the hotter of the two sensors, which is stricter
set temperatureset by the wash programme50 °C with 2 °C hysteresis (fixed for now)
relay switch-on orderthe pin-68 relay for 50 ms → a 250 ms pause → the pin-91 relay → the pin-68 relay againthe same
relay switch-offthe pin-68 relay first, the pin-91 relay 50 ms laterthe same
relay coilfull signal first, then holding at ≈ 70%100 ms at full signal, then 70%
relay contact checkyes (we have not worked out what exactly it measures)no

Why our "water is really flowing" condition is softer: we do not measure the rotor speed yet, and the 4.5 s count starts earlier, from the start of rotation rather than from the hand-over to the observer.

⚠ Our firmware still measures the pump current roughly: the measurement is not tied to the PWM pulse. So for us the 80 mA threshold is a guide; we will refine it by measuring with water and without, and we can rely on it once we port the current measurement from the original firmware.

Heater relays: pull in at full, hold at 70%

A relay is an electromagnet: current in the coil pulls the armature in, and the contacts close. Pulling the armature in across the air gap takes a lot of force. Holding it once it is in takes much less: the armature sits right against the core, and the magnetic circuit is closed.

How it works:

  1. As soon as a relay switches on, the firmware applies a steady "1" to the coil transistor for 100 ms: full voltage, the armature pulls in firmly and the contacts close.
  2. Then the same pin gets a 16 kHz PWM signal (16,000 pulses a second): "1" for 70% of the time, "0" for 30%. The coil has inductance, so its current does not have time to fall during these short gaps and stays at about 70% of full. That is enough to keep the armature from dropping out.
  3. 16 kHz is above what most adults can hear, so the relay does not whine or buzz.

The benefits:

  • the coil draws less current and runs cooler: heating goes with the square of the current, so at 70% current it is only about 49% of full. This matters for the heater relays, since they stay on for minutes;
  • less load on the board's power supply.

How the firmware sets it up:

  • the relays are wired to timer outputs: pin 68 (PA9) to TIM2, pin 91 (PB5) to TIM3;
  • frequency: 72 MHz ÷ 3 ÷ 1500 = 16 kHz;
  • duty: 1050 out of 1500 = 70%;
  • for each relay, the firmware simply switches the timer output mode: "always 0" (off), "always 1" (pull-in) or PWM (hold).

The original firmware uses almost the same numbers: 1049 out of 1500 (69.9%).

Why the relays switch on in turn. The two relays sit in series in the heater circuit. First the pin-68 relay clicks briefly on its own, then the pin-91 relay switches on on its own: while the other is open, no current flows through the heater, so this is a safe check. The heater current is always made and broken by the same relay (pin 68), while the other (pin 91) switches with no current. So only one relay ever sparks, and the other remains a backup break in case the first one's contacts weld.

Power for the power module's gate drivers

What the first pump run showed. On mains the pump did not turn, and there was no current in the phases at all. The multimeter showed why: the module had its bus voltage (≈ 300 V on pin 17), but the gate driver supply VCC (pins 3, 8 and 13, tied together) was 0 V. Without that supply the module does not turn on a single switch, whatever the microcontroller sends it. One more thing: a few times the board switched off right at a pump start or stop. That stopped once our firmware began holding all 17 pins at idle the same way the original does (see the first run on mains), not just pin 7.

Where VCC comes from. We followed the trace from pin 3 of the module and worked through the nearby parts one by one (photo below):

  • A PNP transistor marked "5BW" connects the module's VCC to the 13.5 V supply. Without pulses both of its upper legs read 13.46 V: the base equals the emitter, so the transistor is off.
  • Another NPN transistor marked "1GW" turns it on (not the one that holds the power from pin 7).
  • The base of "1GW" is fed by a diode charge pump. At its heart is a part marked "A7W", two diodes in series; we call its pins D1–D3. In diode-test mode: ground to D3 reads 0.6 V, D3 to D1 0.6 V, ground to D1 1.16 V, and nothing flows the other way. So D2 is ground, D3 is the common point of the diodes, where the pulses arrive, and D1 is the output.
  • Next to it is a capacitor: one end is on ground, and the other leads through a 472 (4.7 kΩ) resistor to pin 92 of the microcontroller (PB6). It is most likely a filter; we have not yet found the coupling capacitor through which the pulses reach D3.

A charge pump only passes changes in voltage, so a steady high level on any pin will not start it. That is why nothing worked at first: we set steady levels on eight pins that the original firmware configures as outputs and sent pulses to three others, and VCC never appeared.

How the original firmware does it. Its code has a function that reads the state of PB6 and writes back the opposite, which means the firmware toggles the pin in software every time it runs its safety task. A second function, for faults, turns PB6 into an input and locks its configuration until the microcontroller restarts: the pulses stop and the module is left without its driver supply. Another function reads pin 47 (PB10); it looks like the firmware uses it to check that the chain has responded. We have not worked out from the code how often it toggles PB6.

How our firmware does it. Timer TIM4 sends a 1 kHz square wave at 50% duty to PB6. Pump start: pulses first, the drive signals to the module 0.3 s later; after a stop the pulses are removed. For checking there is a "VCC only" test: holding the # button for 2 s turns the pulses on without starting the pump, and a short press of # steps through frequencies from 100 Hz to 20 kHz.

The gate driver supply area of the power module: pin 92 (PB6), the capacitor, "A7W", the "1GW" and "5BW" transistors, voltages with and without pulses

Measurements (multimeter, DC, relative to pin 1 of the module; motor and heater disconnected):

PointNo pulses1 kHz pulses on PB6
module VCC (pin 3)0 V13.48 V
D1 of "A7W" (charge pump output)0 V2.095 V
upper legs of "5BW"13.46 Vnot measured
module bus (pin 17)≈ 300 Vnot measured

Pin 47 (PB10) on the display: 0 while the pulses run; when they are removed it shows 1 for a moment, then 0 again. We have not yet traced where it leads on the board.

It also works as a safeguard. The module has its driver supply only for as long as the microcontroller keeps toggling PB6. When VCC drops below its threshold of 7.4–9.4 V (the datasheet spread), the module turns all its switches off by itself. So this chain can serve as a second way to shut down, independent of the TIM1 outputs. What is already there and what we plan:

  • the program hangs: in the original firmware the pulses stop along with it. Ours currently come from a timer, and a timer keeps running even when the program has hung. For now the watchdog covers this case: it restarts the microcontroller in about 1 s, and after the reset PB6 becomes an input. Next we will move the PB6 toggling into the program, as the original firmware does, so that VCC disappears at once;
  • a fault (overcurrent, running dry, overheating): besides turning off the TIM1 outputs, also remove the pulses, so the switches turn off even if the outputs to the module were somehow left on. For now the pulses are removed only after the pump stops;
  • a serious fault: PB6 will become an input with its configuration locked until a restart, as in the original firmware;
  • a start-up check: stop the pulses and wait for pin 47 to change; the pump may start only after that. This is not in place yet.

Motor parameters for field-oriented control

So far we have been running the pump "blind": we apply a rotating field and do not check whether the rotor keeps up with it. The original firmware uses field-oriented control: it measures the phase currents all the time and works out from them where the rotor is and how fast it turns. For that it needs the parameters of the motor itself:

ParameterWhat it is
number of pole pairshow many pairs of magnetic poles the rotor has; links the field frequency to the speed
winding resistance Rsthe resistance of one phase
winding inductance Lsthe inductance of one phase: how fast the current in the winding can change
back-EMF constant (Ke)the voltage the rotor induces in the windings per unit of speed: this is how the firmware "sees" the rotor
current and voltage limitswhat the motor and the power module can take

What we found in the original firmware. It holds three motor parameter sets. The set it runs with the JW2SN relay off is our pump: speeds of 1500…5000 rpm and a field frequency that corresponds to three pole pairs. We counted 9 coils on the stator, so the rotor most likely has 6 magnetic poles, the most common combination for such a stator. Resistance and inductance are not stored separately: there are ready-made coefficients for working out the rotor position, with these values already "baked in". One of them is 3596 out of 4096 (0.878). If it has the usual form 1 − Rs · Ts / Ls, and the original firmware's cycle is 200 µs (10 kHz PWM, with the two motors computed in turn, so each about 5,000 times a second), then the electrical time constant of the winding, Ls / Rs, is about 1.6 ms [calc.]. This is our estimate, not a measurement.

How to measure the parameters of an unfamiliar motor

  • Pole pairs — run a compass round the rotor: the needle flips 2 × p times; or spin the shaft at a known speed n (rpm) and measure the frequency f of the winding voltage: p = 60 · f / n
  • Resistance Rs — the resistance between two phases, divided by 2; more accurately, pass a known DC current between two phases, work out the resistance from the voltage drop, and divide by 2 as well
  • Inductance Ls — an LCR meter between two phases at 100 Hz, reading divided by 2; or a short voltage pulse between two phases: L = U · Δt / ΔI, divided by 2 (the pulse much shorter than Ls / Rs)
  • Back-EMF constant Ke — spin the shaft with a drill at a known speed and measure the AC voltage between two phases; conventions vary: ST, for example, gives it as the RMS voltage between two phases per 1000 rpm
  • Current and voltage limits — from the motor and power module datasheets (ours is the FSB50550AB: 2 A continuous, up to 5 A for no longer than 100 ms)

Dividing by 2 gives the value for one phase of a star connection, which is what the control needs (for delta-connected windings it gives the equivalent star). If the magnets are buried inside the rotor, the inductance depends on the rotor position, and it is then measured at several positions.

⚠ The "clicks" you feel when turning the rotor by hand do not equal the number of poles: per revolution there are as many as the least common multiple of the number of stator teeth and the number of poles. For our pump (9 teeth, 6 poles) that is 18 clicks, which would suggest 9 pole pairs instead of 3.

⚠ Measure the windings only with the motor disconnected from the board. When the shaft is spun with a drill, voltage appears on the leads, and a motor built for 300 V can produce hundreds of volts at high speed. So spin it slowly, and clip the probes on before spinning the shaft. Do not short the leads together.

How to turn them into coefficients

  • Current controller. Its bandwidth is usually set about ten times below the loop rate: for about 5,000 cycles a second, around 500 Hz. Then the proportional gain is Ls · ω and the integral gain is Rs · ω, where ω = 2π · 500; in a program that runs in cycles, the integral gain is also multiplied by the cycle time Ts.
  • Working out the rotor position (the observer). The simplest model of a winding one cycle ahead: the next cycle's current = the current now × (1 − Rs · Ts / Ls) + (the voltage − the rotor's back-EMF) × Ts / Ls. The observer compares the predicted current with the measured one, and from the difference estimates the back-EMF and, from that, the rotor position. The first factor is exactly the coefficient we used above to estimate the time constant.
  • Start-up. The rotor is first aligned with a set current, then accelerated with the same current without the position estimate, and once the back-EMF is large enough for a reliable estimate, control passes to the observer. For our pump the original firmware does this: ≈ 0.42 A for 0.3 s to align, then ≈ 1 s of acceleration to ≈ 1000 rpm (a fifth of the top speed), and only then the observer.
  • The speed controller is the least demanding: it is tuned while running, starting with soft gains and increasing them until the speed holds steady.

A program that measures Rs, Ls and Ke by itself is described in the appendix at the end of this part.

The next stages

  1. Field-oriented control, as in the original firmware. Port the current measurement tied to the PWM pulse, the "align → accelerate on current → observer" start-up, and the check that the rotor has not fallen behind the field. The firmware will then see the real speed, not just the set one.
  2. Protection through VCC. Toggle PB6 from the program, as the original firmware does, remove the pulses on a fault, and check the response on pin 47 before a start (see above).
  3. A run with water. On mains, heater disconnected: check the version 24 speeds, the display without the mess on the screen, and the version 25 heater rules.
  4. The 80 mA threshold. Refine it by measuring with water and without. The original firmware also has a separate "no water" threshold stored in the EEPROM; in our copy it corresponds to about 43 mA. That is an estimate, and we have yet to check it.
  5. Checking the temperature in water, once the sensors are in the water heater itself.

Appendix: ST Motor Profiler

For a motor with no "original" data, for example one salvaged from scrap metal or another appliance, the quickest route to field-oriented control is ST Motor Profiler from the microcontroller maker, STMicroelectronics. You connect the motor to an ST board, and the program spins it and measures the winding resistance and inductance (Rs, Ls), the back-EMF constant (Ke), rotor inertia and friction. The result is saved as a profile and imported into ST's library configuration tool (MC Workbench), which generates a firmware project ready to build. Our pump did not need the program: the numbers are already in the original firmware.

  • What you enter by hand — the number of pole pairs, the maximum speed, the maximum current, the bus voltage, the rotor type (surface or buried magnets); newer versions can detect the pole pairs themselves
  • Which boards it works with — only ST boards from its own list: a NUCLEO-F303RE or NUCLEO-G431RB control board together with a power board — the low-voltage X-NUCLEO-IHM07M1 or X-NUCLEO-IHM16M1, or the STEVAL-IPM05F, STEVAL-IPM10B, STEVAL-IPM15B for mains-voltage motors; or the ready-made B-G431B-ESC1 board
  • Whether our board will do — no: it is a dishwasher board, not an ST one. To use the program, the motor has to be connected to one of the supported boards for the measurements
  • What to do without a supported board — measure by hand (see above); ST itself suggests measuring Rs and Ls with an LCR meter between two phases at 100 Hz and taking half of the reading

⚠ ST's mains-voltage power boards are not isolated from the mains, and the program talks to the board over the computer's USB. This is the same hazard as with our ST-Link (see "The board ground and mains"): you need a USB isolator and power through an isolation transformer. A 300 V motor on a low-voltage board will most likely let you measure resistance and inductance, but there may not be enough voltage for the back-EMF constant and for spinning it up.

Article changelog

  • 2026-11-18 — the series was restructured from five parts into three; this part used to be part five. Added: what has already been measured about the board ground and the ST-Link supply (in place of empty tables), the commands for reading the log, the history of the runs on mains (versions 20–24: the ramp, a mess on the screen, the main pump's speeds), pin 7 (PC13) under "What we already know"; the motor parameters section was shortened and ST Motor Profiler moved to an appendix; the next stages were updated.
  • 2026-11-18 — heater rules as in the original firmware (water really flowing, −10…95 °C, 15 / 13 °C, 82 / 77 °C instead of our 85 °C limit) and a comparison with it; heater relays: holding at 70% and the switch-on order.
  • 2026-11-18 — section "Motor parameters for field-oriented control": what we found in the original firmware, how to measure the parameters of an unfamiliar motor, how to get the coefficients, the ST Motor Profiler program.
  • 2026-11-16 — section "Power for the power module's gate drivers": the module's VCC is switched on by pulses on pin 92 (PB6) through a diode charge pump, as in the original firmware; a photo with the final measurements (VCC 13.48 V); how to use this chain for protection; a per-second log of pump operation.
  • 2026-11-16 — heater rules from temperature: healthy and agreeing sensors, an 85 °C limit, a set temperature with hysteresis.
  • 2026-11-16 — sections "Current protection and current measurement" (as in the original firmware, 0.41 Ω shunts, a ≈ 2.9 A threshold, 72 MHz) and "Stage 4: the first pump run from the buttons"; rule: the heater only while the pump is running.
  • 2026-11-16 — the first run on mains: power held for ≈ 1 s; the power-hold pin (7, PC13) found by elimination; the second run went fine, results in the table.
  • 2026-11-16 — stage 3 measured: all 12 steps match the expected voltages, no FAULT.
  • 2026-11-15 — sections "A display with buttons" (an OLED on free pins, answering at address 0x3C) and "Stage 3: motor signals off mains" with a photo of where to put the probes.
  • 2026-11-14 — "Where we start": measurements before the first USB connection (no lamp and no USB isolator); stage 1 version 2 with statistics in the mailbox and a log in flash memory; "The first run on mains: the log only".
  • 2026-11-12 — labelled photo of the X20 pads under "Tools".
  • 2026-11-12 — first draft: what we already know, safety on mains (moved from the board map), the tools, stage 1 with the heater relays and raw sensor readings, the next stages.