% Measure three channels in the student wind tunnel over a bunch of speeds % % We assume that channel 0 is the pitot tube pressure transducer, which % outputs a voltage from 1-5 volts, corresonding to 0-1" H20. This channel % is used to accurately compute the speed from the Pitot tube. % % channels 1 and 2 are called "hot wire" and "strain gage", but could be % any channel that outputs a voltaqe between -10 and 10 % % Kenny Breuer, Feb 2020 % %% Set parameters for experiment Nspeed = 1; % Number of speeds to loop through Npts = 50000; % Total number of points on each channel to measure DigRate = 1000; % Digitizing rate, in Hz NI_DEV = 'Dev3'; % Name of the NI-DAQ box attached to the computer D = 1.5e-3%12.7e-3; % %2.38e-3; %Diameter %% Dont change stuff here on down % Add path for temperature and pressure c0odes addpath 'C:\Users\Public\Documents\ENGN0810'; % Set up the NI-DAQ s = daq.createSession('ni'); s.NumberOfScans = Npts; s.Rate = DigRate; Re = zeros(Nspeed); ideal_freq = zeros(Nspeed); addAnalogInputChannel(s, NI_DEV, 'ai0', 'Voltage'); % Pitot Tube voltage addAnalogInputChannel(s, NI_DEV, 'ai1', 'Voltage'); % Hot Wire addAnalogInputChannel(s, NI_DEV, 'ai2', 'Voltage'); % Strain gage % Time array time = (1/(s.Rate))*(1:Npts); % Measure temperature and pressure disp('Measuring Temperature and Pressure') Temperature = WindTunnelTemperature; % Temp in Kelvin Pressure = WindTunnelPressure; % Pressure in Pa Density = 1000*Pressure /((273 + Temperature) * 287); Visc = 1.458*10^-6*(Temperature+273)^(3/2)/(Temperature+110.4+273); fprintf('Temp: %6.2f [C]; Pressure: %6.3f [kPa], Density: %5.3f [kg/m^3]\n', ... Temperature, Pressure, Density); fprintf('Each speed will take approx %d seconds\n', round(Npts/DigRate)); % Zero out the arrays freq = zeros(1,Nspeed); ch1_ave = zeros(1,Nspeed); ch1_std = zeros(1,Nspeed); ch2_ave = zeros(1,Nspeed); ch2_std = zeros(1,Nspeed); ch3_ave = zeros(1,Nspeed); ch3_std = zeros(1,Nspeed); vel = zeros(1,Nspeed); pitot = zeros(Npts, Nspeed); hotwire = zeros(Npts, Nspeed); strain = zeros(Npts, Nspeed); clear spec1 spec2; % Loop through the speeds for ispeed = 1:Nspeed, fprintf('Set wind tunnel to speed: %d/%d: ', ispeed, Nspeed); Pitot_Pressure = input('Enter Pitot Tube pressure [in-H20]: ' ); freq(ispeed) = input('Enter motor frequency [Hz]: ' ); vel(ispeed) = sqrt(2*248.84*Pitot_Pressure/Density); fprintf(' Estimated Velocity [from visual reading of DP]: %6.3f m/s\n', vel(ispeed)) % Measure ADC data = startForeground(s); % This will measure from the Phidget strain gage % [t,data] = Phidget_Bridge(Npts); ch1_ave(ispeed) = mean(data(:,1)); ch1_std(ispeed) = std(data(:,1)); ch2_ave(ispeed) = mean(data(:,2)); ch2_std(ispeed) = std(data(:,2)); ch3_ave(ispeed) = mean(data(:,3)); ch3_std(ispeed) = std(data(:,3)); % Update the speed based on the accurate measure from the Pitot tube Pitot_Pressure = (ch1_ave(ispeed) - 1)/4; % in-H20 vel(ispeed) = sqrt(2*248.84*Pitot_Pressure/Density); fprintf(' True speed (from Pitot tube reading): %6.3f m/s\n', vel(ispeed)); fprintf(' Pitot tube: %6.3f +/-%5.3f [V]\n', ch1_ave(ispeed), ch1_std(ispeed)); fprintf(' Hot Wire: %6.3f +/-%5.3f [V]\n', ch2_ave(ispeed), ch2_std(ispeed)); fprintf(' Strain gage: %6.3f +/-%5.3f [V]\n', ch3_ave(ispeed), ch3_std(ispeed)); figure subplot(2,1,1) plot(time,detrend(data(:,2:3))) xlabel('Time [sec]') ylabel('Hot Wire Voltage [Volts]') legend('Hot Wire', 'Strain Gage') % seg = 500 gives 2 Hz resolution % seg = 1000 gives 1 Hz resolution seg = 1000; % Length of FFT - at 1000 Hz fs = 1/(time(2)-time(1)); [pxx f] = pwelch(detrend(data(:,2:3)), seg, seg/2, seg, fs); subplot(2,1,2) plot(f,10*log10(pxx)) xlabel('Frequency, [Hz]') ylabel('Power [dB]') legend('Hot Wire', 'Strain Gage') % Save the data and the spectra spec1(:,ispeed) = pxx(:,1); spec2(:,ispeed) = pxx(:,2); pitot(:,ispeed) = data(:,1)'; hotwire(:,ispeed) = data(:,2)'; strain(:,ispeed) = data(:,3)'; Re(ispeed) = Density*vel(ispeed)*D/Visc; ReTest(ispeed) = Density*(0.256+0.304*freq(ispeed))*D/Visc; ReTestSting(ispeed) = Density*(0.256+0.304*freq(ispeed))*1.27e-2/Visc; ideal_freq(ispeed) = (.212*Re(ispeed)-4.5)*Visc/Density/D^2; ideal_freqTest(ispeed) = (.212*ReTest(ispeed)-4.5)*Visc/Density/D^2; ideal_freqTestSting(ispeed) = (.212*ReTest(ispeed)-4.5)*Visc/Density/1.27e-2^2; fprintf('Reynolds Number = %f\n ; Re Sting = %f\n',ReTest(ispeed),ReTestSting(ispeed)) fprintf('Ideal frequency (Pitot Value) = %f, Ideal frequency (Approximate) = %f\n',ideal_freq(ispeed),ideal_freqTest(ispeed)) fprintf('Approx low Freq ideal = %f \n',ideal_freqTestSting(ispeed)) end %% Plot the average and rms vs speed % figure % subplot(3,2,1) % plot(vel, ch1_ave, 'o') % xlabel('Speed [m/s]') % ylabel('Pitot Tube [V]') % % subplot(3,2,2) % plot(vel, ch1_std, 'o') % xlabel('Speed [m/s]') % ylabel('Pitot Tube RMS [V]') % % subplot(3,2,3) % plot(vel,ch2_ave, 'o') % xlabel('Speed [m/s]') % ylabel('Hot Wire Voltage [V]') % % subplot(3,2,4) % plot(vel,ch2_std, 'o') % xlabel('Speed [m/s]') % ylabel('Hot Wire RMS [V]') % % subplot(3,2,5) % plot(vel,ch3_ave, 'o') % xlabel('Speed [m/s]') % ylabel('Strain gage Voltage [V]') % % subplot(3,2,6) % plot(vel,ch3_std, 'o') % xlabel('Speed [m/s]') % ylabel('Strain gage RMS [V]') %% reset the DAQ daqreset