LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA-CAN data conversion problem

Solved!
Go to solution

How do I convert 32 bits of data to 16 bits and 16 bits?

 

Eg:-

My first input is 1000 in i16 format.

My 2nd input is 1000 in i16 format.

 

When i send this in CAN the the can data received from FPGA is in format of 32 bits.

 i.e the value is coming as 3892570115

 

How do i convert the above number back to 1000 and 1000??

 

Input:-

Byte0=1000

Byte 1=1000

Output:-

3892570115

 

Convert the output(3892570115) back to input as mentioned above.i.e 1000 and 1000

0 Kudos
Message 1 of 4
(2,881 Views)

Think in binary:

 

1000d = 0000 0011 1110 1000 Binary

 

3892570115 in an unsigned decimal, 32 bit = 1110 1000 0000 0011 1110 1000 0000 0011 binary

 

So I think the issue is with the endian format of the data, you need to swap the byte order of i16

 

0 Kudos
Message 2 of 4
(2,853 Views)
Solution
Accepted by topic author Dhrubajyoti

Here are some simple VI's that I use in my CAN communication.  You can see the conversion from U32 to U8's and vice versa.  The U16's are a step along the way.  One of the VI's shows how to handle negative numbers.  These are all in LabVIEW 9.0.1.

Message 3 of 4
(2,834 Views)

Thankyou so much..

 

The problem is resolved

0 Kudos
Message 4 of 4
(2,818 Views)