<< Click to Display Table of Contents > 

Client Control Interface Manual > Programming Examples > Motion Control

Motion Control
Previous pageReturn to chapter overviewNext page

The following examples shows for MDrive motors (Type=5) how to set the absolute/relative position/angle and speed of two drives, execute the starting command and retrieve a message that both drives (1. part) and the first/second (2. part) drive has stopped respectively. In this context it is important to wait until the last drive has stopped before sending a new starting command (MotionGo; therefore the stop messages). Otherwise the motion control would not work correctly. If one drive reaches its position limit given in the motion settings file or has already reached its new position before, it does not move any more.

 

Motion Control - MDrive - type 5

 

// the application comes back immediately

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionWaitForEnd, 0 );

 

// 1. part: check if all MDrive motors have stopped

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 0 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisPosition, 100 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisSpeed, 4 );

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 1 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisAngleRelative, 720 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisSpeed, 1 );

 

cci.ScExecCommand( ( int ) ScComSAMLightClientCtrlExecCommandConstants.scComSAMLightClientCtrlExecCommandMotionGo );

 

// -1 means all axes

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, -1 );

do

{    cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, -1 );

}

whilecci.ScGetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionMoving ) == 1 );

 

MessageBox.Show( "All motors have stopped." );

 

// 2. part: check if single MDrive motor has stopped

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 0 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisPositionRelative, 100 );

 

cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 1 );

cci.ScSetDoubleValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlDoubleValueTypeMotionAxisAngle, 720 );

cci.ScExecCommand( ( int ) ScComSAMLightClientCtrlExecCommandConstants.scComSAMLightClientCtrlExecCommandMotionGo );

 

int axis0 = 1;

int axis1 = 1;

 

do

{

 if( axis0 == 1 )

    {

        cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 0 );

        ifcci.ScGetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionMoving ) == 0 )

        {

            MessageBox.Show( "Motor with axis 0 has stopped." );

            axis0 = 0;

        }

    }

 

    if( axis1 == 1 )

    {

        cci.ScSetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionAxis, 1 );

        ifcci.ScGetLongValue( ( int ) ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeMotionMoving ) == 0 )

        {

            MessageBox.Show( "Motor with axis 1 has stopped." );

            axis1 = 0;

        }

    }

while ( ( axis0 == 1 ) || ( axis1 == 1 ) ) ;

Table 415: Motion Control type 5