I'm working on using Phidgets to drive an experimental winching devise for a research project and I'm aiming at using Matlab/ Simulink to drive this system. So far I have successfully setup matlab scripts to open the phidgets and a simulink model to read and drive the phidgets using embedded matlab and "extrinsic" function calls to use matlab to access the phidgets.
The problem I face is I would like to impliment the system in real time and this requires the use of real time workshop for Simulink which does not allow external matlab function calls. So I believe the solution is to write a C-mex S-function to call the C routines directly. Has anyone done this before? I have tried searching the internet for information with no luck. I have little experience writing S-functions but am learning. So far I'm stuck trying to compile the c-mex file with the phidget21.h header that does nothing but pass the input through to the output. I get a long list of "error-unrecognized declaration" starting at line 168 of the header file.
Edit "In particular the mex compiler doesn't like '__declspec (dllimport)', this I guess is the first problem to overcome."
Further edit: "After doing some more investigation I believe the compiler is the problem. The default one used by the matlab function mex is Lcc -win 32. They also support Open Watcom C/C++, all the other supported compilers are beyond my means. Is there a work around to use the Lcc -win32 compiler with the existing C code? Would I have more success setting up Open Watcom and using that?"
Thanks for any help.