HOW CAN I DO A CONTINUOUSLY MATLAB GRAPH AUTO UPDATABLE
Show older comments
I am adquiring data from arduino, froman ultra sonic sensor and from de position of a servo motor , i have two variables i have a huge problem ..well two
first i need to plot in real time, i did it, but i run the program, then it plots, then restarts the program and so the counter in x axis , i have red other old post about this , but ,i just dont get it, i need two graph "current_pos", and "t"
Second after that i need to derive current_pos to get its velocity, and then derive it again to get acceleration , is that even possible? to differentiate or derive an input in order to get another physic analysis?, if so , it would be current_pos, Vel=[diff(current_pos)]; Accel=[diff(Vel)]; -- i did it and didnt worked -- please help i needed for tomorrow morning %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a = arduino ('COM3', 'Uno', 'Libraries',{'Servo','JRodrigoTech/HCSR04'} );
s = servo(a, 'D4')
sensor = addon(a, 'JRodrigoTech/HCSR04', 'D12', 'D8')
clear s;
s = servo(a, 'D4', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', 2300*10^-6)
for i=1:1
writePosition(s,0);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1);
writePosition(s,0.5);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1);
writePosition(s,1);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
t = readTravelTime(sensor)*100;
sprintf('Current distance is %.4f cm\n', 340*t/2)
pause (1); end %%%%%%%%%%%%%%%%555
Answers (0)
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!