MCUcraft · Example project, made with MCUcraft

Compressor monitor

The idea

Compressor monitor on an STM32 for an industrial site. It measures the motor current with a split-core current transformer and the oil temperature with a PT100. It counts the running hours, keeps them through power loss, and closes an alarm relay if the temperature goes above 90 °C or the current stays above the set limit for 5 seconds. Values are readable over Modbus RTU on RS-485. Powered from 24 V DC. I want a custom PCB.

Firmware

Firmware builds, not tested yet

it compiles, and what the device does for R-6261, R-470a, R-20c7, R-f92c and 1 more rule(s) was not verified

Bill of materials (57 lines)

PartManufacturer part numberManufacturerQtyFunction
STM32F103C8T6STM32F103C8T6STMicroelectronics1Main controller: ADC for PT100 and CT channels, USART for Modbus RTU, GPIO for relay driver, I2C for FRAM, firmware for alarm and running-hours logic.
MAX31865 RTD-to-digital converterMAX31865AAP+Analog Devices1PT100 front-end: excitation, 3-wire lead compensation and 15-bit digital conversion over SPI, replacing a discrete analog bridge.
Trasduttore di corrente a nucleo spaccato 100 A / 50 mA (Olimex SNS-CURRENT-CT013-100A)SNS-CURRENT-CT013-100AOlimex1Measures the motor current as a secondary current through the split-core clamp around a motor lead.
Relè 24 V DC PRY3-24V-360-1C-EPRY3-24V-360-1C-ESame Sky1Alarm relay: closes on oil over-temperature, motor over-current, or sensor fault.
RS-485 transceiver SP3485EN (3.3 V)SP3485EN-L/TRMaxLinear1Physical layer for Modbus RTU on RS-485, with direction enable driven by the MCU.
Relay driver transistor BC817 with base resistorBC817-25Diotec Semiconductor1Low-side transistor stage that switches the alarm relay coil from a GPIO.
Digital isolator 3-channel for the RS-485 UART TXD, RXD and DE lines (logic side 3.3 V, field side 3.3 V)ISO6431DBQRQ1Texas Instruments1Digital isolator carrying UART TXD, RXD and the RS-485 direction enable across the isolation barrier between the MCU logic domain and the RS-485 transceiver side.
Regolatore LDO lineare 3,3 V 1 A dal rail 5 V alla logica (SPX3940AT-L-3-3/TR, MaxLinear)SPX3940AT-L-3-3/TRMaxLinear1Linear 3.3 V regulator from the 5 V intermediate rail to the logic domain.
Convertitore DC/DC isolato 24 V - 5 V, 1 W (alimentazione dominio logico attraverso la barriera di isolamento)DDP1-24-S5-DCUI Inc.1Isolated 24 V DC to 5 V converter, about 1 W, supplying the logic domain across the isolation barrier from the field supply.
Regolatore LDO lineare 3,3 V 100 mA dal rail 5 V isolato al lato campo RS-485 (transceiver e VCC2 dell'isolatore)MCP1700T-3302E/TTMicrochip Technology1Field-side linear 3.3 V regulator fed from the isolated 5 V rail, supplying the RS-485 transceiver and the VCC2 side of the isolator (3.135-3.465 V).
Convertitore DC/DC isolato 24 V - 5 V, 1 W, lato campo RS-485 (secondo isolamento, separato dal dominio logico)DDP1-24-S5-DCUI Inc.1Second isolated 24 V DC to 5 V converter, about 1 W, supplying only the RS-485 field side (row10 field LDO and the VCC2 side of row7) so the field domain has its own isolated source, separate from the logic domain fed by row9.
SMBJ33A TVS diodeSMBJ33ALittelfuse1Transient suppression on the 24 V input.
SS14 Schottky diode 1A 40V (reverse polarity)SS14ON Semiconductor1Reverse-polarity protection in series with the 24 V input.
Array TVS bidirezionale 2 linee RS-485, standoff 12 V (USB50812C)USB50812C/TR7Microchip Technology1ESD and surge clamp on the RS-485 A and B lines, standoff above the -7 V to +12 V bus range.
1N4148 flyback diode (relay coil)1N4148ON Semiconductor1Flyback diode across the relay coil to clamp inductive kick when the transistor turns off.
Clamp diode pair BAT54S, ADC input to 3.3 V and GNDBAT54SSMC Diode Solutions1Clamp pair on the CT ADC input: one diode to 3.3 V and one to GND, clamps overvoltage at the ADC pin.
Connettore a vite Phoenix Contact 3 poli passo 5,08 mm (plug RS-485 A, B, GND)1757022Phoenix Contact1Field connection for the Modbus RS-485 bus: A, B and shield/ground.
Phoenix Contact 2-pin terminal block 5.08 mm (24 V DC input)1705469Phoenix Contact1Field connection for the 24 V DC supply input.
Morsettiera a vite 3 poli passo 5,08 mm (uscita relè allarme) Phoenix Contact MSTB 2,5/3-ST-5,08 (1715063)1715063Phoenix Contact1Field connection for the alarm relay contact (COM, NO, NC).
Morsettiera a vite 3 poli passo 5,08 mm Phoenix Contact (PT100 e secondario TA)1712193Phoenix Contact2Field connection for the PT100 three-wire leads (J5, 3-pole) and the 2-wire CT secondary (J6, two of its three poles).
Connettore SWD 2x5 1.27 mm (Samtec FTSH-105-01-L-DV-K)FTSH-105-01-L-DV-KSamtec1SWD debug and programming connector for ST-LINK, with SWDIO, SWCLK, NRST, GND and 3.3 V.
FRAM FM24CL64B-G (I2C, 64 Kbit)FM24CL64B-GInfineon Technologies1Non-volatile storage for the running-hours total, written at a controlled rate and reloaded at boot.
Condensatore 100 nF disaccoppiamento VCC1 (3.3 V) dell'isolatore digitale ISO6431 (lato logica)1parte di «Digital isolator 3-channel for the RS-485 UART TXD, RXD and DE lines (logic side 3.3 V, field side 5 V)»
Condensatore 100 nF disaccoppiamento VCC2 (3.3 V) dell'isolatore digitale ISO6431 (lato campo RS-485)1parte di «Digital isolator 3-channel for the RS-485 UART TXD, RXD and DE lines (logic side 3.3 V, field side 3.3 V)»
Resistore 100 kΩ 1% 0603 partitore alto bias CT (3.3 V a nodo CT)1Upper resistor of the CT bias divider: from 3.3 V to the CT node, so an open CT wire reads a known level.
Resistore 100 kΩ 1% 0603 partitore basso bias CT (a GND)1Lower resistor of the CT bias divider: from the CT node to GND.
Condensatore 100 nF filtro nodo bias CT (nodo CT verso GND)1Filter capacitor on the CT bias node, from the CT node to GND.
Condensatore 100 nF di disaccoppiamento VCC del transceiver RS-485 SP3485EN-L (3.3 V)1parte di «RS-485 transceiver SP3485EN (3.3 V)»
Crystal 8 MHz 16 pF SMD 3.2x2.5 mm1External HSE clock for the STM32, SMD 8 MHz crystal with 16 pF load.
Capacitor 22 pF, 06032Load capacitors for the 8 MHz crystal in row29 (two units), 22 pF each: CL = C/2 + stray (about 5 pF) gives 16 pF for the crystal in row29.
PT100 RTD probe 3-wire, 4 mm sheath, 06031Oil temperature sensing element immersed in the compressor oil.
Precision resistor 400R 0.1% (MAX31865 RREF), 06031RREF reference resistor of the MAX31865 PT100 front-end, sets the excitation current.
Burden resistor 22R 0.1% 0.25W (CT), 06031Burden resistor converting the CT secondary current into a voltage for the ADC.
Resistor 10k (relay driver base pull-down), 06031Base-emitter pull-down keeps the relay off during boot, before the firmware drives the GPIO.
Resistor 1k (relay driver base series), 06031Base current limiting resistor between the GPIO and the transistor base.
Resistor 4.7k (I2C pull-up, 2 units), 06032Pull-up resistors for the I2C bus to the FRAM.
Capacitor 10 uF 16 V ceramic, LDO input (INPUT to GND), 06031Input capacitor of the AZ1117CH-3.3 LDO, from INPUT to GND, next to the regulator.
Capacitor 10 uF 16 V tantalum, LDO output (OUTPUT to GND)1Output capacitor of the SPX3940 LDO, from VOUT to GND. A tantalum type gives the output ESR the regulator needs for stability.
Capacitor 100 nF 16 V ceramic, MAX31865 VDD decoupling, 06031Decoupling capacitor of the MAX31865 VDD pin, next to the converter.
Capacitor 100 nF 16 V ceramic, MAX31865 REFIN filter, 06031REFIN filter capacitor of the MAX31865, from REFIN+ to GND, on the node the converter reads.
Capacitor 100 nF 16 V ceramic, MCU VDD decoupling, 06033Decoupling capacitors, one per VDD pin of the STM32F103C8T6, next to each pin.
Capacitor 4.7 uF 10 V ceramic, MCU VDD bulk (VDD to VSS), 06031Bulk decoupling on the STM32 VDD rail, next to the MCU.
Capacitor 10 nF 16 V ceramic, MCU VDDA decoupling, 06031High-frequency decoupling of the STM32 VDDA analog supply, next to the pin.
Capacitor 1 uF 16 V ceramic, MCU VDDA decoupling, 06031Bulk decoupling of the STM32 VDDA analog supply, next to the pin.
Capacitor 100 nF 16 V ceramic, MCU NRST filter, 06031NRST capacitor from the reset pin to GND, filtering the reset line.
Resistor 10k (BOOT0 pull-down), 06031Pull-down on the BOOT0 pin, holds the STM32 boot from main flash.
RS-485 bus termination resistor 120 ohm (A to B)1Bus termination: 120 ohm across the RS-485 A and B lines at the bus end.
RS-485 A line bias resistor 680 ohm to 3.3 V1Fail-safe bias: pulls the RS-485 A line up to 3.3 V when the bus is idle.
RS-485 B line bias resistor 680 ohm to GND1Fail-safe bias: pulls the RS-485 B line down to GND when the bus is idle.
Series resistor 1k 0603, CT input to ADC (protection)1Series resistor between the CT output and the ADC input, limits the current into the ADC pin when the CT line is out of range.
Capacitor 1 uF 50 V ceramic, input filter of the isolated DC/DC (+VIN to -VIN), 06031Input filter capacitor of the isolated 24 V-5 V DC/DC, from +VIN to -VIN, for input ripple reduction (1 uF / 50 V per the datasheet input capacitor table).
Capacitor 10 uF 16 V ceramic, output filter of the isolated DC/DC (+VOUT to -VOUT), 06031Output filter capacitor of the isolated 24 V-5 V DC/DC, from +VOUT to -VOUT (10 uF / 16 V per the datasheet output table). Well below the 220 uF maximum capacitive load of the DC/DC.
Capacitor 10 uF 16 V ceramic, field-side LDO input (5 V to GND), 06031Input capacitor of the field-side 3.3 V LDO, from its VIN to GND, next to the regulator.
Capacitor 10 uF 16 V tantalum, field-side LDO output (OUTPUT to GND), 06031Output capacitor of the field-side 3.3 V LDO, from VOUT to GND. A tantalum type gives the output ESR the regulator needs for stability.
Resistor 620R minimum load (SPX3940 VOUT to GND), 06031Minimum-load resistor from the SPX3940 3.3 V output to GND, drawing about 5.3 mA so the LDO stays in regulation.
Capacitor 1 uF 50 V ceramic, input filter of the field-side isolated DC/DC (+VIN to -VIN), 06031Input filter capacitor of the second isolated 24 V-5 V DC/DC (field side), from +VIN to -VIN, same datasheet input capacitor as row50.
Capacitor 10 uF 16 V ceramic, output filter of the field-side isolated DC/DC (+VOUT to -VOUT), 06031Output filter capacitor of the second isolated 24 V-5 V DC/DC (field side), from +VOUT to -VOUT, same datasheet output capacitor as row51.

The schematic, the PCB, the firmware and the chat that produced them open in the MCUcraft workspace, read-only and without an account: Compressor monitor.