I have a simulink model where I want to use an ultrasonic sensor for feedback in my control loop. I tried using only simulink blocks found here: http://www.mathworks.com/matlabcentral/fileexchange/35639
. However, it turns out that changing the pin mode from an output to an input is not supported at this time. So my next approach was to use a Matlab function block and encode the logic for the sensor there. I downloaded the support package found here: http://www.mathworks.com/academia/arduino-software/arduino-matlab.html
and I tried converting the C code for the ultrasonic sensor found here: http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor
into Matlab code using the provided functions. My code works fine as a standalone M script with the server program running on the Arduino. However when I use it as a function in Simulink, it no longer works. I get errors such as the delete function not working because destructors are not supported by the code generator. Does anyone have an arduino.m file I can use that is compatible with the simulink code generator? Thank you.