Limit i_set within range of MAX1968 chip
parent
76547be90a
commit
cb4d5b737e
|
@ -129,7 +129,16 @@ impl<'a> Channels<'a> {
|
|||
voltage
|
||||
}
|
||||
|
||||
pub fn set_i(&mut self, channel: usize, i_set: ElectricCurrent) -> ElectricCurrent {
|
||||
pub fn set_i(&mut self, channel: usize, mut i_set: ElectricCurrent) -> ElectricCurrent {
|
||||
// Silently clamp i_set to available range of MAX1968 chip
|
||||
let min = ElectricCurrent::new::<ampere>(-3.0);
|
||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||
if i_set < min {
|
||||
i_set = min;
|
||||
}
|
||||
if i_set > max {
|
||||
i_set = max;
|
||||
}
|
||||
let vref_meas = match channel.into() {
|
||||
0 => self.channel0.vref_meas,
|
||||
1 => self.channel1.vref_meas,
|
||||
|
|
Loading…
Reference in New Issue