Matlab GUI

2 vues (au cours des 30 derniers jours)
Tee
Tee le 6 Avr 2011
Commenté : Brayan Reyes le 21 Nov 2017
I have some question on obtain data from arduino which connect to optical encoder. I have using following code to obtain data from Arduino
function encoder1pushbutton9_Callback(hObject, eventdata, handles)
handles.a.pinMode(2,'input');
handles.a.digitalRead(2)
numberOfDatas = 200;
data = zeros(1, numberOfDatas);
i = 1;
% Main graph figure
figure(1);
hold on;
title('Incomming Data from External Device');
xlabel('Data Number');
ylabel(' output (0-1)');
for i=1:numberOfDatas
% Get the data from the serial object
data(i) = handles.a.digitalRead(2);
% Plot the data
figure(1);
plot(i, data(i), 'm*');
drawnow;
end
Did i have to set the Baudrate, databits and stopbits to acquire data from arduino???

Réponses (2)

Walter Roberson
Walter Roberson le 6 Avr 2011
Everyone else that I have seen discussing the Arduino has been using the serial port to do the reading, not digital I/O. How exactly is your Arduino connected to the system you are running Matlab on?
  3 commentaires
Walter Roberson
Walter Roberson le 6 Avr 2011
Perhaps this File Exchange Contribution demonstrating communications and control will help:
http://www.mathworks.com/matlabcentral/fileexchange/27843-arduino-io-package-slides-and-examples
Tee
Tee le 6 Avr 2011
Another question, the code i write only collect data ,for example 200 data,got any code can i write to know how many data transfer in 1 second?

Connectez-vous pour commenter.


Tee
Tee le 6 Avr 2011
I using digital I/O to control my motor through Matlab GUI, therefore i using digital I/O to acquire data from Arduino
  1 commentaire
Brayan Reyes
Brayan Reyes le 21 Nov 2017
How was it?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Acquisition Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by