# [CNC Mill Concept: Control Electronics, Motion & Electrical](https://blog.hirnschall.net/cnc-mill-concept/electronics-motion-and-electrical/)

author: [Sebastian Hirnschall](https://blog.hirnschall.net/about/)

meta description: ECU and distributed sensor PCBs on STM32G4 with CAN-FD, Duet 3 6HC open-loop stepper motion with HTD belts, and a DIN/EN 60204-1 electrical installation.

meta title: CNC Mill Concept — Control Electronics, Motion & Electrical

date published: 25.03.2026 (DD.MM.YYYY format)
date last modified: 19.05.2026 (DD.MM.YYYY format)

---

Introduction
------------

This post is part of the [CNC Mill Concept hub](https://blog.hirnschall.net/cnc-mill-concept/). It covers the control electronics architecture, distributed sensor PCB capabilities, the motion system, and the electrical installation and pneumatics.

Control Electronics and PCB Architecture
----------------------------------------

### Purpose

* Provide a clear separation between:
  + motion control
  + process supervision
  + sensing and data acquisition
  + safety
* Enable extensible, modular sensing and supervision
* Avoid tight coupling between motion execution and adaptive logic

### ECU (Master PCB)

* Acts as real-time supervisory controller
* Responsibilities:
  + sensor fusion
  + machine state estimation
  + process supervision decisions
* Interfaces:
  + CAN-FD:
    - communication with distributed sensor PCBs
  + RS-485:
    - communication with spindle servo drive
  + GPIO:
    - low-latency triggering of Duet macros
  + SPI or UART:
    - communication with Raspberry Pi
* Does not:
  + generate motion trajectories
  + directly drive axes
  + participate in safety chain

### Distributed Sensor PCBs

* Zonal architecture:
  + multiple PCBs placed near sensors
* Connected to ECU via CAN-FD
* Responsibilities:
  + sensor signal acquisition
  + local filtering
  + FFT and envelope extraction
  + threshold detection
* Communication behavior:
  + event-driven data transmission
  + periodic heartbeat messages
* Fault handling:
  + ECU detects missing heartbeats
  + missing data treated as sensor failure
* Debug and validation:
  + raw data access via USB or SPI

### Communication Architecture

* CAN-FD used for:
  + robust, deterministic sensor data exchange
* SPI / UART used for:
  + configuration
  + logging
  + visualization
* GPIO used for:
  + low-latency supervisory actions
  + feed and spindle-related macros

### Raspberry Pi Integration

* Runs Duet services and web interface
* Hosts plugins for:
  + configuration of ECU and sensor PCBs
  + data logging
  + visualization (e.g. Grafana)
* Not used for:
  + real-time control
  + safety-critical functions

Sensor PCB Capabilities
-----------------------

### General Architecture

Two identical distributed sensor PCBs are used.

* Mounted close to structural measurement locations
* Based on an STM32G4 (CAN-FD capable)
* CAN-FD communication to the main ECU
* Optional synchronization line for deterministic simultaneous sampling
* Careful separation of analog and digital domains

All nodes share the same CAN-FD bus. The ECU is located at one physical end of the bus.

### CAN Topology

Fig. 1 shows the CAN-FD bus topology with both sensor nodes and their connected sensors.

![CAN-FD bus topology: ECU at one end, Sensor Node A (left X-beam) and Sensor Node B (right X-beam), with strain gauge, accelerometer, microphone, and temperature sensor connections per node.](https://blog.hirnschall.net/cnc-mill-concept/electronics-motion-and-electrical/resources/img/can-topology-overview.jpg)


Figure 1: CAN-FD bus topology: ECU at one end, Sensor Node A (left X-beam) and Sensor Node B (right X-beam), with strain gauge, accelerometer, microphone, and temperature sensor connections per node.

### Strain Gauge Interface

* Supports multiple full-bridge configurations
* External 24-bit ADC recommended for dynamic strain measurement
* Differential low-noise instrumentation front-end
* Bridge excitation provided by PCB
* Shielded differential wiring to remote DMS

Typical usage:

* 2 × X-beam full bridges

### Accelerometer Interface

* SPI interface for digital 3-axis accelerometers
* Deterministic sampling capability
* Remote mounting via short shielded cable or rigid daughterboard
* Optional synchronization between PCBs

Typical usage:

* 1 × spindle plate accelerometer
* 1 × tower accelerometer

### Microphone Interface (Piezo Surface Microphone)

* High-impedance charge amplifier front-end
* Anti-alias filtering
* Analog input to ADC
* Shielded cable required

Typical usage:

* 1 × spindle housing microphone
* 1 × tower microphone

### Temperature Sensor Interface

* SPI/I²C thermocouple frontend or RTD interface
* Alternatively precision analog temperature input
* Slow sampling rate sufficient

Typical usage:

* 1 × spindle housing temperature
* 1 × tower plate temperature

### Piezo Communication Interface

* SPI or I²C master interface
* Used to communicate with external piezo shunt PCBs
* No high-voltage circuitry on the sensor PCB
* Digital control and monitoring only

Motion System
-------------

### Purpose

* Provide precise, repeatable axis motion
* Keep motion execution simple and robust in the initial build
* Allow future upgrades without redesigning the machine structure

### Current Motion Configuration

* Motion controller:
  + Duet 3 6HC
* Motors:
  + stepper motors on all linear axes
* Motor drive:
  + steppers driven directly by Duet
* Mechanical transmission:
  + HTD belt between motor and leadscrew
* Purpose of belt coupling:
  + mechanical filtering of motor vibration
  + increased effective steps per millimeter
  + flexibility in gear ratio selection
* Leadscrews:
  + directly coupled to axis motion
* Feedback:
  + open-loop stepper operation in current phase

### Design Considerations

* Motion system prioritized for:
  + simplicity
  + predictability
  + compatibility with supervision layer
* Motion execution kept independent from:
  + adaptive supervision logic
  + compliance estimation
* Any feed or spindle adaptation performed via:
  + Duet macros
  + supervisory requests only

### Deferred Motion Upgrades

* Closed-loop servo drives
* Dual-loop control using external feedback
* Glass scale integration
* Custom servo inverter development

### Scope Limitations

* No real-time modification of trajectories by ECU
* No active damping or compensation within motion controller
* Motion system behavior assumed deterministic for supervision purposes

Electrical Installation and Pneumatics
--------------------------------------

### Purpose

* Ensure operator and bystander safety
* Provide deterministic, fail-safe shutdown behavior
* Comply with applicable DIN / EN machine safety principles
* Keep safety independent from software and firmware

### Electrical Installation

* Electrical system designed in accordance with:
  + DIN / EN 60204-1 principles
* Separate grounded electrical cabinet
* Segregation of:
  + mains power
  + motor power
  + control signals
  + sensor signals
* Use of:
  + main contactors
  + appropriate fusing
  + protective earth bonding
* All safety-relevant wiring implemented in hardware

### Emergency Stop (E-Stop)

* Emergency stop system implemented as hardware-only
* Normally-open main contactor
* E-stop directly interrupts:
  + mains power to drives
  + control power where required
* No software involvement in E-stop behavior
* E-stop overrides:
  + Duet
  + ECU
  + Raspberry Pi

### Pneumatics

* Pneumatic system used for:
  + tool clamping
  + auxiliary machine functions
* Depressurization valve:
  + normally open
  + wired directly into shutdown circuit
* Behavior on:
  + E-stop
  + power loss
* Result:
  + automatic venting of pneumatic system
  + loss of pressure as safe state
* Pneumatic control logic not software-dependent for safety

### Fail-Safe Behavior

* Loss of electrical power results in:
  + drives de-energized
  + pneumatic system depressurized
* Safety chain behavior is deterministic and testable
* No single software fault can inhibit safe shutdown

### Scope Limitations

* No software-based safety logic
* No safety functions implemented in Duet, ECU, or Raspberry Pi
* Safety system not affected by firmware updates