code wiki / _hdl_build / _pe_heat.nx
_pe_heat.nx source
↩ module page · 8 lines · 355 B
1// AUTHORED BY THE NISHI BUILDER (pattern: PID_LOOP) -- integer PI, gains pre-flighted vs the plant sim
2import "nx_syscalls.nx"
3func _pe_heat_pid(err: i64, integ: *i64) -> i64 {
4 integ[0] = integ[0] + err
5 if integ[0] > 10000 { integ[0] = 10000 }
6 if integ[0] < 0 - 10000 { integ[0] = 0 - 10000 }
7 return (2000 * err + 20 * integ[0]) / 1000
8}