ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
Loading...
Searching...
No Matches
Potentiometer Class Reference

Class for a generic potentiometer which is used to determine its position. More...

#include <potentiometer.h>

Public Member Functions

 Potentiometer (uint8_t pin, float offset)
 Constructor for the potentiometer class. More...
 
float get_voltage (void)
 The method to retrieve the voltage at the input pin. More...
 
float get_angle (void)
 The method to return the position of the potentiometer. More...
 
void zero (void)
 The method to zero the potentiometer to its current position. More...
 

Public Attributes

uint16_t adc_value
 ADC value from the GPIO input pin.
 
float voltage
 Input voltage from ADC reading.
 

Protected Attributes

uint8_t ADC_PIN
 Pin to read voltage from (0 - 3.3V)
 
const uint16_t ADC_RANGE = 4096
 ADC range determined by a default 12 bit resolution.
 
const float VOLTAGE_SOURCE = 3.3
 Voltage source reference to scale ADC reading.
 
float voltage_offset
 The offset used to zero the potentiometer.
 
float VOLTAGE_TO_DEGREES = 60
 Conversion from voltage to degrees determined experimentally.
 

Detailed Description

Class for a generic potentiometer which is used to determine its position.

Constructor & Destructor Documentation

◆ Potentiometer()

Potentiometer::Potentiometer ( uint8_t  pin,
float  offset 
)

Constructor for the potentiometer class.

Constructor which creates a potentiometer object.

Parameters
pinThe GPIO input pin to read voltages from
offsetThe offset values used to zero the potentiometer

Member Function Documentation

◆ get_angle()

float Potentiometer::get_angle ( void  )

The method to return the position of the potentiometer.

Measures position of the potentiometer.

Returns
The position of the potentiometer in units of degrees

◆ get_voltage()

float Potentiometer::get_voltage ( void  )

The method to retrieve the voltage at the input pin.

Measures the voltage at the input pin.

Returns
The voltage measured at the input pin

◆ zero()

void Potentiometer::zero ( void  )

The method to zero the potentiometer to its current position.

Zeros the position of the potentiometer by setting the offset voltage to the voltage measured at its current position.


The documentation for this class was generated from the following files: