
20
port.send(MR, sizeof(MR));
// Move motors
}
Example 4 – Reading of Position
The position of any axis can be queried with the GP instruction.
CSerial port;
If(port.open(2, 115200))
// Open serial port and configured
{
// to baud 115200 bps
char query[7] = “GP ?,?”;
// Get position – A and B axes
query[6] = 0x0D;
// Terminate with Carriage Return
char readBuf[10];
// Container for reply
char posA[5];
// Buffer for Axis A position
char posB[5];
// Buffer for Axis B position
int i = 0;
port.send(query, sizeof(query));
// Query for position
// Once controller received the command, it will reply the positions.
port.read(readBuf, sizeof(readBuf));
// Read the positions
// Positions replied contained in readBuf are separated by 0x0D
// Read position of Axis A
while(readBuf[i] != 0x0D)
{
posA[i] = readBuf[i];
i++;
}
// Read position of Axis B
while(readBuf[i] != 0x0D)
{
posB[i] = readBuf[i];
i++;
}
}
Example 5 – Velocity Control
In this example, we drive A and B motors at a desired speed.
Содержание MK-200C
Страница 1: ...M MK K 2 20 00 0C C U Us se er r s s M Ma an nu ua al l Revision 1 1 MOTKA LLP ...
Страница 4: ...4 List of Tables Table 1 MK 200C terminal definitions 9 Table 2 Document revision history 25 ...
Страница 7: ...7 Related documents Command Reference MOTKA Motion Companion User s Manual ...
Страница 22: ...22 3 3 Package Information Figure 12 MK 200C package outline ...
Страница 26: ...26 ...