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)
| Part | Manufacturer part number | Manufacturer | Qty | Function |
|---|---|---|---|---|
| STM32F103C8T6 | STM32F103C8T6 | STMicroelectronics | 1 | Main 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 converter | MAX31865AAP+ | Analog Devices | 1 | PT100 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-100A | Olimex | 1 | Measures the motor current as a secondary current through the split-core clamp around a motor lead. |
| Relè 24 V DC PRY3-24V-360-1C-E | PRY3-24V-360-1C-E | Same Sky | 1 | Alarm relay: closes on oil over-temperature, motor over-current, or sensor fault. |
| RS-485 transceiver SP3485EN (3.3 V) | SP3485EN-L/TR | MaxLinear | 1 | Physical layer for Modbus RTU on RS-485, with direction enable driven by the MCU. |
| Relay driver transistor BC817 with base resistor | BC817-25 | Diotec Semiconductor | 1 | Low-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) | ISO6431DBQRQ1 | Texas Instruments | 1 | Digital 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/TR | MaxLinear | 1 | Linear 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-D | CUI Inc. | 1 | Isolated 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/TT | Microchip Technology | 1 | Field-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-D | CUI Inc. | 1 | Second 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 diode | SMBJ33A | Littelfuse | 1 | Transient suppression on the 24 V input. |
| SS14 Schottky diode 1A 40V (reverse polarity) | SS14 | ON Semiconductor | 1 | Reverse-polarity protection in series with the 24 V input. |
| Array TVS bidirezionale 2 linee RS-485, standoff 12 V (USB50812C) | USB50812C/TR7 | Microchip Technology | 1 | ESD 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) | 1N4148 | ON Semiconductor | 1 | Flyback 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 GND | BAT54S | SMC Diode Solutions | 1 | Clamp 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) | 1757022 | Phoenix Contact | 1 | Field 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) | 1705469 | Phoenix Contact | 1 | Field 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) | 1715063 | Phoenix Contact | 1 | Field connection for the alarm relay contact (COM, NO, NC). |
| Morsettiera a vite 3 poli passo 5,08 mm Phoenix Contact (PT100 e secondario TA) | 1712193 | Phoenix Contact | 2 | Field 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-K | Samtec | 1 | SWD debug and programming connector for ST-LINK, with SWDIO, SWCLK, NRST, GND and 3.3 V. |
| FRAM FM24CL64B-G (I2C, 64 Kbit) | FM24CL64B-G | Infineon Technologies | 1 | Non-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) | 1 | parte 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) | 1 | parte 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) | 1 | Upper 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) | 1 | Lower resistor of the CT bias divider: from the CT node to GND. | ||
| Condensatore 100 nF filtro nodo bias CT (nodo CT verso GND) | 1 | Filter 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) | 1 | parte di «RS-485 transceiver SP3485EN (3.3 V)» | ||
| Crystal 8 MHz 16 pF SMD 3.2x2.5 mm | 1 | External HSE clock for the STM32, SMD 8 MHz crystal with 16 pF load. | ||
| Capacitor 22 pF, 0603 | 2 | Load 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, 0603 | 1 | Oil temperature sensing element immersed in the compressor oil. | ||
| Precision resistor 400R 0.1% (MAX31865 RREF), 0603 | 1 | RREF reference resistor of the MAX31865 PT100 front-end, sets the excitation current. | ||
| Burden resistor 22R 0.1% 0.25W (CT), 0603 | 1 | Burden resistor converting the CT secondary current into a voltage for the ADC. | ||
| Resistor 10k (relay driver base pull-down), 0603 | 1 | Base-emitter pull-down keeps the relay off during boot, before the firmware drives the GPIO. | ||
| Resistor 1k (relay driver base series), 0603 | 1 | Base current limiting resistor between the GPIO and the transistor base. | ||
| Resistor 4.7k (I2C pull-up, 2 units), 0603 | 2 | Pull-up resistors for the I2C bus to the FRAM. | ||
| Capacitor 10 uF 16 V ceramic, LDO input (INPUT to GND), 0603 | 1 | Input 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) | 1 | Output 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, 0603 | 1 | Decoupling capacitor of the MAX31865 VDD pin, next to the converter. | ||
| Capacitor 100 nF 16 V ceramic, MAX31865 REFIN filter, 0603 | 1 | REFIN filter capacitor of the MAX31865, from REFIN+ to GND, on the node the converter reads. | ||
| Capacitor 100 nF 16 V ceramic, MCU VDD decoupling, 0603 | 3 | Decoupling 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), 0603 | 1 | Bulk decoupling on the STM32 VDD rail, next to the MCU. | ||
| Capacitor 10 nF 16 V ceramic, MCU VDDA decoupling, 0603 | 1 | High-frequency decoupling of the STM32 VDDA analog supply, next to the pin. | ||
| Capacitor 1 uF 16 V ceramic, MCU VDDA decoupling, 0603 | 1 | Bulk decoupling of the STM32 VDDA analog supply, next to the pin. | ||
| Capacitor 100 nF 16 V ceramic, MCU NRST filter, 0603 | 1 | NRST capacitor from the reset pin to GND, filtering the reset line. | ||
| Resistor 10k (BOOT0 pull-down), 0603 | 1 | Pull-down on the BOOT0 pin, holds the STM32 boot from main flash. | ||
| RS-485 bus termination resistor 120 ohm (A to B) | 1 | Bus 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 V | 1 | Fail-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 GND | 1 | Fail-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) | 1 | Series 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), 0603 | 1 | Input 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), 0603 | 1 | Output 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), 0603 | 1 | Input 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), 0603 | 1 | Output 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), 0603 | 1 | Minimum-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), 0603 | 1 | Input 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), 0603 | 1 | Output 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.