Andrea Corrado / MaxbotixDriver

Dependents:  

Fork of MaxbotixDriver by Daniel Casner

Committer:
andcor02
Date:
Fri Dec 05 16:45:13 2014 +0000
Revision:
2:455334cc71d5
Parent:
1:964f4d42a3d6
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andcor02 1:964f4d42a3d6 1 /*
andcor02 1:964f4d42a3d6 2 Height_Sensor.cpp - MB1033 HRLV-MaxSonar®-EZ3 sensor library
andcor02 1:964f4d42a3d6 3 Developed by Andrea Corrado
andcor02 1:964f4d42a3d6 4 */
andcor02 1:964f4d42a3d6 5
andcor02 1:964f4d42a3d6 6 /*
andcor02 1:964f4d42a3d6 7 Example 'main.cpp'
andcor02 1:964f4d42a3d6 8
andcor02 1:964f4d42a3d6 9 DigitalOut myled(LED1);
andcor02 1:964f4d42a3d6 10 Serial pc (USBTX, USBRX);
andcor02 1:964f4d42a3d6 11
andcor02 1:964f4d42a3d6 12 MAXBOTIX ez2(PTB3, SW2);
andcor02 1:964f4d42a3d6 13
andcor02 1:964f4d42a3d6 14 float var=0;
andcor02 1:964f4d42a3d6 15
andcor02 1:964f4d42a3d6 16 int main()
andcor02 1:964f4d42a3d6 17 {
andcor02 1:964f4d42a3d6 18 while(1) {
andcor02 1:964f4d42a3d6 19
andcor02 1:964f4d42a3d6 20 var=ez2.height_detect();
andcor02 1:964f4d42a3d6 21 if (var!=0)
andcor02 1:964f4d42a3d6 22 pc.printf("\n\r Result %f ", var);
andcor02 1:964f4d42a3d6 23 }
andcor02 1:964f4d42a3d6 24 }
andcor02 1:964f4d42a3d6 25
andcor02 1:964f4d42a3d6 26 */
andcor02 1:964f4d42a3d6 27
andcor02 1:964f4d42a3d6 28 #ifndef MBED_HEIGHT_H
andcor02 1:964f4d42a3d6 29 #define MBED_HEIGHT_H
andcor02 1:964f4d42a3d6 30
DanielC 0:7e65f5077f5a 31 #include "mbed.h"
andcor02 1:964f4d42a3d6 32
andcor02 1:964f4d42a3d6 33
andcor02 1:964f4d42a3d6 34
andcor02 1:964f4d42a3d6 35 class MAXBOTIX {
DanielC 0:7e65f5077f5a 36
andcor02 1:964f4d42a3d6 37 public:
andcor02 1:964f4d42a3d6 38
andcor02 1:964f4d42a3d6 39 MAXBOTIX (PinName ain, PinName intr); //(AnalogueIn, SW2), SW2 usable for set/reset zero if needed.
DanielC 0:7e65f5077f5a 40
andcor02 1:964f4d42a3d6 41 float calibration(); //As soon as device turns on, height reading is taken to get zero refrence, make sure nothing obstructs sensor when turn on, 300mm radius, reset to obtain new zero.
andcor02 1:964f4d42a3d6 42
andcor02 1:964f4d42a3d6 43 float data_conversion_inch(); //Convert analogue voltage to Absolute measurement in inches
DanielC 0:7e65f5077f5a 44
andcor02 1:964f4d42a3d6 45 float data_conversion_m(); //Convert analogue voltage to Absolute measurement in meters
andcor02 1:964f4d42a3d6 46
andcor02 1:964f4d42a3d6 47 protected:
andcor02 1:964f4d42a3d6 48 AnalogIn _ain;
andcor02 1:964f4d42a3d6 49 InterruptIn _intr;
andcor02 1:964f4d42a3d6 50 float Raw;
andcor02 1:964f4d42a3d6 51 float Zero;
andcor02 1:964f4d42a3d6 52 float Absolute;
andcor02 1:964f4d42a3d6 53 };
andcor02 1:964f4d42a3d6 54
andcor02 1:964f4d42a3d6 55 #endif