Behaviours: gen_server
.
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 with1> grisp:add_device(spi1, pmod_nav).
component() = acc | mag | alt
opts() = #{}
register() = atom()
config/2 | Change configurations. |
read/2 | Equivalent to read(Comp, Registers, #{}) .
|
read/3 | Read registers of a component. |
registers/0 | Get the registers (with the possible entries) of all components. |
registers/1 | Get the registers (with the possible entries) of one component. |
config(Comp::component(), Options::#{}) -> ok
Change configurations.
2> pmod_nav:config(acc, #{odr_g => power_down}). okTo turn the gyroscope back on use:
3> pmod_nav:config(acc, #{odr_g => {hz,14.9}}). okFor 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(Comp::component(), Registers::[register()]) -> any() | {error, any()}
Equivalent to read(Comp, Registers, #{})
.
read(Comp::component(), Registers::[register()], Opts::opts()) -> any() | {error, any()}
Read registers of a component.
4> pmod_nav:read(acc, [out_x_xl, out_y_xl, out_z_xl], #{xl_unit => mg}). [50.813,6.527,983.7470000000001]
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 |
registers/0
and registers/1
and use the datasheets
LSM9DS1
and
LPS25HB
for a complete description.
registers() -> #{component() => #{}}
Get the registers (with the possible entries) of all components.
registers(X1::component()) -> #{atom() => any()}
Get the registers (with the possible entries) of one component.
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