Module pmod_nav

Driver module for the PmodNAV 9-axis IMU plus barometer device.

Behaviours: gen_server.

Description

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).

Data Types

component()

component() = acc | mag | alt

opts()

opts() = #{}

register()

register() = atom()

Function Index

config/2Change configurations.
read/2Equivalent to read(Comp, Registers, #{}).
read/3Read registers of a component.
registers/0Get the registers (with the possible entries) of all components.
registers/1Get the registers (with the possible entries) of one component.

Function Details

config/2

config(Comp::component(), Options::#{}) -> 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.

read/2

read(Comp::component(), Registers::[register()]) -> any() | {error, any()}

Equivalent to read(Comp, Registers, #{}).

read/3

read(Comp::component(), Registers::[register()], Opts::opts()) -> any() | {error, any()}

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

ComponentRegistersPossible 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 LSM9DS1 and LPS25HB for a complete description.

registers/0

registers() -> #{component() => #{}}

Get the registers (with the possible entries) of all components.

registers/1

registers(X1::component()) -> #{atom() => any()}

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}]}}


Generated by EDoc