PLC is Automation Direct P2000. Destination device is a servo drive. Pacific Scientific SC755 with a custom program in BASIC. I have a copy of the BASIC code.
Need to do a checksum of characters. RS232 out only.
CheckSum8 Modulo 256. Sum of Bytes mod 256.
Productivity CPO command only has checksums for CRC and XOR.
Structure for the Rotate command is a single ASCII character for the command, direction bit, 4 digit speed, 8 bit checksum in HEX (00 - FF).
Only need to do this for the Rotate command. Other commands are so simple, I can just send it complete, using an ASCII chart to find HEX value for character. For example, the Enable command is "E", so I send "E45". Home = "H48". Tested with a terminal program - PuTTY.
Commands are always fixed length. For example, rotate clockwise at 10 RPM is "V" for Velocity, "1" is direction, "0010" is speed, and "48" for checksum. Using this online checksum calculator to verify.
Need code to calculate the checksum in HEX. Assume I'll use the CPO instruction to pack and send in one instruction.
Portion of BASIC program used in drive to decode command:
WHILE 1 = 1
IF MSG_COMPLETE = 1 THEN
CHECK_SUM1 = 0
MSG_LEN = LEN(MOTOR_CMD$)
FOR I = 1 TO MSG_LEN-2
CHECK_SUM1 = (CHECK_SUM1 + ASC(MID$(MOTOR_CMD$,I,1))) MOD 256
NEXT
Need to do a checksum of characters. RS232 out only.
CheckSum8 Modulo 256. Sum of Bytes mod 256.
Productivity CPO command only has checksums for CRC and XOR.
Structure for the Rotate command is a single ASCII character for the command, direction bit, 4 digit speed, 8 bit checksum in HEX (00 - FF).
Only need to do this for the Rotate command. Other commands are so simple, I can just send it complete, using an ASCII chart to find HEX value for character. For example, the Enable command is "E", so I send "E45". Home = "H48". Tested with a terminal program - PuTTY.
Commands are always fixed length. For example, rotate clockwise at 10 RPM is "V" for Velocity, "1" is direction, "0010" is speed, and "48" for checksum. Using this online checksum calculator to verify.
Need code to calculate the checksum in HEX. Assume I'll use the CPO instruction to pack and send in one instruction.
Portion of BASIC program used in drive to decode command:
WHILE 1 = 1
IF MSG_COMPLETE = 1 THEN
CHECK_SUM1 = 0
MSG_LEN = LEN(MOTOR_CMD$)
FOR I = 1 TO MSG_LEN-2
CHECK_SUM1 = (CHECK_SUM1 + ASC(MID$(MOTOR_CMD$,I,1))) MOD 256
NEXT