Advanced functions
The Accelerometer module working mode is to set and read registers, thus when it is wanted to change a data a register is set and when data wants to be read a register is read. There are some functions for writing and reading registers. As well, there are some registers that are used to configure the accelerometer module. These registers are called CTRL_REG1, CTRL_REG2, CTRL_REG3, CTRL_REG4
and CTRL_REG5
and are defined in the Waspmote ACC library as constants.
Some functions have been created to set and read these registers. However, these functions are not necessary for a basic accelerometer use.
Writing a register
It writes a byte into a register in the accelerometer.
It returns 1 if there is no error or 0 if there is error.
Example of use:
Reading a register
It reads a register from the accelerometer.
It returns 1 if there is no error or 0 if there is error.
Example of use:
Setting CTRL_REG1
It sets accelerometer's control register 1.
It returns '0' if error.
Since it calls writeRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Getting CTRL_REG1
It checks accelerometer's control register 1.
It returns the contents of control register 1.
Since it calls readRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Setting CTRL_REG2
It sets accelerometer's control register 2.
It returns '0' if error.
Since it calls writeRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Getting CTRL_REG2
It checks accelerometer's control register 2.
It returns the contents of control register 2.
Since it calls readRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Setting CTRL_REG3
It sets accelerometer's control register 3.
It returns '0' if error.
Since it calls writeRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Getting CTRL_REG3
It checks accelerometer's control register 3.
It returns the contents of control register 3.
Since it calls readRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Setting CTRL_REG4
It sets accelerometer's control register 4.
It returns '0' if error.
Since it calls writeRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Getting CTRL_REG4
It checks accelerometer's control register 4.
It returns the contents of control register 4.
Since it calls readRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Setting CTRL_REG5
It sets accelerometer's control register 5.
It returns '0' if error.
Since it calls writeRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Getting CTRL_REG5
It checks accelerometer's control register 5.
It returns the contents of control register 5.
Since it calls readRegister()
, it will not activate any flags by itself, but the other functions will activate ACC_ERROR_READING
in case there was an error when communicating to the register.
Example of use:
Sleep to wake mode
The sleep to wake function, in conjunction with Low Power mode, allows further reduction of system power consumption and the development of new smart applications. The accelerometer can be set in a low-power operating mode, characterized by lower date rate refreshments. In this way the device, even if "sleeping", continues sensing acceleration and generating interrupt requests.
When the sleep to wake function is activated, the accelerometer is able to automatically wake up Waspmote as soon as the interrupt event has been detected, increasing the output data rate and bandwidth. With this feature the Waspmote can be efficiently switched from Low Power mode to full performance, depending on user-selectable positioning and acceleration events, thus ensuring power saving and flexibility.
Setting sleep to wake mode
It sets the sleep to wake mode of the accelerometer.
Example of use:
Unsetting the sleep to wake mode
It unsets the sleep to wake mode of the accelerometer.
Example of use:
Last updated