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 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