Test a multibody wind turbine model.
Passes RotorAssemblyData.mat to the RHSRobotInitialize function. ------------------------------------------------------------------------ See also Plot2D, RK4, AngleEncoder, DToA, Motor, Wind ------------------------------------------------------------------------
Contents
%------------------------------------------------------------------------------- % Copyright (c) 1999, 2008, 2021 Princeton Satellite Systems, Inc. % All rights reserved. %-------------------------------------------------------------------------------
Motor constants
motor = struct; motor.kT = 0.01; motor.r = 1; motor.kG = 1; motor.vMax = 5; motor.iMax = 1; motor.iMin = -1;
Angle encoder constants
angleEncoderBits = 2048;
Simulation Constants
tEnd = 10;
nTest = 4;
dT = 0.025;
nSim = tEnd/dT+1;
tPulse = 0.1;
nPulse = tPulse/dT;
xI = [0 -100 0 0 0 0 5.296964 0 0 5.296964 5.296964 5.296964]'; % Rotation, should also drop. Then run with lift on but no drag
motorDoublet = 128*ones(1,nSim);
motorDoublet( 1:nPulse ) = 256;
motorDoublet((nPulse+1):2*nPulse) = 0;
Initialization of data structure using stored data
h = RHSRobotInitialize('fname','RotorAssemblyData.mat'); h.jointFun = '';
Define wind velocity
wind = [5;0;0];
Store wind velocity in data structure h
h.windVel = wind; h.forceData = [];
Plot labels
yLabel = {'theta1 (rad)' 'lambda2' 'theta2 (rad)' 'theta3 (rad)'... 'theta4 (rad)' 'theta5 (rad)' ... 'omega1 (rad/s)' 'lambda2Dot ' 'omega2 (rad/s)' 'omega3 (rad/s)' ... 'omega4 (rad/s)' 'omega5 (rad/s)'... 'encoder 1' 'encoder 2' 'encoder 3' 'encoder 4'... 'motor word 1' 'motor word 2' 'motor word 3' 'motor word 4'... 'motor voltage 1' 'motor voltage 2' 'motor voltage 3' 'motor voltage 4'... 'motor torque 1' 'motor torque 2' 'motor torque 3' 'motor torque 4 '};
Simulation
for j = 1:nTest % Initialization x = xI; xPlot = zeros(28,nSim); c = [128;128;128;128]; e = [0;0;0;0]; t = 0; for k = 1:nSim if( j > 1 ) c(j-1) = motorDoublet(k); end % Convert digital words to voltages v = DToA( c, 256, 2.5, -2.5 ); % Input voltages to the motors u = DCMotor( v, x([8 10 11 12]), motor ); % Plotting array xPlot(:,k) = [x;e;c;v;u]; % Update control in data structure h h.u = u; % Enter the motor torques into the dynamics model x = RK4( @RHSRobot, x, dT, t, h ); t = t + dT; % Angle encoder e = AngleEncoder( x(3:6), angleEncoderBits ); end t = dT*(0:(nSim-1)); Plot2D( t, xPlot( 1: 6,:), 'Time (sec)', yLabel( 1: 6), 'Rotor Assembly Position and Angle' ); Plot2D( t, xPlot( 7:12,:), 'Time (sec)', yLabel( 7:12), 'Rotor Assembly Rate' ); Plot2D( t, xPlot(13:16,:), 'Time (sec)', yLabel(13:16), 'Rotor Assembly Encoders' ); Plot2D( t, xPlot(17:20,:), 'Time (sec)', yLabel(17:20), 'Motor Words' ); Plot2D( t, xPlot(21:24,:), 'Time (sec)', yLabel(21:24), 'Motor Voltages' ); Plot2D( t, xPlot(25:28,:), 'Time (sec)', yLabel(25:28), 'Motor Torques' ); end %-------------------------------------- % $Date$ % $Id: bd634c5de62d9b481e267eb714385bdaf422bc81 $