Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using CfromScript() - Calling C Functions from the PMAC Script Language
#1
Attached is a new document describing how to use CfromScript() in Power PMAC, which is a function that permits users to call C functions directly from PMAC Script programs, such as PLCs and Kinematics Subroutines.

CfromScript() can be used for general purpose calculations, but CfromScript() is useful primarily for performing kinematics calculations, because to perform these calculations in a compiled C program is significantly faster than to calculate them using the interpreted PMAC Script kinematics subroutines. This is especially useful for highly nonlinear, computationally-intensive calculations, such as that which occurs in Hexapod or Delta Robot kinematics. Another advantage is that with CfromScript(), the user can more easily implement common C-based nonlinear iterative solvers, such as those given in the famous Numerical Recipes in C cookbook.

If you have any questions on the usage or implementation of this function, please feel free to post them.


Attached Files
.pdf   Using CfromScript in Power PMAC.pdf (Size: 268.01 KB / Downloads: 315)
Reply
#2
I know what's the meaning of the L,C and D datas.The documens tells us that:
//#define KinPosMotor1 L1
//#define KinPosMotor2 L2
//#define KinPosAxisX C6
//#define KinPosAxisY C7
//#define KinAxisUsed D0
But what is the meaning of R data,especially in CfromScript,and how to use it?

Thanks
Reply
#3
R variables, according to page 6 of the Power PMAC Computational Features manual, are:

"Stack/return (“R”) variables: local user variables for passing and returning arguments to subroutines and subprograms; equivalent to differently numbered L-variables."

You will not actually need R-Variables for your kinematics subroutines in CfromScript since you can just use whatever variables the C programming language offers for passing parameters between functions. You probably will not need to access these in CfromScript, since they are normally only used in Script-based subprograms and subroutines, but we permit access to R-Variables in C just in case you do need it.
Reply
#4
Charles,

I was hoping you could provide a small example of how to implement C functions in the realtime routine for specifically kinematics. Does the C application need to be called in the realtime PLC to use with kinematics? I have a two motor kinematic equation (motor 1-X and motor 2-Y) that has a fairly simple equation. We are hoping to see the performance gains of moving the kinematic calculations to the C realtime routines.

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)