Real-Time Data Acquisition from Arduino using Simulink
조회 수: 14 (최근 30일)
이전 댓글 표시
Hi All,
I am writing my question here after many attempts to solve the problem by myself and after being confused by the very fragmented information found on the web about the following subject.
First of all, I run the "Matlab R2012a", I also have (where relevant): "Arduino IO Library" and "Target for Use with Arduino" Simulink libraries.
- My aim is to acquire analog data from a Arduino board (analog input A0), plot them in real time and also write them into a file for post processing. *
In order to create an analog input, I created the simple hardware configuration in Fig.1
Voltage (5Volts) is provided to a variable potentiometer and the pin in the middle provide a voltage (analog) that is directed into the analog input of the Arduino UNO board. The connections are fine as checked with a voltmeter and also read through the Arduino Serial Monitor (0 - 1023). Finally a LED is connected to the digital (PWM) output 9.
The following model is then downloaded on the Arduino board using the "Run on Target" function in Simulink
The hardware response is as expected: as the potentiometer lever is turned the LED lights up, from zero to max light intensity.
With the Arduino running, a second model is created in Simulink and run (at the same time the potentiometer is turned) but as shown in the picture an error is given.
Can anyone suggest a way of achieving my goal ?
Thanks in advance
G
댓글 수: 0
답변 (2개)
Brody
2014년 4월 2일
Which mode are you running in? External or normal? I think you need to run in external mode to get realtime data, but I don't think that's supported on the Uno (or Nano, probably not enough memory).
I'm trying to do the same thing, and I spoke to a Mathworks FAE who suggested [Analog Pin] > [Convert] > [Serial TX] for the target and a separate model with Serial RX (if you have it, needs Instrument Control toolbox I think) or serial read in MATLAB.
Anyway for your attempt wouldn't running your second model overwrite the first one? Also if you're using multiple Analog Read blocks, the description mentions that you can't have multiple blocks set to the same input.
ercan duzgun
2014년 4월 28일
Dear Giuseppe,
Have you succeed to do this Simulink model? I also want to use Arduino for Real time applications. Your example is good and simple for the first step, but it doesn't work. It gives error like yours. Have you found something out, if so could you share?
Ercan
댓글 수: 2
Tobias Flores-Wentz
2015년 7월 28일
I tried to use scope with this example and I was wondering if someone knows of a more effective method of data logging from the analog input.
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!