alejandrojginerd Posted April 12 Posted April 12 we are developing a State machine that will be runing on the Servo loop thread to take advantage of the real time characteristics and the Matlab Code generation. The State machine we thinking of ttriggering other programs like motion programns with the Command() call. However, we are not able to include the Command() fucntion into owr C code. the following example shows the problems we are facing: double user_pid_ctrl( struct MotorData *Mptr) { if (!Mptr->ClosedLoop) return 0; if (pshm->P[1] == 1){ Send(0,"Move Up"); Command("&2 b MoveUp r"); pshm->P[1] = 0; } return 0; } C:\Users\aleja\Documents\Universidad\KEIO\Research\PMAC\NewModule\PowerPMAC1\C Language\Realtime Routines\usrcode.c(126,0): error : implicit declaration of function 'Command' [-Werror=implicit-function-declaration] it seems the gplib.h was not loaded so we tried to forceload it with a #inlcude <gplib.h> \usr\local\dtlibs\libppmac\gplib.h(18,0): error : stdlib.h we did the same for stdlib.h this time (#inlcude <stdlib.h>) C:\Users\aleja\Documents\Universidad\KEIO\Research\PMAC\NewModule\PowerPMAC1\C Language\Realtime Routines\usrcode.c(40,0): error : stdlib.h Is it possible to use Command inside a UserServo fucntion? If it is, how to do it? if not, what could achieve a similar outcome? Quote
leandro.martins Posted April 12 Posted April 12 The best thing would be consult the PowerPMAC C Help documentation It is attached into this another topic Probably this is the function that you are looking for //----------------------------------------------------------------------------------------------- /// Sends a command to the Pmac Command Processor /// /// Previous modal commands will be retained /// The input string is converted from symbolic to PMAC compatible commands and variables /// \param[in] *pinstr - ptr to PMAC input string /// \return 0 == OK, - == error number int Command (char *pinstr); or //----------------------------------------------------------------------------------------------- /// Sends a command to the Pmac Command Processor /// /// Previous modal commands aren't retained, thus the function is Thread Safe /// The input string is converted from symbolic to PMAC compatible commands and variables /// \param[in] *pinstr - ptr to PMAC input string /// \return 0 == OK, - == error number int CommandTS (char *pinstr); Quote
alejandrojginerd Posted April 13 Author Posted April 13 I have already checked the C API documentation but it does not seem to have any information on the issue. I know now that the library is loaded as Send() is also part of gplib.h according to the documentation. Additionally, when the Command() is commented out, the app builds without any issue. double user_pid_ctrl( struct MotorData *Mptr) { if (!Mptr->ClosedLoop) return 0; if (pshm->P[1] == 1){ Send(0,"Move Up"); // CommandTS("&2 b MoveUp r"); pshm->P[1] = 0; } return 0; } I also know that the function itself exists within the library and works as intended on BgCPLC void user_plcc() { if(pshm->P[1] == 1){ Command("&2 b MoveUp r"); pshm->P[1] = 0; } } Given that Matlab code generation only generates code for a UserServo fucntion and that we want a hard real time behaviour, we would like to be able to call the Motion Programs within this UserServo fucntion and not a BgCPLC. Do you have any idea on how to call motion programs within a UserServo rutine or automatically generate C code for BgCPLC. Quote
leandro.martins Posted April 15 Posted April 15 I have found this disclaimer at the header of the gplib.h: /// \file gplib.h /// /// These functions are for use as an API for linux "C" APPs. /// \warning They are NOT available to user written real time "C" PLCs. Therefore, it looks that it's not possible to use the Command() in the Realtime Routines. I couldn't find anything with the same function of the online command "run" in the rtpmacapi. There is a function for cheching the CS status though. //------------------------------------------------------------- /// Returns enum of Coord Program Status /// /// \param[in] num - number /// \return enum progstatus enum progstatus CoordStatus(int num); My impression is that the C code generation is intended only for control loops purposes, not general logic. Sorry for not being able to help more. Quote
steve.milici Posted April 15 Posted April 15 It is the case that you cannot use the “Command()” in Realtime Routines. You could however, set a flag that would trigger a PLC to execute the command. Quote
steve.milici Posted April 19 Posted April 19 You can however use the following C-API functions in real-time routines: JogPosition() JogSpeed() JogTrigger() Anything listed in the “rtpmaclib.h Rt/Gp Library Functions” or “rtpmacapi.h Rt/Gp Library Functions” can be used in real-time routines. See the C-API help documentation for details. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.