embedded system library for e-puck  1.0.1
A redesigned API library for the e-puck robot platform
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Data Structures | Macros | Enumerations | Functions
el_ir_proximity.h File Reference
#include "el_common.h"
#include "el_clock.h"
#include "el_trigger.h"

Go to the source code of this file.

Data Structures

struct  el_ir_proximity_param
 
struct  el_ir_proximity_data
 

Macros

#define EL_IR_PROXIMITY_VALUE_MAX   4095U
 
#define EL_IR_PROXIMITY_SENSOR_ALL   -1
 
#define EL_IR_PROXIMITY_SENSOR_0   0
 
#define EL_IR_PROXIMITY_SENSOR_1   1
 
#define EL_IR_PROXIMITY_SENSOR_2   2
 
#define EL_IR_PROXIMITY_SENSOR_3   3
 
#define EL_IR_PROXIMITY_SENSOR_4   4
 
#define EL_IR_PROXIMITY_SENSOR_5   5
 
#define EL_IR_PROXIMITY_SENSOR_6   6
 
#define EL_IR_PROXIMITY_SENSOR_7   7
 

Enumerations

enum  el_ir_proximity_mode { EL_IR_PROXIMITY_PASSIVE = 0, EL_IR_PROXIMITY_PULSE = 1, EL_IR_PROXIMITY_EMIT = 2, EL_IR_PROXIMITY_COMMUNICATION = 3 }
 
enum  el_ir_proximity_output { EL_IR_AMBIENT, EL_IR_REFLECTION, EL_IR_DATA, EL_IR_ALL_3V }
 

Functions

void el_enable_ir_proximity (void)
 enable the proximity sensors module
 
void el_disable_ir_proximity (void)
 disable the proximity sensors module
 
el_ir_proximity_paramel_ir_proximity_options ()
 get the pointer to a static instance of el_ir_proximity_param More...
 
void el_ir_proximity_options_apply ()
 apply the settings stored in el_ir_proximity_options directly More...
 
void el_ir_proximity_options_reset ()
 reset the settings stored in el_ir_proximity_options to default More...
 
void el_config_ir_proximity (const el_ir_proximity_param *p)
 apply the settings in the given structure More...
 
int el_ir_proximity_get (el_index i, el_ir_proximity_output u, el_int16 *out)
 get output value(s) from a accelerometer More...
 
el_uint32 el_ir_proximity_get_counter ()
 get total number of samples obtained since initialization More...
 

Detailed Description

Author
Jianing Chen

Enumeration Type Documentation

This enum is used in el_ir_proximity_param to specify the working mode of the IR proximity sensors.

Explanation for each of the working mode can be found in the introduction section of Infrared Proximity Sensors.

Enumerator
EL_IR_PROXIMITY_PASSIVE 

use the Passive Mode

EL_IR_PROXIMITY_PULSE 

use the Pulse Mode (default mode)

EL_IR_PROXIMITY_EMIT 

use the Emit Mode

EL_IR_PROXIMITY_COMMUNICATION 

use the Communication Mode (not implemented yet)

This enum is used in el_ir_proximity_get to select the output type to get.

Explanation for each of output group can be found in the introduction section of Infrared Proximity Sensors.

Enumerator
EL_IR_AMBIENT 

get the ambient output

EL_IR_REFLECTION 

get the reflection output

EL_IR_DATA 

get the data encoded (not implemented yet)

EL_IR_ALL_3V 

get all of the three outputs

Function Documentation

el_ir_proximity_param* el_ir_proximity_options ( )

get the pointer to a static instance of el_ir_proximity_param

Returns
the pointer
void el_ir_proximity_options_apply ( )

apply the settings stored in el_ir_proximity_options directly

This function is equivalent to "el_config_ir_proximity( el_ir_proximity_options() )".

void el_ir_proximity_options_reset ( )

reset the settings stored in el_ir_proximity_options to default

This function can be used in combination with el_ir_proximity_options_apply when the default configuration need to be used.

void el_config_ir_proximity ( const el_ir_proximity_param p)

apply the settings in the given structure

Parameters
ppointer to the data structure

The default setting of the ir proximity sensors can be represented by following code:

1 el_ir_proximity_options()->WorkingMode = EL_IR_PROXIMITY_PULSE;
2 el_ir_proximity_options()->EnvironmentalAmbient = 0;
3 el_ir_proximity_options()->SubtractEA = false;
4 el_config_ir_proximity( el_ir_proximity_options() );
int el_ir_proximity_get ( el_index  i,
el_ir_proximity_output  u,
el_int16 *  out 
)

get output value(s) from a accelerometer

Parameters
iindex of the sensor
uoutput type (see el_ir_proximity_output)
outpointer to a variable or an array of variables to store the output value(s).
Returns
number of values stored into *out.

See Component Index for the index of each of the proximity sensors.

The dimension the data pointed by "out" depends on the number of output values. For example, when one type of output of all eight proximity sensors need to be stored, "out" needs to point to an array of eight el_int16.

1 el_int16 ir_reflection[8];
2 ...
3 el_ir_proximity_get( EL_IR_PROXIMITY_SENSOR_ALL, EL_IR_REFLECTION, ir_reflection );
4 ...

When all types of outputs of all eight proximity sensors need to be stored, An array of el_ir_proximity_data should be used because the output values will be interlaced. For example:

1 el_ir_proximity_data prox[8];
2 ...
3 el_ir_proximity_get( EL_IR_PROXIMITY_SENSOR_ALL, EL_IR_ALL_3V, (el_int16*)prox );
4 ...

At present, the refreshing rate of the proximity sensors are 30 Hz, regardless of the working mode. Thus, a trigger with the event EL_EVENT_IR_PROXIMITY_UPDATE will be triggered 30 times per second.

el_uint32 el_ir_proximity_get_counter ( )

get total number of samples obtained since initialization

Returns
number of samples

When enabled, sampling frequency of the ir proximity sensors are 30Hz.