Real-Time Data Acquisition from Arduino using Simulink

조회 수: 17 (최근 30일)
Giuseppe Naselli
Giuseppe Naselli 2014년 1월 2일
댓글: Tobias Flores-Wentz 2015년 7월 28일
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

답변 (2개)

Brody
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.
  댓글 수: 1
Giuseppe Naselli
Giuseppe Naselli 2014년 4월 2일
Hi Brody,
thanks for your answer.
Regarding your question " Anyway for your attempt wouldn't running your second model overwrite the first one? "
I see your point and I think you are right.
Does the solution provided by the Mathworks FAE work?
If so would you like to share a screen shot of your model?
G

댓글을 달려면 로그인하십시오.


ercan duzgun
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
Giuseppe Naselli
Giuseppe Naselli 2014년 4월 30일
Hi Ercan,
sorry I have not solved the problem so took a complete different approach by using the Arduino language in order to achieve my goal and put on side Simulink (it was not worth for me to loose more time on that when I could achieve my goal differently :)
G
Tobias Flores-Wentz
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 CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by