View Source pmod_nav (grisp v2.8.0)
Driver module for the PmodNAV 9-axis IMU plus barometer device.
For more information see the Tutorial at the GRiSP Wiki: PmodNAV Tutorial.
Start the driver with
1> grisp:add_device(spi1, pmod_nav).
Summary
Functions
Change configurations.
Equivalent to read(Comp, Registers, #{})
.
Read registers of a component.
Get the registers (with the possible entries) of all components.
Get the registers (with the possible entries) of one component.
Types
Functions
-spec config(component(), #{}) -> ok.
Change configurations.
Examples
To switch to accelerometer only mode, i.e., power down the gyroscope, use:
2> pmod_nav:config(acc, #{odr_g => power_down}).
ok
To turn the gyroscope back on use:
3> pmod_nav:config(acc, #{odr_g => {hz,14.9}}).
ok
For more possible configurations see the datasheets LSM9DS1 and LPS25HB.
Use registers/0
and registers/1
to see the mapping between
Erlang expressions and the bits on the hardware.
Equivalent to read(Comp, Registers, #{})
.
Read registers of a component.
Examples
To read the accelerometer X, Y and Z axises G-forces in milli g, use:
4> pmod_nav:read(acc, [out_x_xl, out_y_xl, out_z_xl], #{xl_unit => mg}).
[50.813,6.527,983.7470000000001]
Further Registers
Component | Registers | Possible Options | Description |
---|---|---|---|
acc | [out_x_g, out_y_g, out_z_g] | #{g_unit => dps | mdps} default dps | Rotation of the axises x,y and z in (milli) degrees per second |
acc | [out_x_xl, out_y_xl, out_z_xl] | #{xl_unit => g | mg} default g | G-force on the axises x,y and z |
mag | [out_x_m, out_y_m, out_z_m] | #{mag_unit => gauss | mgauss} default gauss | Strength of the magnetic field in (milli) gauss |
alt | [press_out] | Pressure in hPa | |
alt | [temp_out] | Temperature in °C |
For all registers see registers/0
and registers/1
and use the datasheets
LPS25HB
and
LPS25HB
for a complete description.
-spec registers() -> #{component() => #{}}.
Get the registers (with the possible entries) of all components.
Get the registers (with the possible entries) of one component.
Example
To see the possible configurations in ctrl_reg1_g
use:
4> maps:find(ctrl_reg1_g, pmod_nav:registers(acc)).
{ok,{16,read_write,1,
[{odr_g,3,
#{power_down => 0,
{hz,119} => 3,
{hz,238} => 4,
{hz,476} => 5,
{hz,952} => 6,
{hz,14.9} => 1,
{hz,59.5} => 2}},
{fs_g,2,#{{dps,245} => 0,{dps,500} => 1,{dps,2000} => 3}},
{0,1},
{bw_g,2,raw}]}}