upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
ENC03R Class Reference

API for the ENC03R Single Axis Analog Gyro. More...

Detailed Description

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.

enc03r.jpg
// Instantiate a ENC03R on analog pin A0
upm::ENC03R *gyro = new upm::ENC03R(0);
// The first thing we need to do is calibrate the sensor.
cout << "Please place the sensor in a stable location, and do not" << endl;
cout << "move it while calibration takes place." << endl;
cout << "This may take a couple of minutes." << endl;
gyro->calibrate(CALIBRATION_SAMPLES);
cout << "Calibration complete. Reference value: "
<< gyro->calibrationValue() << endl;
// Read the input and print both the raw value and the angular velocity,
// waiting 0.1 seconds between readings
while (shouldRun)
{
unsigned int val = gyro->value();
double av = gyro->angularVelocity(val);
cout << "Raw value: " << val << ", "
<< "angular velocity: " << av << " deg/s" << endl;
usleep(100000);
}

Public Member Functions

 ENC03R (int pin, float vref=5.0)
 
 ~ENC03R ()
 
void calibrate (unsigned int samples)
 
unsigned int value ()
 
float calibrationValue ()
 
double angularVelocity (unsigned int val)
 

Constructor & Destructor Documentation

ENC03R ( int  pin,
float  vref = 5.0 
)

ENC03R sensor constructor

Parameters
pinAnalog pin to use
vrefReference voltage to use; default is 5.0 V
~ENC03R ( )

ENC03R destructor

Member Function Documentation

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.

Parameters
samplesNumber of samples to use for calibration
unsigned int value ( )

Returns the raw value of the sensor

Returns
Raw value of the sensor
float calibrationValue ( )
inline

Returns the currently stored calibration value

Returns
Current calibration value
double angularVelocity ( unsigned int  val)

Computes angular velocity based on the value and stored calibration reference.

Parameters
valValue to use to compute angular velocity
Returns
Computed angular velocity

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