Jump to content
OMRON Forums

Add .cpp file to realtime routines


maartenvervelde

Recommended Posts

Hi,

 

I have a servo loop in which I use S functions. S Functions from C files are no problem, because you can include the .c and .h file in the realtime routines folder.

Now I have a .cpp file in which I have code. I made a function in the file which is extern "C" so it could be called from the C code of the servo loop. But the problem I have now, is that I can't add the .cpp file to the folder. Is there a way to include the code from cpp file, because the compiler in the ide is a GNU C/C++ crosscompiler and I would suspect it would be possible to compile it?

 

Maarten

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

The “Realtime Routines” folder can have only one “.c” file. You add routines to this file through the IDE. See the section in the IDE manual under “ASSOCIATING MOTORS WITH USER-WRITTEN SERVO AND PHASE ALGORITHMS” starting on page 213 (219 electronic). Basically you will add the code you have in your “.cpp” files to your newly added routines.

"http://forums.deltatau.com/filedepot/download.php?f=Power PMAC/Manuals/Power PMAC IDE.pdf"

Link to comment
Share on other sites

The “Realtime Routines” folder can have only one “.c” file. You add routines to this file through the IDE. See the section in the IDE manual under “ASSOCIATING MOTORS WITH USER-WRITTEN SERVO AND PHASE ALGORITHMS” starting on page 213 (219 electronic). Basically you will add the code you have in your “.cpp” files to your newly added routines.

"http://forums.deltatau.com/filedepot/download.php?f=Power PMAC/Manuals/Power PMAC IDE.pdf"

 

I already have a working user servo algorithm, but the problem is that I want to use S-Functions created from C++ in the servo algorithm. I have done it with C code, and you need to add the C file and the header file to the realtime routines. Is there a different way to use C++ S functions that are not fully inlined?

Link to comment
Share on other sites

Within the IDE, we only support C code across the board, but you can compile c++ code outside of the IDE for the background C Programs. The user servo algorithms are strictly C, since they are running in kernel space so you can not use c++ for the servo algorithms. we also use Matlab and embedded coder to generate c files for custom servo algorithms. Can you generate c instead of c++?
Link to comment
Share on other sites

Within the IDE, we only support C code across the board, but you can compile c++ code outside of the IDE for the background C Programs. The user servo algorithms are strictly C, since they are running in kernel space so you can not use c++ for the servo algorithms. we also use Matlab and embedded coder to generate c files for custom servo algorithms. Can you generate c instead of c++?

 

I have a servo loop in C code, and I have it working. The problem is the S Functions. We already have a lot of code written in C++ which we want to implement in the model. In the generated code the are called as functions which they get from the .c file and the .h file I added to the realtime routine folder.

 

What you're saying is that you cant use c++ functions in that way?

Link to comment
Share on other sites

  • 2 weeks later...

What you're saying is that you cant use c++ functions in that way?

 

This is a bit confusing because C++ is a superset of C. Does your existing c++ code make use of a lot of "C++ ONLY" features such as objects/classes and function/operator overloading, passing by reference, etc? If so then you will have to port it to straight C.

Link to comment
Share on other sites

This is a bit confusing because C++ is a superset of C. Does your existing c++ code make use of a lot of "C++ ONLY" features such as objects/classes and function/operator overloading, passing by reference, etc? If so then you will have to port it to straight C.

 

The file I was trying it with was using a class in which almost everything happend so I have to rewrite it to C. I just made a struct with all the variables the class had and passed a pointer to that to al the functions so they could use the variables and change them, and the changes would be also changed within the other functions.

 

In the S function I put the struct pointer in a PWork vector to use it between the update and the output function and so I could save it between steps.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...