private void Initialize(UIOMode mode, int select, int hwres, int intParam, bool isDigital, double scale, double offset) { _uioMode = mode; SelPort = (UIOSelector)select; switch (mode) { case UIOMode.UIOModeDigitalInput: break; case UIOMode.UIOModeDigitalOutput: DigitalOut = new DigitalOutput((Output)hwres); break; case UIOMode.UIOModeAnalogInput: _avg = new MovingAverageCalculator(intParam); AnalogIn = new AnalogIn((ADC)hwres, scale, offset, intParam) {Scale = scale, Offset = offset}; break; case UIOMode.UIOModeSoftPwm: if (intParam < 1 || intParam > 1000) throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1000 Hz", "freq"); //creo ed avvio il PWM software _softPwm = new SoftPWM(intParam, (Cpu.Pin)hwres); SoftPWM.Start(); break; case UIOMode.UIOModeRealPwm: if (intParam < 1 || intParam > 1000000) throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1 MHz", "freq"); //creo ed avvio il PWM hardware _realPwm = new PWM((Cpu.PWMChannel)hwres, intParam, 0, false); _realPwm.Start(); break; case UIOMode.UIOModeSoftDac: if (intParam < 1 || intParam > 1000) throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1000 Hz", "freq"); //creo ed avvio il PWM software _softPwm = new SoftPWM(intParam, (Cpu.Pin)hwres); SoftPWM.Start(); break; case UIOMode.UIOModeRealDac: if (intParam < 1 || intParam > 1000000) throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1 MHz", "freq"); //creo ed avvio il PWM hardware _realPwm = new PWM((Cpu.PWMChannel)hwres, intParam, 0, false); _realPwm.Start(); break; default: break; } //seleziono sul modulo il tipo di uscita DAC/PWM _pwmSel = new DigitalOutput((Output)SelPort); _pwmSel.Write(isDigital); }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> /// <param name="r0">Resistenza in Ohm dell'PRT alla temperatura T0</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'PRT (in Ohm)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Prt(ADC res, double scale, double offset, int movingAverageSize, int r0, double rb, double vref) : this(r0, rb, vref) { _ai = new AnalogIn(res, movingAverageSize) {Scale = scale, Offset = offset}; }
private void Initialize(UIOMode mode, int select, int hwres, int intParam, bool isDigital, double scale, double offset) { _uioMode = mode; SelPort = (UIOSelector)select; switch (mode) { case UIOMode.UIOModeDigitalInput: break; case UIOMode.UIOModeDigitalOutput: DigitalOut = new DigitalOutput((Output)hwres); break; case UIOMode.UIOModeAnalogInput: _avg = new MovingAverageCalculator(intParam); AnalogIn = new AnalogIn((ADC)hwres, scale, offset, intParam) { Scale = scale, Offset = offset }; break; case UIOMode.UIOModeSoftPwm: if (intParam < 1 || intParam > 1000) { throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1000 Hz", "freq"); } //creo ed avvio il PWM software _softPwm = new SoftPWM(intParam, (Cpu.Pin)hwres); SoftPWM.Start(); break; case UIOMode.UIOModeRealPwm: if (intParam < 1 || intParam > 1000000) { throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1 MHz", "freq"); } //creo ed avvio il PWM hardware _realPwm = new PWM((Cpu.PWMChannel)hwres, intParam, 0, false); _realPwm.Start(); break; case UIOMode.UIOModeSoftDac: if (intParam < 1 || intParam > 1000) { throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1000 Hz", "freq"); } //creo ed avvio il PWM software _softPwm = new SoftPWM(intParam, (Cpu.Pin)hwres); SoftPWM.Start(); break; case UIOMode.UIOModeRealDac: if (intParam < 1 || intParam > 1000000) { throw new ArgumentOutOfRangeException("Il valore deve essere compreso nel range 1...1 MHz", "freq"); } //creo ed avvio il PWM hardware _realPwm = new PWM((Cpu.PWMChannel)hwres, intParam, 0, false); _realPwm.Start(); break; default: break; } //seleziono sul modulo il tipo di uscita DAC/PWM _pwmSel = new DigitalOutput((Output)SelPort); _pwmSel.Write(isDigital); }