Jump to content
  • 0

USB 1608 reads in DIFF mode but not SE


isherer

Question

My MCC DAQ will read diff mode inputs but when i configure to SE and rewire - my code gives me an error.

 

properties (Access = private)

GREEN = [0 1 0];

RED = [1 0 0];

StopFlag = 0;

B = 269.8;

C = -0.8808;

dofH2O = 62.426;

dofH2Otempref = 62.316;

viscosityStandard = 0.9973;

Pstd = 14.695333681130098 %Standard Pressure [PSI] (29.92" Hg);

Tstd = 70; %Standard Temperature [F]

%Creates structure to record data

Data = struct("Time",[], "DP",[], "PF", [], "LFEMassFlowRate", [], "DPTVoltage", [], "Tf", [], "massDieselB", [], "massBiodieselB", []);

%Data.DP; Differential Pressure measured by Sentra 239

%Data.PF; Flowing Pressure measured by sentra 280e

end

methods (Access = public)

function intialize(app)

app.DAQactiveLamp.Color = app.GREEN;

%intializes daq as readable object

global dq

dq = daq("mcc");

dq.Rate = 500;

%LFE airflow measurement

addinput(dq,'Board0','Ai0','Voltage'); %Sentra 239 Differential Pressure

addinput(dq,'Board0','Ai1','Voltage'); %Flowing Pressure (inlet presure) measured by sentra 280e

% addinput(dq,'Board0','Ai2','Voltage'); %LFE Thermocouple

% %Loadstar fuel measurement system [A]

% addinput(dq,'Board0','Ai3','Voltage'); %Loadstar RPP1 load cell

% addinput(dq,'Board0','Ai4','Voltage'); %Sending unit

% %Ian Sherer fuel measurement system [B]

addinput(dq,'Board0','Ai5','Voltage'); %Desiel Fuel load cell

addinput(dq,'Board0','Ai6','Voltage'); %Biodeisel Fuel load cell

end

end

% Code

methods (Access = protected)

function getAirFlow(app, Volts)

Volt = mean( Volts.Board0_Ai1, "all");

app.Data.DPTVoltage = [app.Data.DPTVoltage, Volt];

app.M280voltageEditField.Value = mean( Volts.Board0_Ai1, "all");

app.M239voltageEditField.Value = mean( Volts.Board0_Ai0, "all");

%Coverts average voltage Measured by Sentra 239 to Differential Pressure in inches of water

DP = mean( Volts.Board0_Ai0, "all") * 3;

app.Data.DP = [app.Data.DP, mean(DP)]; %Differential Pressure [inches of water]

app.DPTVoltageVEditField.Value = mean( Volts.Board0_Ai0, "all"); - THIS IS WHERE I GET MY ERROR

app.DPTVoltageVEditField.Limits = [-5,5]; - 

Error using MyAirflowapp/RUNButtonPushed2 (line 222)
'Value' must be a double scalar within the range of 'Limits'.

%Voltage to pressure "Inches of water

app.DPTinofH20EditField.Value = DP;

%Coverts average voltage to PSI %Data.PF; Flowing Pressure measured by sentra 280e

PF = mean(Volts.Board0_Ai1, "all") * 5 -0.15;

app.Data.PF = [app.Data.PF, (PF)] ; %records data

app.FlowingPressurePSIEditField.Value = PF;

app.FlowingPressureVoltageVEditField.Value = mean(Volts.Board0_Ai1);

Tf = 70; %Flowing temperature [F] (Place holder value)

% Read temperature at LFE inlet from thermocouple

%Tf = mean(Volts.Board0_Ai2, "all"); %*const+const

app.Data.TF = [app.Data.Tf, Tf];

airFlowRate = (app.B*DP+app.C*DP^2)*(app.Tstd/Tf)*(PF/app.Pstd); %cubic feet

app.Data.LFEMassFlowRate = [app.Data.LFEMassFlowRate, (airFlowRate*0.035)]; %kg/hr

app.MassFlowRateEditField.Value = app.Data.LFEMassFlowRate(end);

plot(app.DPTVoltageGraph, app.Data.Time, app.Data.DPTVoltage);

xlabel(app.DPTVoltageGraph,"Time (s)");

ylabel(app.DPTVoltageGraph,"Voltage (V)");

plot(app.LFEMassFlowRateGraph, app.Data.Time, app.Data.LFEMassFlowRate);

xlabel(app.LFEMassFlowRateGraph,"Time (s)");

ylabel(app.LFEMassFlowRateGraph,"LFEMassFlowRate (kg/h)");

app.PeakAirflowEditField.Value = max(app.Data.LFEMassFlowRate);

app.PeakAirflowEditField.Limits = [-300,300];

app.PeakAirflowEditField.UpperLimitInclusive = app.PeakAirflowEditField.Value;

app.IdleAirflowEditField.Value = min(app.Data.LFEMassFlowRate);

app.IdleAirflowEditField.Limits = [-300,300];

app.IdleAirflowEditField.LowerLimitInclusive = app.IdleAirflowEditField.Value;

end

%Function read data for Loadstar Fuel Measurement system and

%updates

function getFuelMeasurementA(app, Volts)

massDieselA = (mean(Volts.Board0_Ai3, "all"));%*constant;

app.Data.massDieselA = [app.Data.massDesielA , massDieselA];

end

%Function read data for Ian Fuel Measurement system

function getFuelMeasurmentB(app, Volts)

massDiesel = (mean(Volts.Board0_Ai5, "all")*5); %lbs

app.Data.massDieselB = [app.Data.massDieselB , massDiesel];

KgMassDiesel = massDiesel * 0.45359237; %kg

app.DieselLevelBGauge.Value = KgMassDiesel- 5.68;

app.KgDiesel.Value = KgMassDiesel - 5.68;

app.GalDiesel.Value = app.KgDiesel.Value*.311;

%BioDiesel

massBioDiesel = (mean(Volts.Board0_Ai6, "all")*5); %lbs

app.Data.massBiodieselB = [app.Data.massBiodieselB , massBioDiesel];

KgMassBioDiesel = massBioDiesel * 0.45359237; %kg

app.BioDieselLevelBGauge.Value = KgMassBioDiesel - 5.68;

app.KgBioDiesel.Value = KgMassBioDiesel - 5.68;

app.GalBioDiesel.Value = app.KgBioDiesel.Value*.311;

end

end

% Callbacks that handle component events

methods (Access = private)

% Button pushed function: STOPButton

function STOPButtonPushed2(app, event)

app.StopFlag = 1;

end

% Button pushed function: RUNButton

function RUNButtonPushed2(app, event)

app.intialize()

global dq

Tstart = tic;

while app.StopFlag == 0

Volts = read(dq, 500); %reads daq voltages

%Sets data readout from DAQ ports

Time = toc(Tstart)

app.Data.Time = [app.Data.Time, Time];

app.getAirFlow(Volts) - THIS IS LINE 222

app.getFuelMeasurmentB(Volts)

end

app.DAQactiveLamp.Color = app.RED;

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello @isherer.

Which versions of Windows OS, InstaCal, MATLAB, and the 'Data Acquisition Toolbox Support Package for Measurement Computing Hardware' are you using?

The analog input channels should be configured for single-ended or differential mode in InstaCal before launching your MATLAB.

17 hours ago, isherer said:

app.DPTVoltageVEditField.Value = mean( Volts.Board0_Ai0, "all"); - THIS IS WHERE I GET MY ERROR

Insert a breakpoint in your MATLAB script to debug and verify the values.

17 hours ago, isherer said:

'Value' must be a double scalar within the range of 'Limits'.

What is the reported 'Value' between single-ended vs differential mode?

Verify the wiring connections for the set configuration mode.

Regards,

Fausto

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...