Skip to content

Commit

Permalink
added max_current
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfbastos committed Nov 16, 2024
1 parent 782db6d commit 8974a7a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions boards/stm32l432kc/src/bin/levitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ use embassy_time::Instant;
use {defmt_rtt as _, panic_probe as _};

const MAX_VOLTAGE: f32 = 500.0; // TBD
const MAX_CURRENT: f32 = 500.0; // TBD
const TARGET_HEIGHT: f32 = 10.0; // to be determined by levitation

const GAIN_HEIGHT = PidGain{
const GAIN_HEIGHT: PidGain = PidGain{
// to be determined by levitation
kp: 1.0,
ki: 0.05,
kd: 0.005,
};

const GAIN_CURRENT = PidGain{
const GAIN_CURRENT: PidGain = PidGain{
// to be determined by levitation
kp: 1.1,
ki: 0.12,
Expand Down Expand Up @@ -56,7 +57,9 @@ async fn main(_spawner: Spawner) {

let output_height_pid = pid_height.update(TARGET_HEIGHT, actual_height, dt);

let target_current = actual_height + output_height_pid;
let mut target_current = actual_height + output_height_pid;

if target_current >= MAX_CURRENT {target_current = MAX_CURRENT};

let actual_current = 1.0; // we'll get that from a sensor

Expand Down

0 comments on commit 8974a7a

Please sign in to comment.