Send a float number to Arduino Target (Serial Receive) using Serial Send (instrument control toolbox)
이전 댓글 표시
Hi, I'm trying to use the Arduino UNO as Hardware In the Loop. I am stuck because I cannot find a way to send a float single precision number via Serial Send block (from Instrument control toolbox), with the arduino target receiving it with Serial Receive (from Arduino Target library).. After that I will need to send a float back from the target to the simulink, (always using serial communication), but that seems a bit easier.
One more thing: the Serial Receive from Arduino Target gives as an output, a int16, but only the 8LSB contain informations, I don't know why (and the Serial Send block from the Arduino Target expects an UINT8, just like it is meant to be!)
I am using Matlab 2011b, and the arduino target library compatible with the IDE 0022, which I have regularly installed. The newest Arduino Target Library, compatible with IDE 1.0 and Matlab 2012a does not work
답변 (1개)
Gautam Vallabha
2012년 4월 9일
0 개 추천
For sending data from MATLAB to Arduino, take a look at the "To Instrument" block (in Instrument Control Toolbox). The "Send" tab in the block mask allows you to send 32-bit or 64-bit floats. This blog entry describes a similar approach.
> The newest Arduino Target Library, compatible with IDE 1.0 and Matlab 2012a does not work.
Can you elaborate? What problem are you having with this?
댓글 수: 7
Massimiliano Curzi
2012년 4월 22일
Massimiliano Curzi
2012년 4월 22일
Vedant
2012년 5월 7일
Hello, even i have similar problem. I am trying to send floating point data(like 130.5 )from Serial Send block (of Matlab) but in arduino the servo.read and servo.write does not accept floating values??
Did u find a way?
Walter Roberson
2012년 5월 7일
Massimiliano, is there a reason not to upgrade to R2012a so you can use the new utilities?
Massimiliano Curzi
2012년 5월 14일
Walter Roberson
2012년 5월 14일
In MATLAB it would be
typecast(The4Chars,'float')
In Simulink I suspect it would be messy to do without calling upon MATLAB.
Walter Roberson
2012년 5월 15일
Possibly Shankar's response will help:
http://www.mathworks.com/matlabcentral/answers/35270-s-function-for-reading-com-port
카테고리
도움말 센터 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!