dPID: The dPID class¶
This article shows the
dpid.PID documentation, as specified in the python file.
It specifies the interface to a discrete-PID-controller. Study it to understand how the class should be used. Then start writing python code to test it.
Its’ a python-coding exercise
When part of this controller is 100% clear, just assume it is working correctly. And fill in the details as needed. Use that as base for your test-code.
At least, eventually, the class and the code are consistent. So, future changes will not invalidate current (assumed) behaviour; without notice.
During normal development, such details should be incorporated into the doc-string; possible after discussion and/or approval
For the ‘homework-goal’ the exact working isn’t that relevant. Fill in details as needed; focus on writing python-code!
- class dpid.dPID(P, I, D, min_result=None, max_result=None)¶
A simple discrete-PID controller, as an exercise.
This PID-controller can be initialised with constantes for
D; which can’t be changed afterwards. Optional, a minimum and maximum output value can be given; both during initialisation, and later.
The controller has two inputs:
measured(), and one output:
result(). Those inputs can be set/updated independently. Similarly, the
result()can be read at any-moment. As the controller will remember the timestamp a values changes (and knows when the result is read), it will always give the correct output. Thus, that output value does depend on the timestamp it is requested!
setpoint()is considered as a step-function: between two changes, it will remain the last value. The
measured()value however should be considered as a continuously linear-changing value. So, between two updates of this value, the dPID-controller will interpolate linearly.
result()is read during such a period; the PID-controller can’t predict the next-measured-value, however. Therefor, it will (for that single read) assume the measured-value is the same as last-time.
As this class is part of an exercise; no implementation is given.
During the training one should update this file to implement the class without changing the interface.
All (numeric) input & output values are either integers or floats.
Set the setpoint: a numeric value.
Give the controller an update on the actual measured (or simulated) process-value.
The controller will assume a linear progression between the last update and the current one
Return the actual result value