Serial communication description V1.0 - makerbase-mks/MKS-SERVO42C GitHub Wiki
Applicable to MKS-SERVO42C-V1.0
Note: Please set the serial port ID first.(default:e0) The default ID for the following chapters is e0.
Read parameter coommand
-
command 1 : e0 30
read the encoder value (the motor should be calibrated)
Return e0, encoder value(uint16_t). The returned value ranges from 0 to FFFF.
Example:
Send e0 30
return e0 40 00
-
command 2 : e0 33
Read the number of pulses received
Return e0, pulses number(int16_t).
Example:
Send e0 33
return e0 00 00 01 00 (256 pulses)
-
command 3 : e0 36
read the angle of the motor shaft.
Return e0 , angle(int32_t), tCHK.
The motor rotates one circle, the corresponding angle value range is 0~65535.
Example:
Send e0 36 16
return e0 00 00 40 00 20 (angle 90 °)
-
command 4: e0 39
read the error of the motor shaft angle.
Return e0, error(int16_t).
The error is the difference between the angle you want to control minus the real-time angle of the motor, 0-FFFF corresponds to 0~360°, for example, when the angle error is 1°, the return error is 65536/360= 182.444, and so on.
Example:
Send e0 39
return e0 00 B7 (error 1 °)
-
command 5: e0 3a
read the En pins status.
Return e0, status (uint8_t).
Status: 01-enable;02-disable;00-error
Example:
Send e0 3a
return e0 01 (enable)
-
command 6: e0 3e
read the motor shaft status.
Return e0, status (uint8_t).
Status: 01-blocked; 02- unblocked; 00-error
Example:
Send e0 3e
return e0 02 (unblocked)
Set subdivision command
-
command 7: e0 84 xx
Set subdivision from 1 to 256, the value will show in the screen of MStep option.
For example:
Send “e0 84 07”,set 7 subdivision
Send “e0 84 4e”,set 78 subdivision
Send “e0 84 00”,set 256 subdivision
And so on...
Return e0 , result (uint8_t).
result: 01- successful; 00- Failure
Example:
Send e0 84 1a (26 subdivision)
return e0 01 (successful)
Serial control command
-
command 8: e0 f3 xx
Set the En pin status in CR_UART mode.
status: 01-enable; 00-disable
Return e0, result (uint8_t).
result: 01- successful; 00- Failure
Example:
Send e0 f3 01 (enable)
return e0 01 nn (successful)
-
command 9: e0 f6 xx
run the motor forward / reverse in a Constant speed.
Such as:
The XX highest bit indicates direction, and the XX lowest 7 bits indicate 128 speed gears, for example:
Send “e0 f6 01”,The motor rotates forward at the speed of 1 gear;
Send “e0 f6 81”,The motor reverses at the speed of 1 gear;
Send “e0 f6 5a”,The motor rotates forward at the speed of 90 gear;
Send “e0 f6 da”,The motor reverses at the speed of 90 gear;
Return e0 ,result (uint8_t).
result: 01- successful; 00- Failure
Example:
Send e0 f6 10 (speed of 16 gear)
return e0 01 (successful)
-
command 10: e0 f7 d7
stop the motor.
Return e0 and the result (uint8_t).
result: 01- successful; 00- Failure
Example:
Send e0 f7 d7 (stop)
return e0 01 (successful)
-
command 11: e0 ff xx
Save/Clear the status set in command9.
xx: c8-save; ca-clean
Return e0, result (uint8_t).
result: 01- successful; 00- Failure
Example: Send e0 ff c8 (save the status)
return e0 01 (successful)
Attention:The motor can rotates clockwise or counterclockwise at a constant speed when powered on.
For example:
Send e0 f6 10
return e0 01
Send e0 ff c8
return e0 01
the motor will always rotates clockwise in speed(16) when power on.
-
command 12: e0 fd xx xx xx
The motor run to an angle in a speed.
The third byte(xx) defines the direction and speed, such as command 9.
The last two bytes(xx xx) define the number of pulses.
If(xx xx = 0C 80),the motor(1.8 °, subdivision 16) will rotates one circle.
Return e0, result (uint8_t).
result: 01- successful; 00- Failure
For example: (the motor(1.8 °, subdivision 16))
send “e0 fd 01 0c 80”, the motor rotates forward 360 °in speed 1.
send “e0 fd 86 0c 80”, the motor rotates reverses 360 °in speed 6.
Example:
Send e0 fd 32 0c 80
return e0 01 (successful)