
A configurable discrete 8-bit PID controller. A host MCU (for example the
RP2040 on the demo board) writes a setpoint SP and a measurement FB (both 0–255).
The chip computes the control action U (0–255) and puts it as a number on
uo_out, where it stays until the next sample.
e[n] = SP - FB (or FB - SP when REV = 1) 9-bit signed
I[n] = clamp(I[n-1] + Ki*e[n], 0, 255) conditional integration (anti-windup)
U[n] = clamp(round(Kp*e[n] + I[n] + Kd*(e[n]-e[n-1])), 0, 255)
ui_in carries a byte. uio[1] (AD) selects an address cycle (1) or a data cycle (0),
and a rising edge on uio[0] (WR) performs the cycle. Data writes auto-increment
the address. 12-bit registers are written low byte first, then the high byte
(bits [3:0]); the register changes only when the high byte arrives. WR must be
high for at least 4 clocks and low for at least 4 clocks, and D/AD must be
stable while WR is high.
| Addr | Register | Reset | Notes |
|---|---|---|---|
| 0x0 | CTRL | 0x02 | [0] EN, [1] AW_EN, [2] REV, [4:3] TICK_SRC (00 timer, 01 ext pin, 10 FB write, 11 software only) |
| 0x1 | CMD | – | [0] SW_TICK, [1] CLR (clears the integrator and the previous error) |
| 0x2 | SP | 0 | setpoint 0–255 |
| 0x3 | FB | 0 | feedback 0–255; starts a sample when TICK_SRC = 10 |
| 0x4/0x5 | KP | 0 | UQ4.8 |
| 0x6/0x7 | KI | 0 | UQ4.8 |
| 0x8/0x9 | KD | 0 | UQ4.8 |
| 0xA/0xB | TS | 999 | sample period - 1 (in clocks) |
| Pin | Signal | Meaning |
|---|---|---|
uio[3] |
HOLD | anti-windup skipped the integration in the last sample |
uio[4] |
DRDY | a new U is ready; cleared by the next write or the next sample |
uio[5] |
SAT_HI | U was clipped at 255 |
uio[6] |
SAT_LO | U was clipped at 0 |
uio[7] |
BUSY | computation in progress |
uo_out = 0 and uio[7:3] = 0.uio[4]) goes high and uo_out = 60.uo_out to the actuator (for example through an 8-bit R-2R DAC or as a PWM duty cycle generated by the host).None required. For a real closed loop you need a sensor read by the host MCU
and an actuator driven from the 8-bit uo_out value.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | D0 | U0 | WR (in) |
| 1 | D1 | U1 | AD (in) |
| 2 | D2 | U2 | TICK (in) |
| 3 | D3 | U3 | HOLD (out) |
| 4 | D4 | U4 | DRDY (out) |
| 5 | D5 | U5 | SAT_HI (out) |
| 6 | D6 | U6 | SAT_LO (out) |
| 7 | D7 | U7 | BUSY (out) |