public static float[] ConvertByteToVoltage(this byte[] buffer, SmartScope.GainCalibration calibration, byte yOffset, ProbeDivision division) { double[] coefficients = calibration.coefficients; float[] voltage = new float[buffer.Length]; //this section converts twos complement to a physical voltage value float totalOffset = (float)(yOffset * coefficients[1] + coefficients[2]); float gain = division; voltage = buffer.Select(x => (float)(x * coefficients[0] + totalOffset) * gain).ToArray(); return(voltage); }
public static float[] ConvertByteToVoltage(this byte[] buffer, SmartScope.GainCalibration calibration, byte yOffset, AnalogChannel ch) { double[] coefficients = calibration.coefficients; float[] voltage = new float[buffer.Length]; //this section converts twos complement to a physical voltage value float totalOffset = (float)(yOffset * coefficients[1] + coefficients[2]); float probeGain = ch.Probe.Gain; float probeOffset = ch.Probe.Offset; if (ch.Inverted) { voltage = buffer.Select(x => - ((float)(x * coefficients[0] + totalOffset) * probeGain + probeOffset)).ToArray(); } else { voltage = buffer.Select(x => (float)(x * coefficients[0] + totalOffset) * probeGain + probeOffset).ToArray(); } return(voltage); }
public static float ConvertByteToVoltage(this byte b, SmartScope.GainCalibration calibration, byte yOffset, AnalogChannel ch) { return((new byte[] { b }).ConvertByteToVoltage(calibration, yOffset, ch)[0]); }
public static float ConvertByteToVoltage(this byte b, SmartScope.GainCalibration calibration, byte yOffset, ProbeDivision division) { return((new byte[] { b }).ConvertByteToVoltage(calibration, yOffset, division)[0]); }