Skip to content

Commit

Permalink
ice: add 2g, 125 dps mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Feb 18, 2025
1 parent 585e5ad commit 6e3861b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions sfy-buoy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fir = []
storage = []
ext-gps = [ "dep:serde-json-core"]
surf = []
ice = []
target-test = [ "storage" ]
build-bin = [ "fir", "storage", "raw", "anyhow", "argh", "serde-json-core/std", "serde_json", "chrono/std" ]

Expand Down
6 changes: 6 additions & 0 deletions sfy-buoy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ AUXRX/AUXTX and pull AUXEN up](https://dev.blues.io/guides-and-tutorials/notecar
* surf: increase accel and gyro range to expect greater forces impacted by
breaking waves.

* ice: increase sensitivity (opposite of surf), expect low movement and low
forces. typically used for ice deployments.

* lowaccel: increase accel and gyro range to expect greater forces impacted by
breaking waves.

* raw: store raw data on SD-card (experimental)

* host-tests: used to disable code that doesn't compile on host, for running
Expand Down
1 change: 1 addition & 0 deletions sfy-buoy/sfy-artemis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ raw = [ "sfy/raw" ]
fir = [ "sfy/fir" ]
storage = [ "sfy/storage" ]
surf = [ "sfy/surf" ]
ice = [ "sfy/ice" ]
deploy = []
defmt-serial = [ "dep:ufmt", "dep:defmt-serial" ]

1 change: 1 addition & 0 deletions sfy-buoy/sfy-ext-gps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ raw = [ "sfy/raw" ]
fir = [ "sfy/fir" ]
storage = [ "sfy/storage" ]
surf = [ "sfy/surf" ]
ice = [ "sfy/ice" ]
deploy = []
host-tests = []
# defmt-serial = [ "dep:ufmt", "dep:defmt-serial" ]
Expand Down
26 changes: 22 additions & 4 deletions sfy-buoy/src/waves/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,23 @@ pub type AxlPacketT = (AxlPacket,);

pub const FREQ: Freq = Freq::Hz208;

#[cfg(all(feature = "surf", feature = "ice"))]
compile_error!("only one of the surf and ice features should be enabled at the same time.");

// See discussion below in `boot`.
#[cfg(feature = "surf")]
pub const ACCEL_RANGE: f32 = 16.; // [g]
#[cfg(feature = "surf")]
pub const GYRO_RANGE: f32 = 1000.; // [dps]
//
#[cfg(not(feature = "surf"))]
#[cfg(feature = "ice")]
pub const ACCEL_RANGE: f32 = 2.; // [g]
#[cfg(feature = "ice")]
pub const GYRO_RANGE: f32 = 125.; // [dps]
//
#[cfg(all(not(feature = "surf"), not(feature = "ice")))]
pub const ACCEL_RANGE: f32 = 4.; // [g]
#[cfg(not(feature = "surf"))]
#[cfg(all(not(feature = "surf"), not(feature = "ice")))]
pub const GYRO_RANGE: f32 = 500.; // [dps]

#[cfg(all(feature = "20Hz", not(feature = "fir")))]
Expand Down Expand Up @@ -271,7 +279,7 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
//
// Sinclair, Alexandra. “FlowRider: A Lagrangian Float to Measure 3-D Dynamics of Plunging Breakers in the Surf Zone.” Journal of Coastal Research 293 (January 2014): 205–9. https://doi.org/10.2112/JCOASTRES-D-13-00014.1.

#[cfg(not(feature = "surf"))]
#[cfg(all(not(feature = "surf"), not(feature = "ice")))]
sensor
.ctrl1xl
.set_chain_full_scale(i2c, ctrl1xl::Fs_Xl::G4)?;
Expand All @@ -281,6 +289,11 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
.ctrl1xl
.set_chain_full_scale(i2c, ctrl1xl::Fs_Xl::G16)?;

#[cfg(feature = "ice")]
sensor
.ctrl1xl
.set_chain_full_scale(i2c, ctrl1xl::Fs_Xl::G2)?;

defmt::info!(
"accelerometer range: {} g",
sensor.ctrl1xl.chain_full_scale()
Expand Down Expand Up @@ -315,7 +328,7 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
// gyro values.
//
// Feddersen, F., Andre Amador, Kanoa Pick, A. Vizuet, Kaden Quinn, Eric Wolfinger, J. H. MacMahan, and Adam Fincham. “The Wavedrifter: A Low-Cost IMU-Based Lagrangian Drifter to Observe Steepening and Overturning of Surface Gravity Waves and the Transition to Turbulence.” Coastal Engineering Journal, July 26, 2023, 1–14. https://doi.org/10.1080/21664250.2023.2238949.
#[cfg(not(feature = "surf"))]
#[cfg(all(not(feature = "surf"), not(feature = "ice")))]
sensor
.ctrl2g
.set_chain_full_scale(i2c, ctrl2g::Fs::Dps500)?;
Expand All @@ -325,6 +338,11 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
.ctrl2g
.set_chain_full_scale(i2c, ctrl2g::Fs::Dps1000)?;

#[cfg(feature = "ice")]
sensor
.ctrl2g
.set_chain_full_scale(i2c, ctrl2g::Fs::Dps125)?;

defmt::info!("gyroscope range: {} dps", sensor.ctrl2g.chain_full_scale());
assert_eq!(sensor.ctrl2g.chain_full_scale().dps(), GYRO_RANGE);

Expand Down

0 comments on commit 6e3861b

Please sign in to comment.