-
Posts
68 -
Joined
-
Last visited
-
Days Won
4
Content Type
Profiles
Forums
Gallery
Events
Blogs
Downloads
Articles
Media Demo
Posts posted by Ash Neilson
-
-
Geert,
Chances are you have a "DOS" Screen in front of you at the moment.
Press and Hold the Touch Screen for about 4 - 5 seconds.
You will then be presented with Two Buttons, tap the "Info" Button.
Enter the Password "1111" from there and follow Phil's Instructions
-
Hi guys.
I've question about calculating checksum in binary format. Authors of 'VisionCommunication.pdf' said: Calculate the accumulated sum of the bytes in the vector.
I suppose, vector is full binary query containing header, details and footer sections. Is it true? And what kind of sum have I to calculate? ASCII sum of full query, or maybe length of query? Can you help me?
Hi Mate,
I assume you are referring to the PComB Communication Protocol, which uses the Binary based data.
You actually need to have two Checksums! The first checksum is the last 2 bytes of the PComB Header (Which itself is 24 bytes long including the checksum). The Second checksum is located in the Footer and is the checksum of the Details.
Here Below I have broken up the PComB Message to show you where the Checksums sit and what they are a Checksum of:
Header:
========
0 = /
1 = _
2 = O
3 = P Bytes 0 to 5 are the STX ("/_OPLC")
4 = L
5 = C
6 = <Unit ID of PLC>
7 = 254 (Always 254)
8 = 1 (Always 1)
9 = <Message Key> (You probably won't need to use this, so leave it as 0)
10 = 0
11 = 0
12 = <Command Code>
13 = <Sub Command Code> (Again probably not required by you so leave as 0)
14 = -
15 = |
16 = | Bytes 14 to 19 are usually the 4 bytes of the Address and 2 bytes of the Elements Count
17 = | These can sometimes be "Command Details" relating to the PComB Command Code
18 = |
19 = -
20 = LSB of Detail Length | Bytes 20 to 21 are the Length of the Bytes in the Detail Section
21 = MSB of Detail Length |
22 = LSB of Checksum | Bytes 22 to 23 are the Checksum of this Header
23 = MSB of Checksum |
The Checksum of the Header that sits in Bytes 22 and 23, is calculated using all the Bytes of the Header (From Byte 0 to Byte 21).
Details:
========
This section of the PComB Message will contain byte data specific to the Command.
Refer to the Unitronics PCOM Protocol PDF for information on the Details Section.
Footer:
========
This section contains just three Bytes. Two Bytes are the Checksum of the Details Section, and the last Byte is the ETX.
0 = LSB of Details Checksum
1 = MSB of Details Checksum
2 = \ Byte 2 is the ETX ("\")
When calculating the Details Checksum, make sure you are using EVERY SINGLE Byte in the Details Section. The Header Section must not be included in the Details Checksum.
Both the Header Checksum and Details Checksum are calculated using a Two' Complement calculation. Below I have listed the Visual Basic, C# and C/C++ Syntax for calculating a PComB Checksum.
1 - Calculate the Sum of the Byte Values in the Section (Meaning add all the "Bytes Values" together to make one big number)
2 - Take this Sum of Byte Values and Calculate the Modulo of 65536 ("Byte Values" MOD 65536) - This makes the Checksum's Maximum Value a Two-Byte Unsigned 16-Bit Integer
3 - Two's Complement of the Calculated Modulo Value - Invert ("NOT") the Value and Add "1"
For the below examples, the Sum of the Byte Values is "<BytesSum>".
Visual Basic (The Result 'checksum' is a UShort):
=================================================
checksum = (Not (<BytesSum> Mod 65536)) + 1
C# (The Result 'checksum' is a UInt16):
========================================
checksum = (~(<BytesSum> % 65536)) + 1;
C / C++:
=========
checksum = (~(<BytesSum> % 65536)) + 1;
Hopefully this is the information you were after! If you are still having trouble, maybe post some of your code so I can help explain things better
Cheers,
Ash Neilson
- 1
-
Cara - You learn fast! I wasn't going to post anything about the UDFB's, but it would be a matter of hours before someone did
I would trade my right arm for UDFB's if it wasn't for my job that requires typing
V130: what time is it? (...in UTC)
in Vision & Samba PLC + HMI Controllers & VisiLogic Software
Posted
Hi John,
There is a nice little Ladder Utility that will give you exactly what you want.
In VisiLogic 8.6.0 or older, the Utility is under the "Clock" drop down menu, then "UTC", then "RTC to UTC".
In VisiLogic 8.6.1, follow the same steps, but it will be under the "Utils" drop down menu.
To use this Utility, the Operand that you specify on the input side is actually the "Start of a Vector" Address. For your requirements, putting SI30 into that Utility will allow it to grab SI30, SI31, SI32 and SI33.
The Output of this Utility is best assigned to a DW Operand.