Timer to sample real-time input.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am using Simulink to make a model of some sort that is interfaced with an Arduino Uno. The part where I need help in involves a sensor reading that is being stored on startup for purpose of calculating the offset. So I have a MATLAB Function block that does so, the code inside is as follows:
function y = fcn(u)
u_calc = 0;
for i = 1:10
u_calc = u_calc + u;
pause('0.1');
end
u_calc = u_calc/10;
y = u-u_calc;
Now to have ensure that there is a different sample on each loop, typically using the Arduino IDE I will just use a delay() function that has value higher than the sensor sample time - let's say it is 0.1 sec. Now making the code in this manner resulted in a problem where the whole model paused, I attached a display to the input and it shows nothing until (0.1*10) sec has elapsed. Is the offeset calculated right? or is the approach I used to simulate a delay() or for sampleing is wrong?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Arduino Hardware in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!