Jump to content
OMRON Forums

Problem using CfromScript


Recommended Posts

As a total newbie on PMAC I have some troubles download and using CfromScript in an inverse kinematic calculation. I have put "UserAlgo.CFunc=1" in my global includes but it refuses to set it (it is stills zero when inspected in the IDE).


There is a variable, UserAlgo.CFuncStatus which is -1 in my case, but I cant find any documentation what this means.


I have tried various combinations of "Build and download all programs", "Build an download realtime Routines" etc. , the compiler does not complain on my code.


If I write a simple forward/inverse kinematic in PMAC script, it works, but if I do the equivalent functions in CfromScript, it does not work (no movement in any my motors). Any clues on what my problem could be??

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

If UserAlgo.CFunc returns zero, this would indicate you have not actually compiled the CfromScript program - check the build output. Verify that you have set the "Build Action" properties for "Compile".



I can still not get it to work. I have:

1) Set UserAlgo.CFunc=1 first thing in global includes

2) Have EXPORT_SYMBOL(CfromScript); in usrcode.h

3) Set build action to "Compile" for usrcode.c (and two other c files used in my calculations), Build action is 'content' for the c header files.

4) Verified that the build output from "Build and download realtime routines" contains no errors. (Se attached file for build log)

5) Directly after "Build an download realtime routines" or "Build and download all programs", typing "UserAlgo.CFunc" in the IDE console answers "0". If I manually do "UserAlgo.CFunc=1" in the console it refuses to change. Does UserAlgo.CFuncStatus=-1 mean anything???



For reference, my entry function in usrcode.c looks like this:



double CfromScript(

double CS_Number_double,

double State_double,

double KinematicsType_double,double arg4,double arg5,double arg6,double arg7,

struct LocalData *Ldata) {



int CS_Number = (int)CS_Number_double;

int State = (int)State_double;

int KinematicsType = (int)KinematicsType_double;

int ErrCode = 0; // 0= no error


switch(State) {

case Forward_Kinematics_State: {

ErrCode = ForwardKinematics(CS_Number,Ldata);



case Inverse_Kinematics_State: {

ErrCode = InverseKinematics(CS_Number,Ldata);



default: {

ErrCode = -11; // Invalid State Entered





return (double)ErrCode;



Link to comment
Share on other sites

The "Warnings" are preventing the building of the code. The IDE is incorrectly reporting "Download Successful". Remove the unused declarations - it should compile OK then.


This was the problem. Many thanks!

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...