Query instrument: initialization with a function

10 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Mauro Diamantino
Mauro Diamantino il 4 Set 2018
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.

Più risposte (0)

Categorie

Scopri di più su Arduino Hardware in Help Center e File Exchange

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by