Skip to content

Commit

Permalink
送信速度を更新
Browse files Browse the repository at this point in the history
  • Loading branch information
chama1176 committed Sep 22, 2024
1 parent 0bac87f commit b436891
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
i_d: 0.0,
i_q: self.tv * 0.5,
};
let kp = 1.2;
let kp = 1.0;
let ki = 0.01;

let err_current = DQCurrent{
Expand Down
3 changes: 2 additions & 1 deletion src/bldc_motor_driver_stm32g4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ impl<'a> Uart1 {
uart.cr1.modify(|_, w| w.m1().clear_bit());
// FIFO?
// Set baud rate
uart.brr.modify(|_, w| unsafe { w.bits(0x4BF) }); // 140MHz / 115200
// uart.brr.modify(|_, w| unsafe { w.bits(0x4BF) }); // 140MHz / 115200
uart.brr.modify(|_, w| unsafe { w.bits(0x98) }); // 140MHz / 921600 = 152

// Set stop bit
uart.cr2.modify(|_, w| unsafe { w.stop().bits(0b00) });
Expand Down
26 changes: 13 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ fn main() -> ! {
// )
// .unwrap();

// // floatのまま送るとFLASHをバカほど食うのでcastする
// write!(
// uart,
// "{{\"ma\":{:4}}}\r\n",
// (mechanical_angle * 1000.0) as i32,
// )
// .unwrap();
// floatのまま送るとFLASHをバカほど食うのでcastする
write!(
uart,
"{{\"ma\":{:4}}}\r\n",
(mechanical_angle * 1000.0) as i32,
)
.unwrap();

// // floatのまま送るとFLASHをバカほど食うのでcastする
// write!(
Expand All @@ -332,12 +332,12 @@ fn main() -> ! {
// .unwrap();

// floatのまま送るとFLASHをバカほど食うのでcastする
// write!(
// uart,
// "{{\"d\":{:4}}}\r\n",
// (dq_current.i_d * 1000.0) as i32,
// )
// .unwrap();
write!(
uart,
"{{\"d\":{:4}}}\r\n",
(dq_current.i_d * 1000.0) as i32,
)
.unwrap();
write!(
uart,
"{{\"q\":{:4}}}\r\n",
Expand Down

0 comments on commit b436891

Please sign in to comment.