I need to choose a PLC that can do the following:
The PLC would send a SOH (which is a Ctr+A or ASCII 01) and i201 to the serial port
Then the connected device will respond with a string like this:
130430173001100000745FC000045FA780044F20000429053B43FF3B32C42927001423C866B&&EEB3
From the device's manual, this is the Format:
<SOH>i201TTYYMMDDHHmmTTpssssNNFFFFFFFF... TTpssssNNFFFFFFFF&&CCCC<ETX>
1. YYMMDDHHmm - Current Date and Time
2. TT - Tank Number (Decimal, 00=all)
3. p - Product Code (one ASCII character [20h-7Eh])
4. ssss - Tank Status Bits:
Bit 1 - (LSB) Delivery in Progress
Bit 2 - Leak Test in Progress
Bit 3 - Invalid Fuel Height Alarm (MAG Probes Only)
Bit 4-16 - Unused
5. NN - Number of eight character Data Fields to follow (Hex)
6. FFFFFFFF - ASCII Hex IEEE floats:
1. Volume
2. TC Volume
3. Ullage
4. Height
5. Water
6. Temperature
7. Water Volume
7. && - Data Termination Flag
8. CCCC - Message Checksum
I am looking to be able to extract the TC Volume value and have the PLC respond to changes by closing a contact. I understand that some PLCs can do anything that can be done with a spreadsheet program. However, I have not been able to figure out how to extract the value of the TC Volume using a spreadsheet.
Finding the HEX number for the TC Volume is the simple part (I hope). The hard part will be decoding the value of the TC Volume.
The manual for the device says:
6.3 ASCII FLOATING POINT FORMAT
6.3.1 NOTES
6.3.1.1 HHHHHHHH (H = 0-9 or A-F) indicates the 8 "nibble" ASCII-Hexadecimal representation
of a 4-Byte Floating Point number. Many data parameters are transmitted in this format.
6.3.1.2 The 32-bits are arranged as follows:
Byte1 = SEEE EEEE
Byte2 = EMMM MMMM
Byte3 = MMMM MMMM
Byte4 = MMMM MMMM
Nibbles are the groups of four letters
S is the sign bit (0 if positive, 1 if negative).
EEE EEEE E represents the 2's exponent. It is a 2's complement value biased by 127 (7F
Hex). The exponent can be determined by subtracting 127 from the value of the E field and
raising 2 to the resulting power.
MMM MMMM MMMM MMMM MMMM MMMM represents the 23-bit mantissa. Since
the mantissa describes a value which is greater than or equal to 1.0 and less than 2.0, the 24th
bit is always assumed to be equal to 1 and is not transmitted or stored. The value of the
mantissa can be determined by dividing the value of the M field by 8,388,608 (2 23 ) and
adding 1.0.
6.3.1.3 The complete value of the floating point number can then be determined by multiplying the
exponent by the mantissa and attaching the appropriate positive or negative sign.
6.3.1.4 By convention, 00 00 00 00 represents the value 0.0 even though it actually converts to
5.8775 x 10 -39 .
6.3.1.5 The eight "nibbles" are transmitted in sequence from 1 through 8 as shown in section 6.3.1.2.
Part No. 576013-635, Revision Y 6
6.3.2 EXAMPLES
6.3.2.1 3F800000 hex = 0011 1111 1000 0000 0000 0000 0000 0000 bin
S = 0 = + (positive)
E = 011 1111 1 bin = 7F hex = 127 dec
M = 000 0000 0000 0000 0000 0000 bin = 0 hex = 0 dec
Exponent = 2 (127-127) = 1.0
Mantissa = 1.0 + (0/8,388,608) = 1.0
Decimal Value = +1.0 x 1.0 = 1.0
6.3.2.2 B8D1B717 hex = 1011 1000 1101 0001 1011 0111 0001 0111 bin
S = 1 = - (negative)
E = 011 1000 1 bin = 71 hex = 113 dec
M = 101 0001 1011 0111 0001 0111 bin = 51 B7 17 hex = 5,355,287 dec
Exponent = 2 (113-127) = 0.0000610352
Mantissa = 1.0 + (5,355,287/8,388,608) = 1.63840
Decimal Value = -0.0000610352 x 1.63840 = -0.0001
6.3.2.3 C2C7FAE1 hex = 1100 0010 1100 0111 1111 1010 1110 0001 bin
S = 1 = - (negative)
E = 100 0010 1 bin = 85 hex = 133 dec
M = 100 0111 1111 1010 1110 0001 bin = 47 FA E1 hex = 4,717,281 dec
Exponent = 2 (133-127) = 64
Mantissa = 1.0 + (4,717,281/8,388,608) = 1.56234
Decimal Value = -64 x 1.56234 = -99.99
6.3.2.4 461C4000 hex = 0100 0110 0001 1100 0100 0000 0000 0000 bin
S = 0 = + (positive)
E = 100 0110 0 bin = 8C hex = 140 dec
M = 001 1100 0100 0000 0000 0000 bin = 1C 40 00 hex = 1,851,392 dec
Exponent = 2 (140-127) = 8,192
Mantissa = 1.0 + (1,851,392/8,388,608) = 1.22070
Decimal Value = +8,192 x 1.22070 = 10,000
So, I have created a spreadsheet which almost is able to extract the value of the TC Level. However, almost is the operative word. A zipped version of my Microsoft Excel 2007 xlsx file is attached.
Thank you for reading this far. Happy summer! Oh, I downloaded and ran the Do-more controller software. It is over my head at this time. I have successfully created a simple smart relay system using the Click PLC for another project.
Special thanks to Travis E., Billy S., Paul R., and the folks at Automation Direct who have been so helpful over the phone.