Example) Perform JOG operation of the
X-Y table based on the specifications below.
・Axis number 1 performs constant speed movement at the starting speed in
the positive direction.
・Axis number 2 performs acceleration movement in the negative direction.
[Please add the ">" codes if you want to synchronously start
axis number 1 and axis number 2]
■ C
long Ret;
long ErrRet;
Short Id;
char ErrorString[256];
// Initialization process
// Not required if initialization has already
been performed.
Ret = SmcWInit("SMC000",
&Id);
ErrRet = SmcWGetErrorString(
Ret, ErrorString );
printf("SmcWInit : %s", ErrorString );
// Reflects the contents of the initial setting
function to the hardware.
// Execute for each axis.
// Axis number 1
Ret = SmcWSetInitParam(
Id , 1 );
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWSetInitParam : %s", ErrorString );
// Axis number 2
Ret = SmcWSetInitParam(
Id , 2 );
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWSetInitParam : %s", ErrorString );
>// Setting synchronization
>// Setting synchronization between axes
(2nd argument): 3H: Axis 1 and Axis 2 are synchronized axes
>// Setting inter-chip synchronization (3rd
argument): 1H: Synchronize
>// Setting inter-chip synchronization (3rd
argument): 0H: Not synchronized
>Ret = SmcWSetSync(
Id , 3, 1, 0 );
// Setting basic operating parameters
// Setting the target speed
// Default values are used for starting speed,
acceleration time, deceleration time, and S-curve section, so no need
to set them.
Ret = SmcWSetTargetSpeed( Id,
1, 100);
Ret = SmcWSetTargetSpeed( Id,
2, 2500);
// Setting start preparation parameters
// Setting the motor operation type (3rd argument):
2: JOG operation
// Setting of motor operation direction (4th
argument): 0: positive direction: 1: negative direction
Ret = SmcWSetReady( Id , 1, 2 , 0
); // Axis number 1
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWSetReady : %s", ErrorString );
Ret = SmcWSetReady( Id , 2, 2 , 1
); // Axis number 2
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWSetReady : %s", ErrorString );
// Starting operation
// No pulses are output here if a synchronization
setting has been made. (Status will be in operation)
Ret = SmcWMotionStart(
Id , 1 );
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWMotionStart : %s", ErrorString );
Ret = SmcWMotionStart(
Id , 2 );
ErrRet = SmcWGetErrorString( Ret, ErrorString );
printf("SmcWMotionStart : %s", ErrorString );
>// Starting synchronous operation
>// Specify
one of the synchronization target axes.
>Ret = SmcWSyncWMotionStart(
Id , 1 );
■ Visual Basic
Dim Ret As Long
Dim ErrRet As Integer
Dim Id As Short
Dim ErrorString As StringBuilder
' Initialization process
' Not required if initialization has already
been performed.
Ret = SmcWInit("SMC000",
Id)
ErrRet = SmcWGetErrorString(
Ret, ErrorString )
Debug.Printf "SmcWInit : " & ErrorString
' Reflects the contents of the initial setting
function to the hardware.
' Axis number 1
Ret = SmcWSetInitParam(
Id , 1 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWSetInitParam : " & ErrorString
' Axis number 2
Ret = SmcWSetInitParam(
Id , 2 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWSetInitParam : " & ErrorString
>' Setting synchronization
>' Setting synchronization between axes (2nd
argument): 3H: Axis 1 and Axis 2 are synchronized axes
>' Setting
inter-chip synchronization (3rd argument): 1H: Synchronize
>' Setting inter-chip synchronization (3rd
argument): 0H: Not synchronized
>Ret = SmcWSetSync(
Id , 3, 1, 0 )
' Setting basic operating parameters
' Setting the target speed
' Default values are used for starting speed,
acceleration time, deceleration time, and S-curve section, so no need
to set them.
Ret = SmcWSetTargetSpeed(Id,
1, 100)
Ret = SmcWSetTargetSpeed(Id,
2, 2500)
' Setting the
motor operation type (3rd argument): 2: JOG operation
' Setting of motor operation direction (4th
argument): 0: positive direction: 1: negative direction
Ret = SmcWSetReady( Id , 1, 2, 0 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWSetReady : " & ErrorString
Ret = SmcWSetReady( Id , 2, 2, 1 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWSetReady : " & ErrorString
' Starting operation
' No pulses are output here if a synchronization
setting has been made. (Status will be in operation)
Ret = SmcWMotionStart(
Id , 1 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWMotionStart : " & ErrorString
Ret = SmcWMotionStart(
Id , 2 )
ErrRet = SmcWGetErrorString( Ret, ErrorString )
Debug.Printf "SmcWMotionStart : " & ErrorString
>' Starting synchronous operation
>' Specify
one of the synchronization target axes.
>Ret = SmcWSyncWMotionStart(
Id , 1 )
■ C#
int Ret;
int ErrRet;
Short Id;
string ErrorString;
// Initialization process
// Not required if initialization has already
been performed.
Ret = Smc.WInit("SMC000",
out Id);
ErrRet = Smc.WGetErrorString(
Ret, out ErrorString );
Debug.Print("SmcWInit: {0}", ErrorString);
// Reflects the contents of the initial setting
function to the hardware.
// Execute for each axis.
// Axis number 1
Ret = Smc.WSetInitParam(
Id , 1 );
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWSetInitParam: {0}", ErrorString);
// Axis number 2
Ret = Smc.WSetInitParam(
Id , 2 );
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWSetInitParam: {0}", ErrorString);
>// Setting synchronization
>// Setting synchronization between axes
(2nd argument): 3H: Axis 1 and Axis 2 are synchronized axes
>// Setting inter-chip synchronization (3rd
argument): 1H: Synchronize
>// Setting inter-chip synchronization (3rd
argument): 0H: Not synchronized
>Ret = Smc.WSetSync(
Id , 3, 1, 0 );
// Setting basic operating parameters
// Setting the target speed
// Default values are used for starting speed,
acceleration time, deceleration time, and S-curve section, so no need
to set them.
Ret = Smc.WSetTargetSpeed( Id,
1, 100);
Ret = Smc.WSetTargetSpeed( Id,
2, 2500);
// Setting start preparation parameters
// Setting the motor operation type (3rd argument):
2: JOG operation
// Setting of motor operation direction (4th
argument): 0: positive direction: 1: negative direction
Ret = Smc.WSetReady( Id , 1, 2 , 0
); // Axis number 1
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWSetReady: {0}", ErrorString);
Ret = Smc.WSetReady( Id , 2, 2 , 1
); // Axis number 2
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWSetReady: {0}", ErrorString);
// Starting operation
// No pulses are output here if a synchronization
setting has been made. (Status will be in operation)
Ret = Smc.WMotionStart(
Id , 1 );
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWMotionStart: {0}", ErrorString);
Ret = Smc.WMotionStart(
Id , 2 );
ErrRet = Smc.WGetErrorString( Ret, out ErrorString );
Debug.Print("SmcWMotionStart: {0}", ErrorString);
>// Starting synchronous operation
>// Specify
one of the synchronization target axes.
>Ret = Smc.WSyncWMotionStart(
Id , 1 );
■ Python
Ret = ctypes.c_long()
ErrRet = ctypes.c_long()
Id = ctypes.c_short()
ErrorString = ctypes.create_string_buffer(256)
# Initialization process
# Not required if initialization has already
been performed.
Ret.value = csmc.SmcWInit("SMC000",
ctypes.byref(Id))
ErrRet.value = csmc.SmcWGetErrorString(
Ret, ErrorString )
print(f"SmcWInit : {ErrorString.value.decode('sjis')}")
# Reflects the contents of the initial setting
function to the hardware.
# Execute for each axis.
# Axis number 1
Ret.value = csmc.SmcWSetInitParam(
Id , 1 )
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWSetInitParam : {ErrorString.value.decode('sjis')}")
# Axis number 2
Ret.value = csmc.SmcWSetInitParam(
Id , 2 )
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWSetInitParam : {ErrorString.value.decode('sjis')}")
># Setting synchronization
># Setting synchronization between axes (2nd
argument): 3H: Axis 1 and Axis 2 are synchronized axes
># Setting inter-chip synchronization (3rd
argument): 1H: Synchronize
># Setting inter-chip synchronization (3rd
argument): 1H: Synchronize
>Ret.value = csmc.SmcWSetSync(
Id , 3, 1, 0 )
# Setting basic operating parameters
# Setting the target speed
# Default values are used for starting speed,
acceleration time, deceleration time, and S-curve section, so no need
to set them.
Ret.value = csmc.SmcWSetTargetSpeed(
Id, 1, 100)
Ret.value = csmc.SmcWSetTargetSpeed(
Id, 2, 2500)
# Setting start preparation parameters
# Setting the motor operation type (3rd argument):
2: JOG operation
# Setting of motor operation direction (4th
argument): 0: positive direction: 1: negative direction
Ret.value = csmc.SmcWSetReady( Id
, 1, 2 , 0 ) # Axis number 1
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWSetReady : {ErrorString.value.decode('sjis')}")
Ret.value = csmc.SmcWSetReady( Id
, 2, 2 , 1 ) # Axis number 2
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWSetReady : {ErrorString.value.decode('sjis')}")
# Starting operation
# Starting operation
Ret.value = csmc.SmcWMotionStart(
Id , 1 )
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWMotionStart : {ErrorString.value.decode('sjis')}")
Ret.value = csmc.SmcWMotionStart(
Id , 2 )
ErrRet.value = csmc.SmcWGetErrorString( Ret, ErrorString )
print(f"SmcWMotionStart : {ErrorString.value.decode('sjis')}")
># Starting synchronous operation
># Specify
one of the synchronization target axes.
>Ret.value = csmc.SmcWSyncWMotionStart(
Id , 1 )