Skip to content

Commit

Permalink
removed space in TODOLater
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfbastos committed Nov 16, 2024
1 parent bfb54e7 commit 2aa3cbf
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 7 deletions.
14 changes: 7 additions & 7 deletions boards/stm32l432kc/src/bin/levitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ use embassy_time::Instant;

use {defmt_rtt as _, panic_probe as _};

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

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

const GAIN_CURRENT: PidGain = PidGain{
// TODO Later determined by levitation
// TODOLater determined by levitation
kp: 1.1,
ki: 0.12,
kd: 0.05,
Expand All @@ -51,15 +51,15 @@ async fn main(_spawner: Spawner) {

loop {

let actual_height = 0.7; // TODO Later we'll get that from a sensor
let actual_height = 0.7; // TODOLater we'll get that from a sensor

let dt = (Instant::now().as_micros() as f32) - time_start;

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

let target_current = (actual_height + output_height_pid).min(MAX_CURRENT);

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

let output_current_pid = pid_current.update(target_current, actual_current, dt);

Expand Down
87 changes: 87 additions & 0 deletions lib/motors/config/messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
struct Messages {
id: u16,
command: u8,
index: u16,
subindex: u8,
data: u32,
}

const TEST_STEPPER_ENABLE: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x09,
data: 0x00000001,
};

const TEST_MODE_COMMAND: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x2031,
subindex: 0x00,
data: 0x00000060,
};

const ENTER_STOP_STATE: Message = Message {
id: 0x000,
command: 0x02,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

const ENTER_PREOPERATIONAL_STATE: Message = Message {
id: 0x000,
command: 0x03,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

const ENTER_OPERATIONAL_STATE: Message = Message {
id: 0x000,
command: 0x01,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

const SET_FREQUENCY: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x2040,
subindex: 0x04,
data: 0x00000000,
};

const SHUTDOWN: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000006,
};

const SWITCH_ON: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000007,
};

const START_DRIVE: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x0000000F,
};

const QUICK_STOP: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000002,
};

0 comments on commit 2aa3cbf

Please sign in to comment.