Borrar filtros
Borrar filtros

How can i set the sampling rate for Arduino analogRead in matlab code?

3 visualizaciones (últimos 30 días)
Soo Chong
Soo Chong el 15 de Mayo de 2017
Respondida: Sadam Hussain el 10 de Ag. de 2018
I want to use current sensor ACS712 to read the real time value for of 50Hz line current with the following code I found on the internet, but it not given the real-time signal. How can I set the sampling rate?
if true
% code
end
a = arduino(); % Create a figure window to monitor the live data
tmax = 10; % Total time for data collection in seconds
figure(1),
grid on,
xlabel ('Time (s)'), ylabel('Voltage');
axis([0 tmax -2.5 2.5]); % set initial index value, starting value
k = 0; %index
v = 0; %voltage
t = 0; %time
tic % Start timer
while toc <= tmax
k = k + 1;
v(k) = readVoltage(a,'A0')-1.47; %maximum value=3.935
t(k) = toc;
% Now plot the data
if k > 1
line([t(k-1) t(k)],[v(k-1) v(k)]);
drawnow;
end
end

Respuestas (1)

Sadam Hussain
Sadam Hussain el 10 de Ag. de 2018
Hello, friend, I have the same problem I can not get accurate data did you get correct once

Categorías

Más información sobre Arduino Hardware en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by