Skip to content

Commit

Permalink
Update comments in README-files to also follow PEP-8
Browse files Browse the repository at this point in the history
  • Loading branch information
m-lundberg committed Mar 20, 2021
1 parent 187df07 commit 6fb3955
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Usage is very simple:
from simple_pid import PID
pid = PID(1, 0.1, 0.05, setpoint=1)

# assume we have a system we want to control in controlled_system
# Assume we have a system we want to control in controlled_system
v = controlled_system.update(0)

while True:
# compute new ouput from the PID according to the systems current value
# Compute new output from the PID according to the systems current value
control = pid(v)

# feed the PID output to the system and get its current value
# Feed the PID output to the system and get its current value
v = controlled_system.update(control)
```

Expand All @@ -43,7 +43,7 @@ output = pid(current_value)
### The basics
The PID works best when it is updated at regular intervals. To achieve this, set `sample_time` to the amount of time there should be between each update and then call the PID every time in the program loop. A new output will only be calculated when `sample_time` seconds has passed:
```python
pid.sample_time = 0.01 # update every 0.01 seconds
pid.sample_time = 0.01 # Update every 0.01 seconds

while True:
output = pid(current_value)
Expand All @@ -70,15 +70,15 @@ Note that all the tunings should have the same sign.

In order to get output values in a certain range, and also to avoid [integral windup](https://en.wikipedia.org/wiki/Integral_windup) (since the integral term will never be allowed to grow outside of these limits), the output can be limited to a range:
```python
pid.output_limits = (0, 10) # output value will be between 0 and 10
pid.output_limits = (0, None) # output will always be above 0, but with no upper bound
pid.output_limits = (0, 10) # Output value will be between 0 and 10
pid.output_limits = (0, None) # Output will always be above 0, but with no upper bound
```

### Other features
#### Auto mode
To disable the PID so that no new values are computed, set auto mode to False:
```python
pid.auto_mode = False # no new values will be computed when pid is called
pid.auto_mode = False # No new values will be computed when pid is called
pid.auto_mode = True # pid is enabled again
```
When disabling the PID and controlling a system manually, it might be useful to tell the PID controller where to start from when giving back control to it. This can be done by enabling auto mode like this:
Expand All @@ -90,7 +90,7 @@ This will set the I-term to the value given to `last_output`, meaning that if th
#### Observing separate components
When tuning the PID, it can be useful to see how each of the components contribute to the output. They can be seen like this:
```python
p, i, d = pid.components # the separate terms are now in p, i, d
p, i, d = pid.components # The separate terms are now in p, i, d
```

#### Proportional on measurement
Expand Down
8 changes: 4 additions & 4 deletions examples/water_boiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Simple simulation of a water boiler which can heat up water and where the heat d
Optionally, create a virtual environment for this example and activate it.

```bash
python -m venv water_boiler_venv # assuming Python 3
python -m venv water_boiler_venv # Assuming Python 3
. water_boiler_venv/bin/activate
```

Expand All @@ -20,13 +20,13 @@ pip install -r requirements.txt
## Usage

```bash
# activate the virtual environment if you use one:
# Activate the virtual environment if you use one:
. water_boiler_venv/bin/activate

# run the example:
# Run the example:
python water_boiler.py

# once you're done deactivate the virtual environment if you use one:
# Once you're done deactivate the virtual environment if you use one:
deactivate
```

Expand Down

0 comments on commit 6fb3955

Please sign in to comment.