Question

Ni MyDAQ
Create a program using matlab to control a DC motor connected to DO port and display real time data of two accelerometer connected to port AI0 and AI1 LIVE. Both the motor and real time data should work simultaneously.
PROJECT C
More detailed description is given in PROJECT C in the file uploaded
Thanks a Lot !!!

5) The shake table should have a platform, which is controlled by the supplied motor to simulate the lateral ground displacemON 2 POWE ฉว 02 I Ser vo Motor Al:0 ALAI:LA: Di:2 (0-5U) 010

5) The shake table should have a platform, which is controlled by the supplied motor to simulate the lateral ground displacement when an earthquake occurs. Your team is required to design a mechanism for transmitting the motor rotations to lateral movements of the platform on the shake table. Moreover, the platform should move like a sinusoidal wave with a constant frequency and an amplitude not less than 2.5cm and its peak acceleration should not be smaller than 500cm/s4 Additional components for building the shake table may be supplied subject to the approval of the tutor. 6) You should use the two accelerometer sensors to monitor the lateral vibrations of the tower at the deck and base, respectively. One figure designed by using MATLAB should be created to keep track of and live display the measured accelerometer traces. In addition, you should display the trace of PI (see Section 3 for the calculating equation), which evaluates the deformation level of your structure. You should convert the accelerometer signals to the unit of cm/s instead of Voltage and need to use appropriate data processing and filtering techniques to process the measured signals.
ON 2 POWE ฉว 02 I Ser vo Motor Al:0 ALAI:LA: Di:2 (0-5U) 010
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The program to control a DC motor connected to DO port and display real time data of two accelerometer connected to port AI0 and AI1 LIVE is as follows :

%User Defined Properties
serialPort = 'COM3'; % define COM port #
plotTitle = 'Serial Data Log'; % plot title
xLabel = 'Elapsed Time (s)'; % x-axis label
yLabel = 'Data'; % y-axis label
plotGrid = 'on'; % 'off' to turn off grid
min = -2010; % set y-min
max = 2010; % set y-max
scrollWidth = 10; % display period in plot, plot entire data log if <= 0
delay = .01; % make sure sample faster than resolution
%Define Function Variables
time = 0;
data_x = 0;
data_y = 0;
data_z = 0;
count = 0;
%Set up Plot
plotGraphx = plot(time,data_x,'-mo',...
'LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',2);
hold on; % it will hold all the lines on same axis
plotGraphy = plot(time,data_y,'-mo',... <---- define data_y before this
'LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',2);
plotGraphz = plot(time,data_z,'-mo',...
'LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',2);
title(plotTitle,'FontSize',25);
xlabel(xLabel,'FontSize',15);
ylabel(yLabel,'FontSize',15);
axis([0 10 min max]);
grid(plotGrid);
%Open Serial COM Port
s = serial(serialPort)
disp('Close Plot to End Session');
fopen(s);
tic
while ( ishandle(plotGraphx) ) %Loop when Plot is Active && ishandle(plotGraphy) && ishandle(plotGraphz)
dat = fscanf(s,['%d,%d,%d']); %Read Data from Serial as Float: PLEASE NOTE: Here i modified the code, in order to adjust the correct format of data in input.
if(~isempty(dat) && isfloat(dat)) %Make sure Data Type is Correct
count = count + 1;
time(count) = toc; %Extract Elapsed Time
data_x(count) = dat(1);
data_y(count) = dat(2);
data_z(count) = dat(3);
%Set Axis according to Scroll Width
if(scrollWidth > 0)
set(plotGraphx,'XData',time(time > time(count)-scrollWidth),'YData',data_x(time > time(count)-scrollWidth));
set(plotGraphy,'XData',time(time > time(count)-scrollWidth),'YData',data_y(time > time(count)-scrollWidth));
set(plotGraphz,'XData',time(time > time(count)-scrollWidth),'YData',data_z(time > time(count)-scrollWidth));
axis([time(count)-scrollWidth time(count) min max]);
else
set(plotGraphx,'XData',time,'YData',data_x);
set(plotGraphy,'XData',time,'YData',data_y);
set(plotGraphz,'XData',time,'YData',data_z);
axis([0 time(count) min max]);
end
%Allow MATLAB to Update Plot
pause(delay);
end
end
%Close Serial COM Port and Delete useless Variables
fclose(s);
clear count dat delay max min plotGraph plotGrid plotTitle s ...
scrollWidth serialPort xLabel yLabel;
disp('Session Terminated...');

Add a comment
Know the answer?
Add Answer to:
Ni MyDAQ Create a program using matlab to control a DC motor connected to DO port and display real time data of two acce...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT