Ejemplo n.º 1
0
		MAKE_SHARP_ENTRY( 50,322,294),
		MAKE_SHARP_ENTRY( 56,288,260),
		MAKE_SHARP_ENTRY( 62,255,233),
		MAKE_SHARP_ENTRY( 69,229,207),
		MAKE_SHARP_ENTRY( 77,204,184),
		MAKE_SHARP_ENTRY( 85,181,165),
		MAKE_SHARP_ENTRY( 94,163,148),
		MAKE_SHARP_ENTRY(104,146,133),
		MAKE_SHARP_ENTRY(115,131,119),
		MAKE_SHARP_ENTRY(127,118,107),
		MAKE_SHARP_ENTRY(135,106,100),
		MAKE_SHARP_ENTRY(255, DISTANCE_MAX, DISTANCE_MAX)
};


// Read all the values and store into the device
static void __GP2Y0A700K0F_read(SENSOR* sensor){
	Sharp_GP2Y0A700K0F* device = (Sharp_GP2Y0A700K0F*)sensor;

//	uint16_t adc = a2dConvert10bit(device->adcPin);
//	device->distance.cm = 94407.0 * pow(adc,-1.0891);

//	uint16_t adc = a2dReadMv(device->adcPin);
//	device->distance.cm = 531492.0 * pow(adc,-1.0891);

	device->distance.cm = _gp2_read(device->adcPin, &myTable[0], _ENTS_);
}

const DISTANCE_CLASS PROGMEM c_Sharp_GP2Y0A700K0F = MAKE_DISTANCE_CLASS(null,&__GP2Y0A700K0F_read,0,0);

Ejemplo n.º 2
0
 *
 *
 */
#include "PingSonar.h"
#include "../../../fraction.h"

// 0.0172212
static const uint16_t PROGMEM ping_frac[]     = {0, 59, 3676, 0};


// Read all the values and store into the device
static void __ping_read(SENSOR* sensor){
	TICK_COUNT duration;

	PingSonar* device = (PingSonar*)sensor;

	// 5 us Trigger Pulse
	pin_pulseOut(device->ioPin,5,TRUE);

	// Measure the inbound pulse
	duration = pin_pulseIn(device->ioPin,TRUE);

	device->distance.cm = fraction32(duration, ping_frac);
//	device->distance.cm = duration;

}

// Requires a 200us (so say 1ms) delay between readings
const DISTANCE_CLASS PROGMEM c_PingSonar = MAKE_DISTANCE_CLASS(null,&__ping_read,0,1);

Ejemplo n.º 3
0
 *
 *
 */
#include "PingSonar.h"
#include "../../../fraction.h"

// 0.0172212
static const uint16_t PROGMEM ping_frac[]     = {0, 59, 3676, 0};


// Read all the values and store into the device
static void __ping_read(SENSOR* sensor){
	TICK_COUNT duration;

	PingSonar* device = (PingSonar*)sensor;

	// 5 us Trigger Pulse
	pin_pulseOut(device->ioPin,5,TRUE);

	// Measure the inbound pulse
	duration = pin_pulseIn(device->ioPin,TRUE);

	device->distance.cm = fraction32(duration, ping_frac);
//	device->distance.cm = duration;

}

// Requires a 200us (so say 1ms) delay between readings
DISTANCE_CLASS const c_PingSonar = MAKE_DISTANCE_CLASS(null,&__ping_read,0,1);

Ejemplo n.º 4
0
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *        File: MB7077.c
 *  Created on: 19 Jun 2010
 *      Author: Clive Webster
 */
#include "MB7077.h"

#include "../../../fraction.h"

// 4.3 as a fraction
static const uint16_t PROGMEM _frac[]     = {4,  4, 20, 0};

// Read all the values and store into the device
static void _read(SENSOR* sensor){
	Maxbotix_MB7077* sonar = (Maxbotix_MB7077*)sensor;
	uint16_t adc = a2dConvert10bit(sonar->adcPin);
	if(sonar->inWater){
		// Multiply by 4.3
		adc = fraction32(adc,_frac);
	}
	sonar->distance.cm = adc;
}

const DISTANCE_CLASS PROGMEM c_Maxbotix_MB7077 = MAKE_DISTANCE_CLASS(null,&_read,0,0);

Ejemplo n.º 5
0
 */
#include "SRF04_Sonar.h"
#include "../../../fraction.h"

// 0.0172212
static const uint16_t PROGMEM srf04_frac[]     = {0, 59, 3676, 0};


// Read all the values and store into the device
static void __srf04_read(SENSOR* sensor){
	TICK_COUNT duration;

	Devantech_SRF04* device = (Devantech_SRF04*)sensor;

	// initialise the pins
	pin_make_output(device->out,FALSE);		// Set low
	pin_make_input(device->in,FALSE);

	// 10us high trigger pulse
	pin_pulseOut(device->out,10,TRUE);

	// Measure the inbound pulse
	duration = pin_pulseIn(device->in,TRUE);

	device->distance.cm = fraction32(duration, srf04_frac);
}

// Requires a 50ms delay between readings
DISTANCE_CLASS const c_Devantech_SRF04 = MAKE_DISTANCE_CLASS(null,&__srf04_read,0,50);

Ejemplo n.º 6
0
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *
 * GP2Y0A710K0F.c
 *
 *  Created on: 29-Jan-2010
 *      Author: Clive Webster
 */

#include "GP2.h"
// Requires the floating point library
#include <math.h>

#include "../../../a2d.h"

// Read all the values and store into the device
static void __GP2Y0A710K0F_read(SENSOR* sensor){
	Sharp_GP2Y0A710K0F* device = (Sharp_GP2Y0A710K0F*)sensor;

//	uint16_t adc = a2dConvert10bit(device->adcPin);
//	device->distance.cm = 500000000.0 * pow(adc,-2.4723);

	uint16_t adc = a2dReadMv(device->adcPin);
	device->distance.cm = 25270743335.99 * pow(adc,-2.4723);
}

DISTANCE_CLASS const c_Sharp_GP2Y0A710K0F = MAKE_DISTANCE_CLASS(null,&__GP2Y0A710K0F_read,0,0);

Ejemplo n.º 7
0
    if(device) {
        uint8_t response[4];
        const I2C_DEVICE* i2c = &(device->i2cInfo);

        // Read registers 0,1,2,3
        while(i2cMasterReadRegisters(i2c, 0, sizeof(response), response)) {
            if(response[0]!=255) {
                // Ranging has finished
                DISTANCE_TYPE val = response[2];	// get high byte
                val = (val << 8) | response[3];		// put in low byte
                device->distance.cm = val;
                device->ldr = response[1];			// Store the light level
                break;
            }
        }
    }
}

// Read all the values and store into the device
static void __srf08_read(SENSOR* sensor) {
    Devantech_SRF08* device = (Devantech_SRF08*)sensor;

    if(startReading(device)) {
        getReading(device);
    }
}

// Requires a 70ms delay between readings
DISTANCE_CLASS c_Devantech_SRF08 = MAKE_DISTANCE_CLASS(null,&__srf08_read,0,70);