In this mode, the host will send a series of
commands to the controller over the RS-232 serial
port. The controller process to the incoming commands and
responses with the proper messages.
Programming Example in Visual BASIC
The following example sets the linear
acceleration to 500000 Steps / sec2
,
step rate at 100 KHz, and the distance to travel equal to
200,000 steps. Then the controller is commanded to make an
absolute move on the X Axis.
Private Sub Command1_Click()
'Function Prototype
Declare Function SioPuts Lib "WSC32.DLL" (ByVal Port As
Long, ByVal Buffer As String, ByVal Size As Long) As
Long
Dim Code As Long
Dim StringToBeTransmtd As String
' Set the linear acceleration of X
Axis to 500,000 steps / sec / sec
StringToBeTransmtd =
"
accx
500000
"
+
vbCr
Code = SioPuts(ThePort, StringToBeTransmtd,
Len(StringToBeTransmtd))
' Set the linear velocity of X Axis to 100,000 steps /
sec
StringToBeTransmtd =
"
velx
100000
"
+
vbCr
Code = SioPuts(ThePort, StringToBeTransmtd,
Len(StringToBeTransmtd))
' Set the position to move of X Axis to 200,000 steps
StringToBeTransmtd =
"
posx
200000
"
+
vbCr
Code = SioPuts(ThePort, StringToBeTransmtd,
Len(StringToBeTransmtd))
'Command the X Axis of the controller to make an
absolute move
StringToBeTransmtd =
"
movax
"
+
vbCr
Code = SioPuts(ThePort, StringToBeTransmtd,
Len(StringToBeTransmtd))
End Sub
Programming Example in 'C'
The following example sets the
acceleration at 10
Million Steps
/ sec2
, step rate at 100 KHz, and the distance to travel equal to
100,000 steps. Then the controller is commanded to make an
absolute move.
void send_command(void)
{
char StringToBeTransmtd[80];
// Set the linear acceleration of X Axis to 500,000
steps / sec / sec
strcpy(StringToBeTransmtd,"accx
500000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));
// Set the linear velocity of X Axis to 100,000 steps /
sec
strcpy(StringToBeTransmtd,"velx
100000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));
// Set the position to move of X Axis to 200,000 steps
strcpy(StringToBeTransmtd,"posx
200000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));
// Command the X Axis of the
controller to make an absolute move
strcpy(StringToBeTransmtd,"movax\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));
}
|