having problem reading data from arduino using instrument toolbox

Hey there well i'm trying to send a constant like 5 to arduino using simulink " to instrument " block and in arduino i have generated a model using "serial recieve" and a "gain" plus a "serial transmit" block and in my laptop i have the "query instrument" block but the thing i get is very weird .

3 Comments

I do not see anything weird? I just see a blank output?
when i run this model it gives some kind of random numbers

Sign in to comment.

 Accepted Answer

I hope that you might have figured out by now. In case you haven't, try this:
The problem here is due to the fact that Arduino is sending the ASCII code and Query Instument is reading the binary values. You can change this at the Query block. Double click to open Block Parameters. Under the Query tab, set the data format as ASCII. You may also the set the ASCII format string as '%d', '%f', or '%s' based on the type of data you are sending.

3 Comments

Yeah i just figured that out but there is another problem with this block. The ehing is it is limited to 4 COM ports only. Using serial recieve and send may resolve that issue but i still have problem sending and recieving data using those blocks. Have you figured out how would that be possible too ?
To confirm, you are trying to send to more than 4 arduino simultaneously in one model ?
Yes as a part of HIL simulation each arduino is going to represent a sensor

Sign in to comment.

More Answers (0)

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Asked:

on 11 Oct 2018

Commented:

on 27 May 2019

Community Treasure Hunt

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

Start Hunting!