Compare commits
2 Commits
dd06ae1075
...
94e0525002
Author | SHA1 | Date |
---|---|---|
Astro | 94e0525002 | |
Astro | 1157b73f7f |
|
@ -318,22 +318,21 @@ impl Channels {
|
|||
|
||||
pub fn get_max_v(&mut self, channel: usize) -> (ElectricPotential, ElectricPotential) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let max = 4.0 * vref;
|
||||
let duty = self.get_pwm(channel, PwmPin::MaxV);
|
||||
(duty * 4.0 * vref, 4.0 * vref)
|
||||
(duty * max, max)
|
||||
}
|
||||
|
||||
pub fn get_max_i_pos(&mut self, channel: usize) -> (ElectricCurrent, ElectricCurrent) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let scale = vref / ElectricPotential::new::<volt>(3.0) / ElectricCurrent::new::<ampere>(1.0);
|
||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||
let duty = self.get_pwm(channel, PwmPin::MaxIPos);
|
||||
(duty / scale, 1.0 / scale)
|
||||
(duty * max, max)
|
||||
}
|
||||
|
||||
pub fn get_max_i_neg(&mut self, channel: usize) -> (ElectricCurrent, ElectricCurrent) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let scale = vref / ElectricPotential::new::<volt>(3.0) / ElectricCurrent::new::<ampere>(1.0);
|
||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||
let duty = self.get_pwm(channel, PwmPin::MaxINeg);
|
||||
(duty / scale, 1.0 / scale)
|
||||
(duty * max, max)
|
||||
}
|
||||
|
||||
fn set_pwm(&mut self, channel: usize, pin: PwmPin, duty: f64) -> f64 {
|
||||
|
@ -365,24 +364,23 @@ impl Channels {
|
|||
|
||||
pub fn set_max_v(&mut self, channel: usize, max_v: ElectricPotential) -> (ElectricPotential, ElectricPotential) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let duty = (max_v / 4.0 / vref).get::<ratio>();
|
||||
let max = 4.0 * vref;
|
||||
let duty = (max_v / max).get::<ratio>();
|
||||
let duty = self.set_pwm(channel, PwmPin::MaxV, duty);
|
||||
(duty * 4.0 * vref, 4.0 * vref)
|
||||
(duty * max, max)
|
||||
}
|
||||
|
||||
pub fn set_max_i_pos(&mut self, channel: usize, max_i_pos: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let scale = vref / ElectricPotential::new::<volt>(3.0) / ElectricCurrent::new::<ampere>(1.0);
|
||||
let duty = (max_i_pos * scale).get::<ratio>();
|
||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||
let duty = (max_i_pos / max).get::<ratio>();
|
||||
let duty = self.set_pwm(channel, PwmPin::MaxIPos, duty);
|
||||
(duty / scale, 1.0 / scale)
|
||||
(duty * max, max)
|
||||
}
|
||||
|
||||
pub fn set_max_i_neg(&mut self, channel: usize, max_i_neg: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
||||
let vref = self.channel_state(channel).vref;
|
||||
let scale = vref / ElectricPotential::new::<volt>(3.0) / ElectricCurrent::new::<ampere>(1.0);
|
||||
let duty = (max_i_neg * scale).get::<ratio>();
|
||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||
let duty = (max_i_neg / max).get::<ratio>();
|
||||
let duty = self.set_pwm(channel, PwmPin::MaxINeg, duty);
|
||||
(duty / scale, 1.0 / scale)
|
||||
(duty * max, max)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ fn main() -> ! {
|
|||
vref.into_format_args(volt, Abbreviation), dac_feedback.into_format_args(volt, Abbreviation),
|
||||
itec.into_format_args(volt, Abbreviation), tec_i.into_format_args(ampere, Abbreviation),
|
||||
tec_u_meas.into_format_args(volt, Abbreviation),
|
||||
(tec_u_meas / tec_i).into_format_args(ohm, Abbreviation),
|
||||
((tec_u_meas - vref) / tec_i).into_format_args(ohm, Abbreviation),
|
||||
);
|
||||
} else {
|
||||
let _ = writeln!(socket, "channel {}: no adc input", channel);
|
||||
|
@ -269,7 +269,7 @@ fn main() -> ! {
|
|||
match (state.get_adc(), state.get_sens(), state.get_temperature()) {
|
||||
(Some(adc), Some(sens), Some(temp)) => {
|
||||
let _ = writeln!(
|
||||
socket, "- adc={:.6} r={:.0} temp{}={:.3}K",
|
||||
socket, "- adc={:.6} r={:.0} temp{}={:.3}",
|
||||
adc.into_format_args(volt, Abbreviation),
|
||||
sens.into_format_args(ohm, Abbreviation),
|
||||
channel,
|
||||
|
|
Loading…
Reference in New Issue