From 76547be90a4d06f71fd7fdbf898bfbeb92f8af9d Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 14 Feb 2024 17:01:19 +0800 Subject: [PATCH] i_tec -> i_set i_tec is reserved for the voltage signal coming out of the MAX1968 chip for now. --- src/channels.rs | 10 +++++----- src/command_handler.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/channels.rs b/src/channels.rs index b531e86..cfec178 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -129,7 +129,7 @@ impl<'a> Channels<'a> { voltage } - pub fn set_i(&mut self, channel: usize, i_tec: ElectricCurrent) -> ElectricCurrent { + pub fn set_i(&mut self, channel: usize, i_set: ElectricCurrent) -> ElectricCurrent { let vref_meas = match channel.into() { 0 => self.channel0.vref_meas, 1 => self.channel1.vref_meas, @@ -137,11 +137,11 @@ impl<'a> Channels<'a> { }; let center_point = vref_meas; let r_sense = ElectricalResistance::new::(R_SENSE); - let voltage = i_tec * 10.0 * r_sense + center_point; + let voltage = i_set * 10.0 * r_sense + center_point; let voltage = self.set_dac(channel, voltage); - let i_tec = (voltage - center_point) / (10.0 * r_sense); - self.channel_state(channel).i_set = i_tec; - i_tec + let i_set = (voltage - center_point) / (10.0 * r_sense); + self.channel_state(channel).i_set = i_set; + i_set } pub fn read_dac_feedback(&mut self, channel: usize) -> ElectricPotential { diff --git a/src/command_handler.rs b/src/command_handler.rs index 91b46d7..efea1b8 100644 --- a/src/command_handler.rs +++ b/src/command_handler.rs @@ -207,11 +207,11 @@ impl Handler { } fn set_center_point(socket: &mut TcpSocket, channels: &mut Channels, channel: usize, center: CenterPoint) -> Result { - let i_tec = channels.get_i(channel); + let i_set = channels.get_i(channel); let state = channels.channel_state(channel); state.center = center; if !state.pid_engaged { - channels.set_i(channel, i_tec); + channels.set_i(channel, i_set); } send_line(socket, b"{}"); Ok(Handler::Handled)