Query instrument: initialization with a function

10 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by