upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

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
System.out.println("Please place the sensor in a stable location, and do not");
System.out.println("move it while calibration takes place");
System.out.println("This may take a couple of minutes.");
gyro.calibrate(CALIBRATION_SAMPLES);
System.out.println("Calibration complete. Reference value: " + gyro.calibrationValue());
// Read the input and print both the raw value and the angular velocity,
// waiting 1 second between readings
while (true) {
long val = gyro.value();
double av = gyro.angularVelocity(val);
System.out.println("Raw value: " + val + ", angular velocity: " + av + " deg/s");
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 ENC03R (int pin, float vref)
 
 ENC03R (int pin)
 
void calibrate (long samples)
 
long value ()
 
float calibrationValue ()
 
double angularVelocity (long val)
 

Constructor & Destructor Documentation

ENC03R ( int  pin,
float  vref 
)

ENC03R sensor constructor

Parameters
pinAnalog pin to use
vrefReference voltage to use; default is 5.0 V

Member Function Documentation

double angularVelocity ( long  val)

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

Parameters
valValue to use to compute angular velocity
Returns
Computed angular velocity
void calibrate ( long  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
float calibrationValue ( )

Returns the currently stored calibration value

Returns
Current calibration value
long value ( )

Returns the raw value of the sensor

Returns
Raw value of the sensor

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