AMarks95
Member
I'm having to make an AOI to use with a generic ethernet device because the manufacturer does not provide an AOP. I just want to do a sanity check to make sure I'm copying/moving/masking things correctly to get the results I expect, since these are not things I typically do.
The bits are easy enough to handle, it's just the combining of SINTs and conversion to other datatypes.
The input data structure is an array of SINTS. Here's an example:
Breakdown of Data | type SINT[12] :
Bytes 0/1 - UINT Trip Code
Bytes 2/3 - Trip Bits | [2].2 = Ground Current, [2].3 = Thermal Overload, [3].0 = comm trip
Bytes 4/5 - INT Temperature (deg C)
Bytes 6/7/8/9 - UDINT Current (x0.01 A)
Bytes 10/11 - Misc. Stats and Current | [11].0 - [11].5 ( 0 - 63 )
Trip code:
COP(Source = Data[0], Dest = TripCode, Length = 1) | where TripCode is type INT
Not worried about signed vs unsigned here because the code will never be larger than 555.
Trip Bits:
GroundCurrentTrip = XIC(Data[2].2)
ThermalTrip = XIC(Data[2].3)
CommTrip = XIC(Data[3].0)
Temperature:
COP(Source = Data[4], Dest = Temp_INT, Length = 1) | where Temp_INT is type INT
MotorTemp = ( Temp_INT * 9/5 ) + 32 | where MotorTemp is type REAL
Current:
COP(Source = Data[6], Dest = Current_Temp, Length = 1) | where Current is type DINT
Current = Current_Temp / 100 | where Current is type REAL
Less confident about this one because of the unsigned/signed thing. Should Current_Temp be type UDINT? - COP doesn't like the datatype UDINT, and UDINT is not allowed inside CPT
Misc. Stats and Current:
COP(Source = Data[11], Dest = Temp_SINT[0], Length = 1) | where Temp_SINT is type SINT
MVM(Source = Temp_SINT[0], Mask = 2#11111100, Dest = Temp_SINT[1])
Current2 = ( Temp_SINT[1] / 32 ) * 100 | where Current2 is type REAL
I realize the COP is an extra step, but I like it for readability's sake.
Any help is much appreciated. Thanks!
The bits are easy enough to handle, it's just the combining of SINTs and conversion to other datatypes.
The input data structure is an array of SINTS. Here's an example:
Breakdown of Data | type SINT[12] :
Bytes 0/1 - UINT Trip Code
Bytes 2/3 - Trip Bits | [2].2 = Ground Current, [2].3 = Thermal Overload, [3].0 = comm trip
Bytes 4/5 - INT Temperature (deg C)
Bytes 6/7/8/9 - UDINT Current (x0.01 A)
Bytes 10/11 - Misc. Stats and Current | [11].0 - [11].5 ( 0 - 63 )
Trip code:
COP(Source = Data[0], Dest = TripCode, Length = 1) | where TripCode is type INT
Not worried about signed vs unsigned here because the code will never be larger than 555.
Trip Bits:
GroundCurrentTrip = XIC(Data[2].2)
ThermalTrip = XIC(Data[2].3)
CommTrip = XIC(Data[3].0)
Temperature:
COP(Source = Data[4], Dest = Temp_INT, Length = 1) | where Temp_INT is type INT
MotorTemp = ( Temp_INT * 9/5 ) + 32 | where MotorTemp is type REAL
Current:
COP(Source = Data[6], Dest = Current_Temp, Length = 1) | where Current is type DINT
Current = Current_Temp / 100 | where Current is type REAL
Less confident about this one because of the unsigned/signed thing. Should Current_Temp be type UDINT? - COP doesn't like the datatype UDINT, and UDINT is not allowed inside CPT
Misc. Stats and Current:
COP(Source = Data[11], Dest = Temp_SINT[0], Length = 1) | where Temp_SINT is type SINT
MVM(Source = Temp_SINT[0], Mask = 2#11111100, Dest = Temp_SINT[1])
Current2 = ( Temp_SINT[1] / 32 ) * 100 | where Current2 is type REAL
I realize the COP is an extra step, but I like it for readability's sake.
Any help is much appreciated. Thanks!
Last edited: