Jump to content
OMRON Forums

Jogging a Motor from a PLC program


bradp

Recommended Posts

In many instances a user wants to simply command a motor to Jog based on the state of some input. In these instances not much status and error checking is required. Othertimes a user wants to build some sort of process or state machine using Jog commands. In these instances it is important to know that a Jog command was successfully started and completed or that an error has occured so that the correct next state can be executed. A deeper understanding of how the Power PMAC executes a Jog command helps To properly program this type of system. When a Jog command is given to the PPMAC from a C APP, CPLC, or with a CMD"" statement from a script PLC the first processing step is syntax checking of the command. If the Syntax is correct the next step is to see that the motor is not involved in any motion program execution. If these tests are passed the function sending the command will return no error. After this step the command is calculated and when everything is prepared the Motor[].Desired.Jog element is set to 1. This is a flag for the servo indicating a Jog is being requested. This flag will only be 1 until the next servo interrupt at which time the servo clears the flag and tries to execute the Jog. If the Jog can be executed the element Motor[].DesVel will become non-zero and the status bit Motor[].DesVelZero will be set to 1. If the Jog cannot be exectued Motor[].DesVel and Motor[].DesVelZero will remain 0. The other case in which Motor[].DesVel and Motor[].DesVelZero will remain 0 is when the jog position is the same as the present desired position. Using this information the proper way to determine if a Jog command has completed is to follow these steps. 1. Issue the Jog command and check the function response. 2. If step 1 is OK then wait at least one servo cycle. 3. Wait for position or velocity requirement to be met. 4. If step 4 is not met check the motor status word for errors. There are many variations on the above idea. Below is a simple C APP that just requires motor 1 to stop before motor 2 starts and motor 2 to stop before motor 1 restarts. If the motor actually reaches its commanded position is not considered in this example. This example also uses x2 digital inputs to determine if the motor should be part of the sequence. //-------------------------------------------------------------------------------- #include #include // Global Rt/Gp Shared memory pointers //------------------------------------------------------------- // The following is a projpp created file from the User defines //------------------------------------------------------------- #include "../../Include/pp_proj.h" int main(void) { struct SHM *pshm; int i; double dIn01, dIn02, Mtr1DesVel, Mtr2DesVel, Svr, SvrStart; InitLibrary () ; pshm = GetSharedMemPtr(); while ( 1 > 0 ){ dIn01 = GetPtrVar(In01); if (dIn01 > 0.5){ Command("#1J:2000"); // must wait one servo cycle for jog to start If it has not started by then it will not // this motor uses C API functions GetPmacVar("Sys.ServoCount", &Svr); SvrStart = Svr; while (SvrStart == Svr) GetPmacVar("Sys.ServoCount", &Svr); GetPmacVar("Motor[1].DesVel", &Mtr1DesVel); while (Mtr1DesVel > 0) GetPmacVar("Motor[1].DesVel", &Mtr1DesVel); } dIn02 = GetPtrVar(In02); if (dIn02 > 0.5){ Command("#2J:2000"); // must wait one servo cycle for jog to start If it has not started by then it will not // this motor uses shared memory pointer SvrStart = pshm->ServoCount; while (SvrStart == pshm->ServoCount) pshm->P[10]++; // for debug while (pshm->Motor[2].DesVel > 0) pshm->P[11]++; // for debug } } CloseLibrary(); return 0; }
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Guest
This topic is now closed to further replies.

×
×
  • Create New...