Data type in CAN based communication protocol

Steven01

Member
Join Date
Oct 2015
Location
Prague
Posts
25
Hello all,

I have been implementing a CAN based communication protocol. During reading the documentation I have found that there are several data types used for physical quantities and each quantity is represented by 16 bits. For example one data type has a description "signed 2's complement word, 1/32 unit per bit". I am not sure what does it mean. My idea is that it means that the quantity range is <-1024; +1023.97>. Please can anybody tell me whether I am correct? Thank you in advance.
 
Hello all,

I have been implementing a CAN based communication protocol. During reading the documentation I have found that there are several data types used for physical quantities and each quantity is represented by 16 bits. For example one data type has a description "signed 2's complement word, 1/32 unit per bit". I am not sure what does it mean. My idea is that it means that the quantity range is <-1024; +1023.97>. Please can anybody tell me whether I am correct? Thank you in advance.

That`s how I would read it.
 
Thank you very much for your reaction, thingstodo. And what is the range in case the resolution is 1/1000 per bit? Does it mean that the quantity range is <-32.768, +32.767>? Thank you for your help.
 
Thank you very much for your reaction, thingstodo. And what is the range in case the resolution is 1/1000 per bit? Does it mean that the quantity range is <-32.768, +32.767>? Thank you for your help.

1/1000 per bit, * 32767 would get me to 32.767 scaled units
1/1000 per bit, * -32768 would get me to -32.768 scaled units

These units sound strange. Not that it is impossible for CAN data to fit nicely into 16 bit numbers ... it`s just that I have not seen that so far.

I have seen lots of 8 bit numbers, some 10 bit, some 12 bit. Lots of stuff where the byte boundaries are not lined up and you need to take a couple of bits from one byte and shift them into another byte.

Is this for an HMI?
 
Hello thingstodo,

yes, it is for HMI. I have been struggling with following calculation. I read a voltage value in fractional format u16Q6 from a DSP. I need to recalculate the voltage value into "signed 2's complement word, 1/32 volt per bit" for displaying on HMI. I am going to do following. At first I will divide the read voltage value in u16Q6 by 64. I expect that this operation results in voltage in volts. Then I will multiply the voltage value in volts by 32. I expect that this operation will result in voltage in "signed 2's complement word, 1/32 volt per bit". Are my steps correct? For example I read 14080 value from the DSP in format u16Q6. Then I will recalculate into volts 14080/64 = 220 V. And at the end 220*32 = 7040 (voltage in "signed 2's complement word, 1/32 volt per bit"). Thank you.
 
Hello thingstodo,

yes, it is for HMI. I have been struggling with following calculation. I read a voltage value in fractional format u16Q6 from a DSP. I need to recalculate the voltage value into "signed 2's complement word, 1/32 volt per bit" for displaying on HMI. I am going to do following. At first I will divide the read voltage value in u16Q6 by 64. I expect that this operation results in voltage in volts. Then I will multiply the voltage value in volts by 32. I expect that this operation will result in voltage in "signed 2's complement word, 1/32 volt per bit". Are my steps correct? For example I read 14080 value from the DSP in format u16Q6. Then I will recalculate into volts 14080/64 = 220 V. And at the end 220*32 = 7040 (voltage in "signed 2's complement word, 1/32 volt per bit"). Thank you.

I don`t know about the u16Q6 format, and a quick google search did not give me anything useful. But the divide by 32 will give you the correct value if you are starting from volts.

Once you get it running, you can combine the divide by 64 and multiply by 32 to just divide by 2. I guess it depends on how much CPU you have, and whether it is busy doing other stuff. If you have the CPU power to spare, it is easier to document as you are doing it. If you are short of CPU, the divide by 2 is the way to go with a bit more documentation in your code.
 

Similar Topics

I cannot add SLC500 analog input tag (I: 8.3) to EZSeries Touch Panel Editor (V 5.3). I used all the listed tag datatype but it all says "Invalid...
Replies
10
Views
261
Hi guys, I have no experience when working with AllenBradley PLC, but I hope someone could clarify the result of multiplication shown in the...
Replies
14
Views
2,208
Trying to get data types (AS Structures) to update after a new tag import is made from PLC. WinCC can show red if an existing element was removed...
Replies
0
Views
278
Is there a way to use LREAL Data type on L71. I am getting 64 bit Double (IEEE754 Double precision 64-bit) data from a modbus device onto PLC via...
Replies
6
Views
963
Back
Top Bottom