Jump to content
OMRON Forums

Command() on servo loop functions


Recommended Posts

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?

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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);

 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...