Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT settings and telemetry #261

Merged
merged 32 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f0e7c15
Adding WIP refactor for MQTT + settings
ryan-summers Jan 26, 2021
a772ccc
Adding WIP updates for StringSet
ryan-summers Jan 26, 2021
702ccc2
Using custom branch of miniconf
ryan-summers Jan 27, 2021
e954ba3
Merge branch 'master' into feature/mqtt-convert
ryan-summers Jan 30, 2021
b73286c
Removing MQTT interface
ryan-summers Jan 30, 2021
9a1bb5d
Fixing build
ryan-summers Jan 30, 2021
411a847
Updating smoltcp-nal
ryan-summers Jan 30, 2021
096f786
Expanding miniconf to lockin
ryan-summers Jan 30, 2021
913990d
Merge remote-tracking branch 'origin/rj/bump-hal-smoltcp' into featur…
ryan-summers Feb 3, 2021
9e1a6ec
Updating dependencies
ryan-summers Feb 3, 2021
738516e
Adding broken example
ryan-summers Feb 3, 2021
91f16c2
Adding working example
ryan-summers Feb 3, 2021
9e1f4a8
Merge branch 'master' into feature/mqtt-convert
ryan-summers Feb 17, 2021
13e0271
Adding simplified clocking semantics
ryan-summers Feb 17, 2021
cb16e9a
Updating settings update function
ryan-summers Feb 17, 2021
6b0595b
Fixing dsp toml
ryan-summers Feb 17, 2021
b66f80f
Fixing dependencies
ryan-summers Feb 17, 2021
50476f6
Adding settings support for lockin-external
ryan-summers Feb 17, 2021
e8711d8
Merge branch 'master' into feature/mqtt-convert
ryan-summers Feb 17, 2021
3c8cd58
Removing lockin-external changes
ryan-summers Feb 17, 2021
e8c4829
Adding docs for the cycle counter
ryan-summers Feb 17, 2021
a55b30e
Working around dependency injection bug
ryan-summers Feb 17, 2021
63a2220
Removing support for configuring IIR state
ryan-summers Feb 17, 2021
90ef083
Fixing style
ryan-summers Feb 17, 2021
78e69b1
s/criterion/easybench/ for less weight
jordens Feb 17, 2021
0425036
deps: make miniconf a patch
jordens Feb 17, 2021
65a0831
Merge branch 'master' into feature/mqtt-convert
ryan-summers Feb 19, 2021
2ac7568
Updating dependencies
ryan-summers Feb 19, 2021
c6ef78c
Pulling back easybench changes
ryan-summers Feb 19, 2021
04dff30
Fixing dependencies:
ryan-summers Feb 19, 2021
76f2f74
Removing information about legacy server
ryan-summers Feb 19, 2021
28db428
Fixing bench tests
ryan-summers Feb 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ panic-semihosting = { version = "0.5", optional = true }
panic-halt = "0.2"
serde = { version = "1.0", features = ["derive"], default-features = false }
heapless = { version = "0.5", features = ["serde"] }
serde-json-core = "0.2"
cortex-m-rtic = "0.5.5"
embedded-hal = "0.2.4"
nb = "1.0.0"
Expand All @@ -46,13 +45,16 @@ paste = "1"
dsp = { path = "dsp" }
ad9959 = { path = "ad9959" }

[dependencies.miniconf]
git = "https://github.com/vertigo-designs/miniconf.git"
branch = "develop"

[dependencies.mcp23017]
git = "https://github.com/mrd0ll4r/mcp23017.git"

[dependencies.smoltcp]
version = "0.7"
features = ["ethernet", "proto-ipv4", "socket-tcp", "proto-ipv6"]
default-features = false
[dependencies.smoltcp-nal]
git = "https://github.com/vertigo-designs/smoltcp-nal.git"
ryan-summers marked this conversation as resolved.
Show resolved Hide resolved
branch = "main"

[dependencies.stm32h7xx-hal]
features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"]
Expand Down
1 change: 1 addition & 0 deletions dsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
libm = "0.2.1"
serde = { version = "1.0", features = ["derive"], default-features = false }
serde-json-core = "0.1"
ryan-summers marked this conversation as resolved.
Show resolved Hide resolved
generic-array = "0.14"

[dev-dependencies]
Expand Down
26 changes: 13 additions & 13 deletions dsp/src/iir.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use miniconf::StringSet;

use super::{abs, copysign, macc, max, min};
use core::f32;
Expand All @@ -11,8 +12,7 @@ use core::f32;
/// To represent the IIR coefficients, this contains the feed-forward
/// coefficients (b0, b1, b2) followd by the negated feed-back coefficients
/// (-a1, -a2), all five normalized such that a0 = 1.
#[derive(Copy, Clone, Default, Deserialize, Serialize)]
pub struct Vec5(pub [f32; 5]);
pub type Vec5 = [f32; 5];
ryan-summers marked this conversation as resolved.
Show resolved Hide resolved

/// IIR configuration.
///
Expand All @@ -39,7 +39,7 @@ pub struct Vec5(pub [f32; 5]);
/// Therefore it can trivially implement bump-less transfer.
/// * Cascading multiple IIR filters allows stable and robust
/// implementation of transfer functions beyond bequadratic terms.
#[derive(Copy, Clone, Default, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, Default, Deserialize, StringSet)]
pub struct IIR {
pub ba: Vec5,
pub y_offset: f32,
Expand All @@ -50,7 +50,7 @@ pub struct IIR {
impl IIR {
pub const fn new(gain: f32, y_min: f32, y_max: f32) -> Self {
Self {
ba: Vec5([gain, 0., 0., 0., 0.]),
ba: [gain, 0., 0., 0., 0.],
y_offset: 0.,
y_min,
y_max,
Expand Down Expand Up @@ -84,13 +84,13 @@ impl IIR {
}
(a1, b0, b1)
};
self.ba.0.copy_from_slice(&[b0, b1, 0., a1, 0.]);
self.ba.copy_from_slice(&[b0, b1, 0., a1, 0.]);
Ok(())
}

/// Compute the overall (DC feed-forward) gain.
pub fn get_k(&self) -> f32 {
self.ba.0[..3].iter().sum()
self.ba[..3].iter().sum()
}

/// Compute input-referred (`x`) offset from output (`y`) offset.
Expand Down Expand Up @@ -118,21 +118,21 @@ impl IIR {
/// * `xy` - Current filter state.
/// * `x0` - New input.
pub fn update(&self, xy: &mut Vec5, x0: f32) -> f32 {
let n = self.ba.0.len();
debug_assert!(xy.0.len() == n);
let n = self.ba.len();
debug_assert!(xy.len() == n);
// `xy` contains x0 x1 y0 y1 y2
// Increment time x1 x2 y1 y2 y3
// Shift x1 x1 x2 y1 y2
// This unrolls better than xy.rotate_right(1)
xy.0.copy_within(0..n - 1, 1);
xy.copy_within(0..n - 1, 1);
// Store x0 x0 x1 x2 y1 y2
xy.0[0] = x0;
xy[0] = x0;
// Compute y0 by multiply-accumulate
let y0 = macc(self.y_offset, &xy.0, &self.ba.0);
let y0 = macc(self.y_offset, xy, &self.ba);
// Limit y0
let y0 = max(self.y_min, min(self.y_max, y0));
// Store y0 x0 x1 y0 y1 y2
xy.0[n / 2] = y0;
xy[n / 2] = y0;
y0
}
}
Loading