Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

DIST-Nx Sensor
[Mindsensors]

Files

file  mindsensors-irdist.h
 

Mindsensors DIST-Nx driver.


Defines

#define MSDIST_I2C_ADDR   0x02
#define MSDIST_CMD   0x41
#define MSDIST_DIST   0x42
#define MSDIST_VOLT   0x44
#define MSDIST_MOD_TYPE   0x50
#define MSDIST_MINDIST   0x52
#define MSDIST_MAXDIST   0x54
#define MSDIST_GP2D12   0x31
#define MSDIST_GP2D120   0x32
#define MSDIST_GP2YA21   0x33
#define MSDIST_GP2YA02   0x34
#define MSDIST_CUSTOM   0x35

Functions

int MSDISTreadDist (tSensors link, ubyte address=MSDIST_I2C_ADDR)
int MSDISTreadVoltage (tSensors link, ubyte address=MSDIST_I2C_ADDR)
int MSDISTreadMinDist (tSensors link, ubyte address=MSDIST_I2C_ADDR)
int MSDISTreadMaxDist (tSensors link, ubyte address=MSDIST_I2C_ADDR)
int MSDISTreadModuleType (tSensors link, ubyte address=MSDIST_I2C_ADDR)
bool MSDISTsendCmd (tSensors link, byte command, ubyte address=MSDIST_I2C_ADDR)

Variables

tByteArray MSDIST_I2CRequest
tByteArray MSDIST_I2CReply
bool MSDISTcalibrated [] = {false, false, false, false}

Detailed Description

DIST-Nx Sensor


Define Documentation

#define MSDIST_CMD   0x41

MSDIST command register

Definition at line 46 of file mindsensors-irdist.h.

#define MSDIST_CUSTOM   0x35

Custom IR module

Examples:
mindsensors-irdist-test1.c.

Definition at line 58 of file mindsensors-irdist.h.

#define MSDIST_DIST   0x42

MSDIST distance data

Definition at line 48 of file mindsensors-irdist.h.

#define MSDIST_GP2D12   0x31

Sharp IR module GP2D12

Examples:
mindsensors-irdist-test1.c.

Definition at line 54 of file mindsensors-irdist.h.

#define MSDIST_GP2D120   0x32

Sharp IR module GP2D120

Examples:
mindsensors-irdist-test1.c.

Definition at line 55 of file mindsensors-irdist.h.

#define MSDIST_GP2YA02   0x34

Sharp IR module GP2YA02

Examples:
mindsensors-irdist-test1.c.

Definition at line 57 of file mindsensors-irdist.h.

#define MSDIST_GP2YA21   0x33

Sharp IR module GP2YA21

Examples:
mindsensors-irdist-test1.c.

Definition at line 56 of file mindsensors-irdist.h.

#define MSDIST_I2C_ADDR   0x02

MSDIST I2C device address

Definition at line 44 of file mindsensors-irdist.h.

#define MSDIST_MAXDIST   0x54

MSDIST maximum distance in mm

Definition at line 52 of file mindsensors-irdist.h.

#define MSDIST_MINDIST   0x52

MSDIST minimum distance in mm

Definition at line 51 of file mindsensors-irdist.h.

#define MSDIST_MOD_TYPE   0x50

MSDIST Sharp module type

Definition at line 50 of file mindsensors-irdist.h.

#define MSDIST_VOLT   0x44

MSDIST voltage data

Definition at line 49 of file mindsensors-irdist.h.


Function Documentation

int MSDISTreadDist ( tSensors  link,
ubyte  address 
)

Read the distance from the sensor

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
distance to object or -1 if an error occurred
Examples:
mindsensors-irdist-test1.c, and mindsensors-motormux-test2.c.

Definition at line 78 of file mindsensors-irdist.h.

int MSDISTreadMaxDist ( tSensors  link,
ubyte  address 
)

Read maximum measuring distance from the sensor

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
maximum measuring distance from the sensor -1 if an error occurred
Examples:
mindsensors-irdist-test1.c, and mindsensors-motormux-test2.c.

Definition at line 150 of file mindsensors-irdist.h.

int MSDISTreadMinDist ( tSensors  link,
ubyte  address 
)

Read minumum measuring distance from the sensor

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
minumum measuring distance from the sensor -1 if an error occurred
Examples:
mindsensors-irdist-test1.c, and mindsensors-motormux-test2.c.

Definition at line 129 of file mindsensors-irdist.h.

int MSDISTreadModuleType ( tSensors  link,
ubyte  address 
)

Read Sharp IR module type from the sensor

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
Sharp IR module type from the sensor -1 if an error occurred
Examples:
mindsensors-irdist-test1.c.

Definition at line 171 of file mindsensors-irdist.h.

int MSDISTreadVoltage ( tSensors  link,
ubyte  address 
)

Read tilt data from the sensor

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
voltage reading from IR Sensor -1 if an error occurred
Examples:
mindsensors-irdist-test1.c.

Definition at line 108 of file mindsensors-irdist.h.

bool MSDISTsendCmd ( tSensors  link,
byte  command,
ubyte  address 
)

Send a command to the sensor

Parameters:
linkthe sensor port number
commandthe command to be sent
addressthe I2C address to use, optional, defaults to 0x02
Returns:
true if no error occured, false if it did

Definition at line 192 of file mindsensors-irdist.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 68 of file mindsensors-irdist.h.

Array to hold I2C command data

Definition at line 67 of file mindsensors-irdist.h.

bool MSDISTcalibrated[] = {false, false, false, false}

Has the sensor been calibrated yet?

Definition at line 70 of file mindsensors-irdist.h.