DuckCar_Lab 1

docx

School

Orange Coast College *

*We aren’t endorsed by this school

Course

A180

Subject

Mechanical Engineering

Date

Feb 20, 2024

Type

docx

Pages

9

Uploaded by khangtuonggia

Report
EGME 476A: Dynamic and Control System Laboratory.  Car Model - Lab 1 Deliverable Submitted By:  Khang Tuong Jeremy Estorga Chad Nguyen Due and submitted: 10-6-2023
Deliverable 1: One plot of velocity vs time containing the data for different voltages: Figure 1: Graph results of velocity of 3V, 4V, and 5V inputs.
Deliverable 2: Table contains time constant and DC: Table 1: Table results from the values of the Time constant obtained by two different methods and the value of DC gain Voltage Input (V) Time Constant 1 (s) Time Constant 2 (s) DC Gain ( m s V ) 3 Volt 0.715 0.8426 0.3260 4 Volt 0.720 0.9186 0.3538 5 Volt 0.774 0.9378 0.6781
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Deliverable 3:  Description of the two methods:  Method 1 : Using a log-linear plot to calculate the time constant First, we need to calculate the maximum steady-state velocity by calculating the average of the last 50 data points. Then, calculate data points of the dimensionless velocity φ(t) by using the appropriate formula and data point. After that, we fit the first 15 values of the φ(t) and the time data points by using the “polyfit” function in Matlab to get the slope of this plotted line (slope = 1 τ ). Finally, calculate the time constant by using the appropriate formulation Method 2 : Using the initial slope to calculate the time constant:  First, we fit the first 15 values of the data by using the “polyfit” function in MATLAB to get the initial slope of the data. Then, we calculate the final steady-state velocity of the data by calculating the average of the last 50 data points. Calculate the time constant after obtaining the initial slope and the final velocity by using the appropriate formula.   MATLAB CODE: % Name: Khang Tuong, Chad Nguyen, Jeremy % Plot Voltage 3,4,5 % Deliverable 1 % Import raw data from excel filename1 = '3V.xlsx' ; filename2 = '4V.xlsx' ; filename3 = '5V.xlsx' ; % Convert 3V data to table array data_3V = readtable ( filename1, "VariableNamingRule" , "preserve" ); % Data from 4 voltage t_3volt = table2array (data_3V(1:end,1)); % velocity at 3V v_3volt = table2array(data_3V(1:end,2)); % time at 3V % Convert 4V data to table array
data_4V = readtable ( filename2, "VariableNamingRule" , "preserve" ); % Data from 4 voltage t_4volt = table2array (data_4V(1:end,1)); % velocity v_4volt = table2array(data_4V(1:end,2)); % time % Convert 5V data to table array data_5V = readtable ( filename3, "VariableNamingRule" , "preserve" ); % Data from 4 voltage t_5volt = table2array (data_5V(1:end,1)); % velocity v_5volt = table2array(data_5V(1:end,2)); % time % Plot velocity vs. time for each voltage level figure scatter(t_3volt, v_3volt, 'r' , 'LineWidth' , 1); % 3 Voltage data in red hold on ; scatter(t_4volt, v_4volt, 'g' , 'LineWidth' , 1); % 4 Voltage data in green scatter(t_5volt, v_5volt, 'b' , 'LineWidth' , 1); % 5 Voltage data in blue % Add labels and legend xlabel( 'Time (s)' ); ylabel( 'Velocity (m/s)' ); legend( '3V' , '4V' , '5V' ); %% Deliverable 2 clc % 3 Voltage % Method 1: Using Log-linear plot % Calculate final steady state velocity by taking the average of the last 50 data points vss_3V = mean(v_3volt(end-50:end)); % Filter v to remove values greater than final steady state velocity to % avoid negative value calculating phi v_filt_3 = v_3volt(v_3volt <= vss_3V); % Calculate phi using filtered data to avoid negatives phi_3V = log(abs(vss_3V - v_filt_3)./vss_3V); % Create the set of data includes the first 15 linear data points int_t3V = t_3volt(1:15); int_v3V = phi_3V(1:15); % Linear fit to the set of data to get the slope of the dimensionless % velocity vs time plot for 3V p = polyfit(int_t3V, int_v3V, 1); slope = p(1); % Calculate time constant tau = -1/slope; % Print time constant fprintf( 'The time constant using log-linear method for 3V: %.3f seconds\ n' , tau); % Plot % figure; % plot(int_t3V, int_v3V,'o'); % xlabel('Time (s)'); % ylabel('Phi (m/s)');
% Method 2: Calculate the time constant using the initial slope for 3V datas % Step 1: Create the set of datas for first 5 points when velocity increase % linearly int_t3V = t_3volt(1:5); int_v3V= v_3volt(1:5); % Step 2: Fit set linear datas to get the initial slope initial_slope = polyfit(int_t3V, int_v3V, 1); % Step 3: Get final steady state velocity by calculating the average datas % from the last 50 values final_v3V = mean(v_3volt(end-50:end)); % Calculate time constant use formula: tau = V_final / slope tau = final_v3V / initial_slope(1); % Print result fprintf( 'Time constant from initial slope for 3V: %f\n' , tau); % Find DC gain for 3V % Define parameters ka= 1.2; % V/V Voltage_3 = 3; % Voltage % Find Steady State velocity velss_3V = mean(v_3volt(end-50:end)); % Find Km km_3V = velss_3V / Voltage_3; % Find DC gain at 3V DC_gain_3V = ka*km_3V; % Print result fprintf( 'DC gain at 3V : %f\n' , DC_gain_3V); fprintf( '\n' );
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help