Query instrument: initialization with a function

10 ビュー (過去 30 日間)
Mauro Diamantino
Mauro Diamantino 2018 年 8 月 20 日
回答済み: Mauro Diamantino 2018 年 9 月 4 日
Hello, I'm trying to receive data from an Arduino board in Simulink, so I decided to use the block "Query instrument". But I need to initialize the board first, so I built a function (a script but with input and output parameters) where I create a string with some numeric parameters, wait some seconds using the function pause and then the string is sent to the board through the serial port. The pause is necessary because the Arduino board take it a while to be ready to receive serial data. I have configured the "Query instrument" block in such a way that in the initialization it executes the function I wrote. This function works well when I call it from the command window, but I get the following message error when I execute the Simulink model: Undefined function or variable 'initPause(s)'. I have tried to solve it using a function handler but I didn't get a solution. Also, I checked that the current directory was the directory where I saved the function. Why did I receive this error message? The function which is executed in the initialization, does it have to accomplish some rules?

採用された回答

Mauro Diamantino
Mauro Diamantino 2018 年 9 月 4 日
I've already solved the problem! I achieved my aim using the callbacks which can be accesed by File->Model Properties->Model Properties->Callbacks. I used the the PreLoadFcn and InitFcn to initialize the Arduino board.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by