I am working with an industrial temperature controller, a PLC, and a limited number of numeric inputs. I have two channels on my temperature controller, each of which can generate an integer error code. Unfortunately, I only have one integer input available on my PLC with which to receive these two codes. I can do math functions on either end to distinguish the two numbers from one another, but may only transmit one number from the temperature controller to the PLC. Is this possible?
There are other hardware changes I could make to get around this problem, but I thought it could make for an elegant and efficient solution. Here's some additional info:
Transmit Side (Temperature Controller)
Each channel (A and B) on the temperature controller contains an integer value for the error code:
- No Error = 61
- Valid Error Codes = 9, 32, 65, 127, 139, 140
And these are the math functions available to me on this end:
- Add/Subtract
- Multiply/Divide
- Average
- Absolute Difference (|A-B|)
- Square Root
I must perform these functions one at a time, so the simpler the better. The number being output is limited to a 16-bit unsigned integer (0 to 65,535).
I would combine A and B to produce a value C, perhaps by doing something like Ax + By = C, and transmit this to the PLC. (Of course, Ax * By = C make them much easier to factor out, but I quickly violate my maximum value limitation.)
Receive Side (PLC)
I have a few more math functions available to me in the PLC:
- Add/Subtract
- Multiply/Divide
- Modulo
- Square Root
- Exponent (x^y)
- Absolute Value
- Cos, Sin, Tan, ArcCos, ArcSin, ArcTan
- Natural Log
- Log Base 10
- Truncate (drop values after decimal)
In the PLC I can write an expression that will output a value. I can also perform some initial checks, for example:
If (C mod x = 0 AND C mod y = 0)
Then compute expressions 1 (to get A) and 2 (to get B)
ElseIf (C mod x = 0)
Then compute expressions 3 (to get A) and 4 (to get B)
ElseIf (C mod y = 0)
Then compute expressions 5 (to get A) and 6 (to get B)
Since I know that x is related to A and y is related to B, through what mathematical operations can I create C and then translate C back into A and B?
Or is there another way I should be thinking about this altogether?
C = 256*A + B, thenB = C mod 256,A = (C-B)/256. – achille hui Oct 19 '17 at 20:45