Arduino DUE custom servo block (LCT) not working despite no compile errors
2 views (last 30 days)
I'm trying to create my own servo.write block in Simulink for Arduino DUE deployment (and External Mode). Before you ask why if there is one available inside the Support Package, generally my final goal is to create a block that will use Arduino servo.writeMicroseconds function (there is no out of the box block for this one) but first i want to try with something simple to debug to see if i can get it to work....
So, generally I'm using his guide https://www.mathworks.com/matlabcentral/fileexchange/39354-device-drivers and the LCT approach. I based my code on one of the example that is provided there and after making some simple modification (basically renaming functions) code seems to compile without any errors, it deploys to hardware in "Monitor and Tune" mode but thats all that happens. The servo port is simply dead and does not output anything at all. It's like the servo.attach() function is never used and the port is never initialised. Of course if I replace S-Function block with built in "Servo Write" block it all works as expected so hardware is not an issue.
I've triple checked all the names and there are no typos. I made sure to add include directories from the hardware support package directory. I have the "Servo" variable in a scope that should be available for both initialise and output function but no idea where else to look for the cause of this issue.
I'm attaching LCT script, cpp source files used in LCT and the harness model I'm using for the S-Function.
Thank you in advance for help.