Live data from Hacker News

PID Control Challenges

janismac.github.io

21–30 of 123 posts

Re: PID Control Challenges

#21
post #7
post #5

Possibly useful: A header-only proportional-integral-derivative (PID) controller. https://github.com/RhysU/helm

It's a nice theoretical implementation but few practical examples would be found using floating-point math, running as they are on systems that don't support it.

Cortex-M4s/M7s/ESP32s/Nordics are cheap and ubiquitous. They all have hardware floats. M0s are available fast enough to do soft floats.

Re: PID Control Challenges

#22
post #7

Earlier quoted context omitted.

It's a nice theoretical implementation but few practical examples would be found using floating-point math, running as they are on systems that don't support it.

Maybe that was true up until the 90's, but doing anything but floating point for a PID is just a waste of development time, even on an 8-bit AVR.

Absolutely not! The choice of fixed- vs floating-point for a controller should be based on domain knowledge of the problem, and the right choice may vary depending by operation. For example your PID's integrator needs to accumulate a running sum. Fixed-point addition is well-behaved for addition, with only the need to deal with overflow (which can be dealt with; the integrator likely needs to saturate anyway to respect a physical limit, so you choose a datatype that doesn't overflow before then). Floating point addition has much more nuance; adding a small value to a large one can result in no change at all to the output, causing a controller's small-signal transfer function to change based on the system state. This can lead to all sorts of unexpected bad behaviour, like vibration and limit cycles, which might happen only in edge cases after the controller has been running for some time, and so are very hard to catch in testing.

There are also many cases where floating point is the clear winner, but again, you should think about it and not just choose floating point reflexively because it seems easier. Its convenience makes it very easy to sweep errors under a rug, and they always come back to haunt you later.

Re: PID Control Challenges

#23
post #7
post #5

Possibly useful: A header-only proportional-integral-derivative (PID) controller. https://github.com/RhysU/helm

It's a nice theoretical implementation but few practical examples would be found using floating-point math, running as they are on systems that don't support it.

I've had about as many floating point PID implementations running on the attached core of an embedded ASIC as I have fixed point implementations (running fully within the hardware).

Both are useful.

Re: PID Control Challenges

#24

Earlier quoted context omitted.

Most PID applications are not IoT. Many use a cortex M0 which doesn't have hardware float support, or non Arm, even 8bit. When you are selling millions it pays to use the cheapest part you can get away with.

What do those things go in anymore? Surely there are asic pid controllers that are insanely cheap? Tuning an analog one I can see probably doesn't make sense anymore, but there is something nice about being able to do that with a screwdriver instead of jtag. What do these M0s go into?

I used an 8-bit PIC micro a couple years ago for power applications (think non-IoT lighting). The specific microcontroller we used had nice peripherals for sensing, and controlling diodes, but no FPU. I remember looking into getting something external to handle the PID, but the cost and board layout constraints made it challenging.

Re: PID Control Challenges

#25
post #8
post #7

Earlier quoted context omitted.

It's a nice theoretical implementation but few practical examples would be found using floating-point math, running as they are on systems that don't support it.

Not all PID controllers are destined for embedded. They’re quite useful in gamedev, for example.

If you're willing to expand on this, color me interested.

Re: PID Control Challenges

#26

My control systems prof said every engineer has done an inverted pendulum problem in school and nobody in their career has ever been asked to balance an inverted pendulum. So our final was a thermostat instead.

> nobody in their career has ever been asked to balance an inverted pendulum

Thats what all those self-balancing scooters are.

Re: PID Control Challenges

#27
post #7
post #5

Possibly useful: A header-only proportional-integral-derivative (PID) controller. https://github.com/RhysU/helm

It's a nice theoretical implementation but few practical examples would be found using floating-point math, running as they are on systems that don't support it.

Even where the hardware is available, it can be harder to prove properties about the behavior of the floating point versions. It's no fun when everything turns to NaNs because of surprise cancellation in subtraction.

Re: PID Control Challenges

#28

My control systems prof said every engineer has done an inverted pendulum problem in school and nobody in their career has ever been asked to balance an inverted pendulum. So our final was a thermostat instead.

Some engineers do balance inverted pendulums in their careers! https://space.stackexchange.com/questions/15486/how-does-the...

Re: PID Control Challenges

#29
Related: Sabine Hossenfelder made a video back in December on use of AI/ML in Chaos Control which is pretty interesting. TLDR: scientists have known it’s possible to control or steer chaotic systems since the 1990s at least, but AI/ML have recently given them new tools for doing so. One interesting use case example is using ML to control in real-time the plasma in a tokomak reactor. More:

https://backreaction.blogspot.com/2022/12/how-chaos-control-...

Re: PID Control Challenges

#30
post #26

My control systems prof said every engineer has done an inverted pendulum problem in school and nobody in their career has ever been asked to balance an inverted pendulum. So our final was a thermostat instead.

> nobody in their career has ever been asked to balance an inverted pendulum Thats what all those self-balancing scooters are.

That's how long ago this was
Post reply on HN