A Python interface to AutomationShield's Arduino shields
Project description
python-automationshield
python-automationshield
is a Python package that implements a Python interface to Automationshield's devices. Automationshield creates cheap and accessible tools for control engineering education in the form of Arduino shields. Currently, this package has Python implementations for the following shields:
This project was built to allow TU Delft students learning control engineering to use Python in their assignments, since that is what they are thought in the curriculum. This package provides a flexible controller class that lets users conveniently implement a controller and run it on the Arduino hardware.
Installation
python-automationshield
requires Python >= 3.10 and can be installed with the following command:
$ pip install python-automationshield
Usage
Below is a very simple example with the AeroShield to get started. Read more in the documentation.
Use the AeroShield
class to interface directly with the Arduino.
from automationshield import AeroShield
with AeroShield() as aero_shield:
for _ in range(100):
aero_shield.write(flag=aero_shield.RUN, motor=50)
out = aero_shield.read()
print(f"Potentiomneter [%]: {out[0]}, Angle [°]: {out[1]}")
Use the ShieldController
class to conveniently implement a controller.
from automationshield import AeroShield, ShieldController
class MyController(ShieldController):
def controller(self, t: float, dt: float, ref: float, pot: float, angle: float) -> float:
"""Set the motor value to the provided reference."""
return ref
# create controller instance
my_controller = MyController(AeroShield())
# run the controller on the Arduino.
hist = my_controller.run(freq=200, cycles=1000, ref=45)
Plot the experiment data using the plotting.Plotter
class
from automationshield.plotting import Plotter
fig, ax = Plotter.plot(hist)
fig.show()
Below is an example of a figure plotting the result of a PID controller with a constant reference at 45°.
Contributing
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
python-automationshield
was created by Bert Van den Abbeele. It is licensed under the terms of the MIT license.
Credits
python-automationshield
was created with cookiecutter
and the py-pkgs-cookiecutter
template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_automationshield-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962bb4cdd8bd8fb0488aabb5925f662b3d5a99f003e8e1423fb09759f3b29574 |
|
MD5 | 598999333ab4d6157a45b6b41635694a |
|
BLAKE2b-256 | c9aae2cb204bf22c38c4fe724bf783b05e0b3bc7e8a6b248997bd71e800bc5db |
Hashes for python_automationshield-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e32039444e75c641da009f37b5f81bdc20a30cb1f9300566f4434bd5534fd10 |
|
MD5 | afdca86283ea80f2b397ab66f9135014 |
|
BLAKE2b-256 | 486519011468eae7e1b0a510252a44ec5c6fabbf1046713021c5548e250ce646 |