I am sending broadcast message and within PGN there is 12 bit signal (Codesys 3.5 SP11+ 32 bit) with conversion info:
Conversion: TRUE
Raw data type: Signed
Byte order: Little endian
Scaling 1
Offset 0
IEC datatype: INT
(min and max values are -180 to 180)
And when "online" the value is e.g. -175.
When I am reading that CAN message from other controller and I am watching it Online, the values coming are fine for 0..+180 (same 0..+180), but negative values from -1 to -180 are 3917 to 4095 ?? It's like the Signed is not working?
The "reading" controller PGN signal conversions are same :
Conversion: TRUE
Raw data type: Signed
Byte order: Little endian
Scaling 1
Offset 0
IEC datatype: INT
"Reading" controller is with Codesys 3.5 SP15 Patch 1 + (64 Bit)
Why the value is like it's Unsigned UINT? What I am doing wrong or is it a bug?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And if you set "Raw data type" (a.k.a. on the wire) as "Unsigned" and set "Offset" as -180?
It is also more idiomatic (by the J1939 standard, all quantities on the wire are, or at least should be, unsigned).
By the way, if it is an angle, have you checked the standard angle scalings? There is SAEad04 which uses two bytes, 1/128 deg/bit, and offset -200, for a total range of -200 .. +301.99 degrees.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Originally created by: palej
Hi,
I am sending broadcast message and within PGN there is 12 bit signal (Codesys 3.5 SP11+ 32 bit) with conversion info:
Conversion: TRUE
Raw data type: Signed
Byte order: Little endian
Scaling 1
Offset 0
IEC datatype: INT
(min and max values are -180 to 180)
And when "online" the value is e.g. -175.
When I am reading that CAN message from other controller and I am watching it Online, the values coming are fine for 0..+180 (same 0..+180), but negative values from -1 to -180 are 3917 to 4095 ?? It's like the Signed is not working?
The "reading" controller PGN signal conversions are same :
Conversion: TRUE
Raw data type: Signed
Byte order: Little endian
Scaling 1
Offset 0
IEC datatype: INT
"Reading" controller is with Codesys 3.5 SP15 Patch 1 + (64 Bit)
Why the value is like it's Unsigned UINT? What I am doing wrong or is it a bug?
Hmm, it is clear you have a 12bit 2's compliment signed integer, whose data is stored in 16 bit 2's compliment signed integer.
You can write a FUNCTION to convert the two data types.
And if you set "Raw data type" (a.k.a. on the wire) as "Unsigned" and set "Offset" as -180?
It is also more idiomatic (by the J1939 standard, all quantities on the wire are, or at least should be, unsigned).
By the way, if it is an angle, have you checked the standard angle scalings? There is SAEad04 which uses two bytes, 1/128 deg/bit, and offset -200, for a total range of -200 .. +301.99 degrees.