TLI493D  2.0.1
With this Sensor, you can detect the position of a Joystick etc. without any additional mechanical components. You just have to provide a magnet that is fixed to a movable component.
Tli493d Class Reference

#include <Tli493d.h>

Collaboration diagram for Tli493d:

Public Types

enum  TypeAddress_e { TLI493D_A0 = 0x35, TLI493D_A1 = 0x22, TLI493D_A2 = 0x78, TLI493D_A3 = 0x44 }
 
enum  AccessMode_e { LOWPOWERMODE = 0, MASTERCONTROLLEDMODE = 1, FASTMODE = 3 }
 
enum  Range_e { FULL = 0, SHORT = 1, EXTRASHORT = 3 }
 

Public Member Functions

 Tli493d (AccessMode_e mode=MASTERCONTROLLEDMODE, TypeAddress_e productType=TLI493D_A0, int resetPin=NO_POWER_PIN, bool powerLevel=HIGH)
 Constructor of the sensor class. More...
 
 Tli493d (int resetPin, bool powerLevel=HIGH, AccessMode_e mode=MASTERCONTROLLEDMODE, TypeAddress_e productType=TLI493D_A0)
 Constructor of the sensor class. More...
 
 ~Tli493d (void)
 Destructor. More...
 
void begin (void)
 Starts the sensor. More...
 
void begin (bool)
 Starts the sensor. More...
 
void begin (TwoWire &bus, TypeAddress_e slaveAddress, bool reset, uint8_t oneByteRead)
 Starts the sensor. More...
 
bool setAccessMode (AccessMode_e mode)
 Sets the operating mode of the sensor. More...
 
void setTrigger (uint8_t trigger)
 Sets when new measurements are triggered in MASTERCONTROLLEDMODE. If invalid argument or sensor mode is LOWPOWERMODE this function returns without having any effect. More...
 
void enableTemp (void)
 Enables temperature measurement; by default already enabled. More...
 
void disableTemp (void)
 Disables temperature measurement to reduce power consumption. More...
 
void enableBz (void)
 Enables BZ measurement; by default already enabled. More...
 
void disableBz (void)
 Disables Bz measurement to reduce power consumption. This only works, when temperature measurement is disabled as well. More...
 
bool setWakeUpThreshold (float xh, float xl, float yh, float yl, float zh, float zl)
 The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set with a ratio of size [-1,1] When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned even thought the values are written to the wake-up regeisters. More...
 
bool setWakeUpThresholdLSB (int16_t xh, int16_t xl, int16_t yh, int16_t yl, int16_t zh, int16_t zl)
 The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in LSB [-2048,2047]. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters. More...
 
bool setWakeUpThresholdMT (float xh, float xl, float yh, float yl, float zh, float zl)
 The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in mT. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters. More...
 
bool wakeUpEnabled (void)
 Checks if WA bit is set. When not interrupt configuration is as specified by the CA and INT bits. More...
 
void enableWakeUp (void)
 Enables the Wake Up functionality of the sensor. Following conditions must be fulfilled: More...
 
void disableWakeUp (void)
 Disables the Wake Up functionality of the sensor. More...
 
void setUpdateRate (uint8_t updateRate)
 Sets the update rate in low power mode. More...
 
bool setMeasurementRange (Range_e range)
 Sets the magnetic range that can be measured. The smaller the range, the higher the sensitivity. Please note: The EXTRASHORT-range enables the T-Bit in Register 0x06 and therefore cannot be used together with the WakeUp-feature. Before setting the range to EXTRASHORT, the WakeUp needs to be disabled via disableWakeUp(). Otherwise this function will return false without taking effect. More...
 
Tli493d_Error updateData (void)
 Reads measurement results from sensor. More...
 
float getX (void)
 
float getY (void)
 
float getZ (void)
 
float getNorm (void)
 
float getAzimuth (void)
 
float getPolar (void)
 
float getTemp (void)
 
void resetSensor (void)
 Resets the sensor. More...
 
void readDiagnosis (uint8_t(&diag)[7])
 
void enableInterrupt (void)
 Enables interrupts. More...
 
void disableInterrupt (void)
 Disables interrupts; When Collision Avoidance is activated, Sensor read-outs are suppressed during ongoing ADC conversion (clock stretching) More...
 
void enableCollisionAvoidance (void)
 Enables collision avoidance. When Interrupt is deactivated, clock stretching is active. For clock stretching: SCL and INT pins must be shorted. More...
 
void disableCollisionAvoidance (void)
 Disables collision avoidance; readouts may collide with ADC conversion. More...
 

Protected Member Functions

void setRegBits (uint8_t regMaskIndex, uint8_t data)
 Stores new values into the bus interface; for this function to take effect the function writeOut() should be called afterwards. More...
 
uint8_t getRegBits (uint8_t regMaskIndex)
 Returns the value of a register field. More...
 

Protected Attributes

tli493d::BusInterface_t mInterface
 

Member Enumeration Documentation

Defines four types of the sensor family which are supported by this library and their corresponding addresses The addresses can be concatenated with 0 or 1 for reading or writing

Enumerator
TLI493D_A0 
TLI493D_A1 
TLI493D_A2 
TLI493D_A3 

Enumerates the three available modes; number 2 is reserved In low power mode cyclic measurements and ADC-conversions are carried out with a update rate; the wake-up function is already configured for this mode, so that the sensor can continue making magnetic field measurements. With this configuration the microcontroller will only consume power and access the sensor if relevant measurement data is available. In master controlled mode the sensor powered down if when it is not triggered. This library configures to ADC start before sending first MSB of data registers In fast mode the measurements and ADC-conversions are running continuously.

Enumerator
LOWPOWERMODE 
MASTERCONTROLLEDMODE 
FASTMODE 

Enumerates the three available ranges; number 2 is reserved The full range is from -160mT to 160mT with a sensitivity of 7.7 LSB/mT. The short range is from -100mT to 100mT with a sensitivity of 15.4 LSB/mT. The extra short range is from -50mT to 50mT with a sensitivity of 30.8 LSB/mT. This is a special feature of the W2BW type.

Enumerator
FULL 
SHORT 
EXTRASHORT 

Constructor & Destructor Documentation

Tli493d::Tli493d ( AccessMode_e  mode = MASTERCONTROLLEDMODE,
TypeAddress_e  productType = TLI493D_A0,
int  resetPin = NO_POWER_PIN,
bool  powerLevel = HIGH 
)

Constructor of the sensor class.

Parameters
modeOperating mode of the sensor; default is the master controlled mode
productTypeThe library supports product types from A0 to A3; default is type A0
Tli493d::Tli493d ( int  resetPin,
bool  powerLevel = HIGH,
AccessMode_e  mode = MASTERCONTROLLEDMODE,
TypeAddress_e  productType = TLI493D_A0 
)

Constructor of the sensor class.

Parameters
modeOperating mode of the sensor; default is the master controlled mode
productTypeThe library supports product types from A0 to A3; default is type A0
Tli493d::~Tli493d ( void  )

Destructor.

Member Function Documentation

void Tli493d::begin ( void  )

Starts the sensor.

void Tli493d::begin ( bool  reset)

Starts the sensor.

Here is the call graph for this function:

void Tli493d::begin ( TwoWire &  bus,
TypeAddress_e  slaveAddress,
bool  reset,
uint8_t  oneByteRead 
)

Starts the sensor.

Parameters
busThe I2C bus
slaveAddressThe 7-bit slave address as defined in Tli493d_Type
resetIf a reset should be initiated before starting the sensor
oneByteReadIf one-byte read protocol should be used. Otherwise the two-byte protocol is available

Here is the call graph for this function:

bool Tli493d::setAccessMode ( AccessMode_e  mode)

Sets the operating mode of the sensor.

Parameters
modeMASTERCONTROLLEDMODE,LOWPOWERMODE or FASTMODE, default is MASTERCONTROLLEDMODE
Returns
true if configuration was successfull, otherwise false

Here is the call graph for this function:

void Tli493d::setTrigger ( uint8_t  trigger)

Sets when new measurements are triggered in MASTERCONTROLLEDMODE. If invalid argument or sensor mode is LOWPOWERMODE this function returns without having any effect.

Parameters
trigger0 = no measurements, 1 = measurements on read before first MSB, 2 = measurements on read after register 0x05

Here is the call graph for this function:

void Tli493d::enableTemp ( void  )

Enables temperature measurement; by default already enabled.

Here is the call graph for this function:

void Tli493d::disableTemp ( void  )

Disables temperature measurement to reduce power consumption.

Here is the call graph for this function:

void Tli493d::enableBz ( void  )

Enables BZ measurement; by default already enabled.

Here is the call graph for this function:

void Tli493d::disableBz ( void  )

Disables Bz measurement to reduce power consumption. This only works, when temperature measurement is disabled as well.

Here is the call graph for this function:

bool Tli493d::setWakeUpThreshold ( float  xh,
float  xl,
float  yh,
float  yl,
float  zh,
float  zl 
)

The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set with a ratio of size [-1,1] When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned even thought the values are written to the wake-up regeisters.

Parameters
xhUpper threshold in x direction [-1,1]
xlLower threshold in x direction [-1,1]
yhUpper threshold in y direction [-1,1]
ylLower threshold in y direction [-1,1]
zhUpper threshold in z direction [-1,1]
zlLower threshold in z direction [-1,1]
Returns
true if configuration was successfull and interrupts will be sent, otherwise false.

Here is the call graph for this function:

bool Tli493d::setWakeUpThresholdLSB ( int16_t  xh,
int16_t  xl,
int16_t  yh,
int16_t  yl,
int16_t  zh,
int16_t  zl 
)

The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in LSB [-2048,2047]. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters.

Parameters
xhUpper threshold in x direction [-2048,2047]
xlLower threshold in x direction [-2048,2047]
yhUpper threshold in y direction [-2048,2047]
ylLower threshold in y direction [-2048,2047]
zhUpper threshold in z direction [-2048,2047]
zlLower threshold in z direction [-2048,2047]
Returns
true if configuration was successfull and interrupts will be sent, otherwise false.

Here is the call graph for this function:

bool Tli493d::setWakeUpThresholdMT ( float  xh,
float  xl,
float  yh,
float  yl,
float  zh,
float  zl 
)

The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in mT. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters.

Parameters
xhUpper threshold in x direction in mT
xlLower threshold in x direction in mT
yhUpper threshold in y direction in mT
ylLower threshold in y direction in mT
zhUpper threshold in z direction in mT
zlLower threshold in z direction in mT
Returns
true if configuration was successfull and interrupts will be sent, otherwise false.

Here is the call graph for this function:

bool Tli493d::wakeUpEnabled ( void  )

Checks if WA bit is set. When not interrupt configuration is as specified by the CA and INT bits.

Here is the call graph for this function:

void Tli493d::enableWakeUp ( void  )

Enables the Wake Up functionality of the sensor. Following conditions must be fulfilled:

  • Test modes must be disabled and the T-Bit in Register 0x06 needs to be 0.

CP parity bit must be odd

  • Configuration partiy must be flagged (CF bit in Register 0x06 needs to be 1). You can check, if the Wake-Up-functionality is activated with the function wakeUpEnabled()

Here is the call graph for this function:

void Tli493d::disableWakeUp ( void  )

Disables the Wake Up functionality of the sensor.

Here is the call graph for this function:

void Tli493d::setUpdateRate ( uint8_t  updateRate)

Sets the update rate in low power mode.

Parameters
updateRateUpdate rate which is an unsigned integer from the 0 (the fastest) to 7 (the highest)

Here is the call graph for this function:

bool Tli493d::setMeasurementRange ( Range_e  range)

Sets the magnetic range that can be measured. The smaller the range, the higher the sensitivity. Please note: The EXTRASHORT-range enables the T-Bit in Register 0x06 and therefore cannot be used together with the WakeUp-feature. Before setting the range to EXTRASHORT, the WakeUp needs to be disabled via disableWakeUp(). Otherwise this function will return false without taking effect.

Parameters
rangeFULL, SHORT or EXTRASHORT, default is FULL.
Returns
true if configuration was successfull, otherwise false.

Here is the call graph for this function:

Tli493d_Error_t Tli493d::updateData ( void  )

Reads measurement results from sensor.

Here is the call graph for this function:

float Tli493d::getX ( void  )
Returns
the Cartesian x-coordinate
float Tli493d::getY ( void  )
Returns
the Cartesian y-coordinate
float Tli493d::getZ ( void  )
Returns
the Cartesian z-coordinate
float Tli493d::getNorm ( void  )
Returns
norm of the magnetic field vector sqrt(x^2 + y^2 + z^2)
float Tli493d::getAzimuth ( void  )
Returns
the Azimuth angle arctan(y/x)
float Tli493d::getPolar ( void  )
Returns
the angle in polar coordinates arctan(z/(sqrt(x^2+y^2)))
float Tli493d::getTemp ( void  )
Returns
the temperature value
void Tli493d::resetSensor ( void  )

Resets the sensor.

void Tli493d::readDiagnosis ( uint8_t(&)  diag[7])

Here is the call graph for this function:

void Tli493d::enableInterrupt ( void  )

Enables interrupts.

Here is the call graph for this function:

void Tli493d::disableInterrupt ( void  )

Disables interrupts; When Collision Avoidance is activated, Sensor read-outs are suppressed during ongoing ADC conversion (clock stretching)

Here is the call graph for this function:

void Tli493d::enableCollisionAvoidance ( void  )

Enables collision avoidance. When Interrupt is deactivated, clock stretching is active. For clock stretching: SCL and INT pins must be shorted.

Here is the call graph for this function:

void Tli493d::disableCollisionAvoidance ( void  )

Disables collision avoidance; readouts may collide with ADC conversion.

Here is the call graph for this function:

void Tli493d::setRegBits ( uint8_t  regMaskIndex,
uint8_t  data 
)
protected

Stores new values into the bus interface; for this function to take effect the function writeOut() should be called afterwards.

Parameters
Registermask index as defined in Registers_e
Valueto be written into the register field specified by the register index

Here is the call graph for this function:

uint8_t Tli493d::getRegBits ( uint8_t  regMaskIndex)
protected

Returns the value of a register field.

Parameters
Registermask index as defined in Registers_e

Here is the call graph for this function:

Member Data Documentation

tli493d::BusInterface_t Tli493d::mInterface
protected

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