You are not registered yet. Please click here to register!

plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!

Go Back - Interactive Q & A > - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Thread Tools Display Modes
Old February 11th, 2018, 04:11 PM   #1
United States

keithkyll is offline
Join Date: Jul 2005
Location: Heath, TX
Posts: 2,026
Calculate simple ASCII Checksum Mod 256

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
  Reply With Quote
Old February 12th, 2018, 12:10 PM   #2
United States

keithkyll is offline
Join Date: Jul 2005
Location: Heath, TX
Posts: 2,026
May have found part of the solution.
The note in the help file for Copy Character (CPC) says it stores the ASCII value of the string character. I'll use an ASCII field for RPM on the HMI.
Add up the values in array, then figure out how to convert the HEX value to a string.
Stay tuned ...

Last edited by keithkyll; February 12th, 2018 at 12:11 PM. Reason: Spelling
  Reply With Quote
Old February 12th, 2018, 04:14 PM   #3
Geoff White

Geoff White is offline
Join Date: Oct 2005
Location: Brisbane
Posts: 343
I know nothing about the hardware you are using but it does not sound too complicated.

The code snippet should calculate the checksum. If the strings are short you should only need to mod it after adding the ascii codes up.

To hex the checksum just use
chr$((checksum div 16)+48) and chr$((checksum mod 16)+48) for the two characters
  Reply With Quote
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Step7 313 CPU ASCii dahnuguy LIVE PLC Questions And Answers 2 March 10th, 2011 04:44 PM
s7 200 and printer SHYAMAL LIVE PLC Questions And Answers 6 August 12th, 2008 01:47 AM
Ascii Checksum Allen Bradley fornhamspark LIVE PLC Questions And Answers 4 June 20th, 2008 02:33 AM
Ascii Checksum In A PLC ? cgehlhausen LIVE PLC Questions And Answers 6 February 1st, 2006 01:40 PM
ASCII input to PLC-5 - converting strings to numbers Ron Beaufort LIVE PLC Questions And Answers 3 April 10th, 2004 01:45 PM

All times are GMT -5. The time now is 03:22 PM.