MATLAB Answers

How to compile .tlc to .mexw64 or obtain source .c file

11 views (last 30 days)
Matthieu Capuano
Matthieu Capuano on 24 Mar 2017
Commented: Matthieu Capuano on 24 Mar 2017
After recently switching to the Pixhawk PSP for R2016a I had to make a change to the disarmed servo output of the PWM_output block. I changed the default output in the sfun_px4_pwm.tlc file from 900 microseconds PWM to 1500 microseconds because my servos have a range of 1000 - 2000 and I need them to stay at 90 degrees when disarmed. However, I am now getting an Invalid MEX-file error. I'm not very familiar with .tlcs and .mexw64s but I understand that the mex file is a compiled c file into a MATLAB executable format. I installed MS Visual C++ and support for MinGW-w64 to be able to compile files into this format but apparently cannot do it from the .tlc.
Is there any way to compile this edited .tlc file into a .mexw64 file? Or do I need the original sfun_px4_pwm.c? In which case, where can I get it if at all possible?
NOTE: Clearly it makes more sense to edit the .c file directly since (I think) the .tlc is just some sort of wrapper for the .c. But I could not find it, so I went ahead and modified the .tlc instead. This is the project I'm assisting with:

Answers (1)

Karthik S S
Karthik S S on 24 Mar 2017
The .tlc file is just a template for the created mex file and s-function. It is used for code generation of the s-function you have created from mex file. So editing a .tlc file is not suggested. You will have to make any changes directly to the c file and then create the subsequent mex file, s-function and .tlc file for the new .c code.
  1 Comment
Matthieu Capuano
Matthieu Capuano on 24 Mar 2017
Okay, so then I need to obtain the source sfun_px4_pwm.c file. How can I go about doing that? The PSP Installation only came with the .tlc and .mex files.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!