![Omntec PROTEUS OEL8000III Series Manual Download Page 14](http://html1.mh-extra.com/html/omntec/proteus-oel8000iii-series/proteus-oel8000iii-series_manual_740737014.webp)
PROTEUS
OMNTEC
Mfg., Inc., 2420 Pond Road, Ronkonkoma, NY 11779
Phone (631) 981-2001 Fax (631) 981-2007 www.OMNTEC.com
File Name: DE00014 DE00015 DE00020-10 rev2045.docx Page 14 of 71 Rev Date: 10-15-2021
Serial Interface Manual
OEL8000III Series Models K/X
VISUAL BASIC CHECKSUM PROGRAMMING EXAMPLE
Check the checksum on OMNTEC Five Charactor/TLS350 protocol
'”Instring” contains current response string.
'The addition of all of the characters(except checksum) converted back to
'a four character hex string should equal the checksum string.
Private Sub check_checksum()
'Read four characters after the ‘&&’ termination.
stpt = (InStr(1, InString, "&&"))
'Find the ‘&&’ termination characters.
If (Len(InString) < stpt + 4) Then Exit Sub
'Are CHECKSUM characters in the response.
chsum = Mid(InString, stpt + 2, 4)
'Store the four checksum characters.
i = 1
'Add the all characters in the string together except the four checksum characters.
Do While (i < stpt + 2)
chk_sum = c Asc(Mid(InString, i, 1))
i = i + 1
Loop
chk_sum = chk_sum Mod 65536
'AND with 0xFFFF (round off).
chk_sum = Hex(&H10000 - chk_sum)
'Perform 2’s complement(Invert plus one), save as
'a hex string.
'Put zero's to format string to 4 places if needed.
If Len(chk_sum) < 4 Then cksm_lgh = 4 - Len(chk_sum)
For X = 1 To cksm_lgh
chk_sum = "0" & chk_sum
Next X
End If
'Compare strings, checksum with calculated value.
If (chsum = chk_sum) Then
checksum_0k = 1 'If checksum is OK.
Else
checksum_0k = 0 'Else checksum is bad.
End If
End Sub
Check the checksum on OMNTEC three Charactor/TLS250 protocol
The three character command checksum is calculated the same as in the above example accept that the termination
character(s) ‘&&’ is a ‘9’ before the checksum characters. Check that the fifth character from the end of the string
is a ‘9’ then store the last four characters as the checksum.