LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to divided hex integer string in to substring and convert in to integer bytes and send through can 9853.

Solved!
Go to solution

Hi

i have created a data string of 17bytes for can implementation.i am using can 9853 module.but can will support only 8 bytes of data.so i want to divide this 17bytes into 8bytes+8bytes+1bytes and want to send through can port to external device(testing device).and i want to send these three separate bytes within 200ms.how to do??i have attached vi and screenshot .

Download All
0 Kudos
Message 1 of 12
(4,487 Views)
Solution
Accepted by Risuraj

Hi rishijha,

 

why are you still using hex-formatted strings instead of plain U8 arrays?

I thought you already learned that in your last thread

 

When those 17 bytes are your (CAN message) payload then please keep this in an U8 array:

check.png

 

so i want to divide this 17bytes into 8bytes+8bytes+1bytes and want to send through can port to external device

All you need to do is to use ArraySubset three times and build 3 CAN messages from the 3 parts of your payload…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(4,458 Views)

 

When those 17 bytes are your (CAN message) payload then please keep this in an U8 array:

but my can payload is U-64 bit integer as u can see in screenshot.so i have to divide 17 byte of data in to 64bit+64bit+8bit.

my payload is combination of  2Byte+2Byte+4Byte+2Byte+3Byte+4Byte=17Bytes.

why are you still using hex-formatted strings instead of plain U8 arrays?

what is the problem with my method.any way my payload is in hexadecimal.

 

0 Kudos
Message 3 of 12
(4,448 Views)

Hi rishijha,

 

what is the problem with my method.any way my payload is in hexadecimal.

It's overly complicated (aka Rube-Goldberg)!

Your data is not "hexadecimal" - that is just the display setting in the frontpanel! The underlying data are just bytes (or 64bit entities), no matter how you display them…

Additionally you will have even more problems to convert your hex-formatted string back into U64 data.

 

but my can payload is U-64 bit integer as u can see in screenshot.so i have to divide 17 byte of data in to 64bit+64bit+8bit.

Why didn't you say so in your first post? It's quite annoying when you change your requirements after getting answers…

check.png

Once you understand what I'm showing to you you can combine my snippets in this thread to directly create 3 U64 values instead of that intermediate 17-byte array. Good luck!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(4,434 Views)

Hi

GerdW,

I am sending that 64it+64bit+8bit from CAN port0 to CAN port1 @1000ms continuously.when i am sending first 64bit from port0 i am able to receive same 64bit at port1.when sending 2nd 64bit i am receiving same previous 64bit why??when 3rd 8bit will write to port0 that time i am seeing 2nd 64bit.so it looks like one frame is pushing another frame.so this the problem or something else??

0 Kudos
Message 5 of 12
(4,401 Views)
Solution
Accepted by Risuraj

Hi rishijha,

 

so it looks like one frame is pushing another frame.

I never had that problem with all those NI9853 modules I used so far…

 

so this the problem

No.

 

or something else??

Yes.

(I guess your VI is the problem. But again you didn't attach it…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(4,397 Views)

Please have a look on attached file.another vi i am using basic can fpga example from example finder.so please tell me where is the problem with real time vi.

0 Kudos
Message 7 of 12
(4,390 Views)

Hi rishijha,

 

unfortunately I didn't find any "basic can fpga" example in the example finder, so I cannot see what's going on in the FPGA part of the code…

(You still don't use that AutoCleanup button a lot, don't you?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(4,386 Views)

now i have attached both.check once.

Download All
0 Kudos
Message 9 of 12
(4,382 Views)

Hi rishijha,

 

are there any CAN bus errors?

 

- If I recall correctly you get some "echo" messages from those 9853, but as I filter CAN messages in the FPGA I only receive those messages I'm interested in.

- To check CAN bus communication independently from any other device on the bus I use something like this. So I'm always sure about messages sent on the CAN bus! I really recommend to use such devices when doing any work involving CAN bus…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 12
(4,378 Views)