AeroShield Class

class automationshield.AeroShield(port: str | None = None)[source]

Bases: BaseShield

Class for Aeroshield device. Inherits from BaseShield.

The Aeroshield is a pendulum control experiment. The actuator is a propeller at the end of the pendulum. The position of the pendulum is measured by an angle sensor.

Interface:
  • Actuator input should be provided in percent by default.

  • Potentiometer is provided in percent by default.

  • Sensor values are converted to degrees by default.

Parameters:

port (str | None) – Port on which the Arduino is connected, defaults to None.

script: str = 'aeroshield'

Name of the script directory in which the .ino file for the specific shield is located.

shield_id: str = 'AE'

ID assigned to shield. This is used to check whether the correct firmware is installed on the Arduino.

actuator_bits: int = 8

Number of bits used for actuator.

potentiometer_bits: int = 10

Number of bits used for potentiometer.

sensor_bits: int = 12

Number of bits used for sensor.

class PlotInfo[source]

Bases: PlotInfo

sensor_unit: str = '$\\degree$'

Sets the unit on the axis label of the output plot.

sensor_type: str = 'Angle'

Sets the name of the axis of the output plot.

sensor_min: float = 0

Sets to lower bound of the sensor value. This is used to set up the LivePlotter.

sensor_max: float = 180

Sets the upper bound of the sensor value. This is used to set up the LivePlotter.

convert_sensor_reading(raw: int) float[source]

Convert raw angle to degrees.

\[\alpha_{deg} = \alpha_{raw} \cdot \frac{360}{2^{n}}\]

where \(n\) equals AeroShield.sensor_bits.

Parameters:

raw (int) – 12-bit value of angle sensor.

Returns:

Angle value scaled to degrees.

Return type:

float

calibrate_sensor_reading(raw_angle: int) int[source]

Calibrate the sensor reading with the zero reference. Subtract zero reference from the measurement and ensure result is between \(-90 \degree\) and \(270 \degree\) and not off by a multiple of \(360 \degree\).

Parameters:

raw_angle (int) – Raw 12-bit angle value.

Returns:

Calibrated angle.

Return type:

int