upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the ENC03R Single Axis Analog Gyro. More...
UPM module for the ENC03R single axis analog gyro. This gyroscope measures x-axis angular velocity, that is how fast the sensor is rotating around the x-axis. Calibration of the sensor is necessary for accurate readings.
Public Member Functions | |
ENC03R (int pin, float aref=5.0) | |
~ENC03R () | |
void | calibrate (unsigned int samples) |
void | update () |
float | calibrationValue () |
float | angularVelocity () |
void | setOffset (float offset) |
void | setScale (float scale) |
float | getNormalized () |
Protected Attributes | |
enc03r_context | m_enc03r |
ENC03R | ( | int | pin, |
float | aref = 5.0 |
||
) |
ENC03R sensor constructor
pin | Analog pin to use |
aref | Reference voltage to use; default is 5.0 V |
void calibrate | ( | unsigned int | samples | ) |
Calibrates the sensor by determining an analog reading over many samples with no movement of the sensor. This must be done before attempting to use the sensor.
samples | Number of samples to use for calibration |
void update | ( | void | ) |
Update the internal state with the current reading. This function must be called prior to calling angularVelocity().
dev | Device context |
|
inline |
Returns the currently stored calibration value
float angularVelocity | ( | ) |
Computes angular velocity based on the value and stored calibration reference.
val | Value to use to compute angular velocity |
void setOffset | ( | float | offset | ) |
Set sensor offset. The offset is applied to the return value before scaling. Default is 0.
offset | Offset to apply to value |
void setScale | ( | float | scale | ) |
Set sensor scale. The return value is scaled by this value after the offset is applied. Default is 1.0.
scale | Scale to apply to value |
float getNormalized | ( | ) |
Get a normalized ADC value from the sensor. The return value will be between 0.0 (indicating no voltage) and 1.0 indicating max voltage (aref). update() must be called prior to calling this function.