LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XNET CAN write error - two different type terminals

Hello everyone,

 

I'm really new to Labview and XNET CAN vi. I'm trying to interface with a board through CAN bus and I have to configure and set some parameters. As hardware I'm using a CAN HS/FD Interface NI-XNET USB-8502 and Labview version is the 2024. In attachment the .vi file! I tried to navigate through the examples and web forums but I'm still confused, also because all the examples are real time one while I have to run a software almost automatically so that all DBC data have to be...let's say hidden inside the VI.

As you will see I need to send as output quite a lot messages: some represent 1 bit signals of a DBC file, others signals of 1 byte lenght and still others 8-bytes frames.

VI_project1.jpeg 

I have three different question for you (a lot I know but I'm really a newbie):

  • First of all, when I try to manage frame signals I get the error: "These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
    The type of the source is 1D array of
    unsigned long [32-bit integer (0 to 4,294,967,295)].
    The type of the sink is 1D array of
    typedef 'XNET Frame CAN.ctl'
    cluster of 6 elements."

         As it is shown in the image below, the CAN frame "CeiSetValues" is an 8-byte frame.

VI_project1_error.jpeg

         What I need to do is to put at 0 the final two bites so I "prepared" an array of 64 elements (well I actually think I did but I'm also not so sure it is correct) but this seems to be incorrect

         because the Frame CAN sink needs (as it said)  a 1D array of typedef 'XNET Frame CAN.ctl' cluster of 6 elements.

         Now, what i didn't get is that it is asking for a cluster of 6 elements...I mean, it is a 8-byte frame, where this "6" comes from and why "cluster"? Except for that, I would also like to ask (this

         is not trivial because I'm pretty sure that putting those bits at 0 is ok) if there is a way to leave "untouched" the firsts 6 bytes of the frame. I put them to 0 to and it shouldn't really change

         anything otherwise the only thing that comes up to me is to make 16 signal-out sessions for the 2 last bytes (not elegant and a bit boring)

  • Second: the three signals "PowerMeter_" are 1 byte multiplexed signals, the first is put to 1, while the second and third to 2 (all decimal). Below is shown an example from the DBC.

VI_project1_PMsignal.jpeg

          I would like to understand if it is possible to use the signal-single point write funciton and the constants array as I did. 

  • Finally, linking back to the previous question, it is correct what I have done for 1 bit signal, I mean, using costants array and Signal single point write function? Fow example, in the first block case I'm setting to 1 all four signals right? (Just to be sure it is possible to do that way)

I'm so sorry to ask you all this things, also because maybe those are stupid but I'm really in hurry and I cannot get lot of informations about CAN driver in Labview.

Any help will be much more than appreciated, and also any Labview tips.

 

Many thanks

0 Kudos
Message 1 of 5
(402 Views)

Hi gcambie,

 


@gcambie88 wrote:
  • First of all, when I try to manage frame signals I get the error: "These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
    The type of the source is 1D array of
    unsigned long [32-bit integer (0 to 4,294,967,295)].
    The type of the sink is 1D array of
    typedef 'XNET Frame CAN.ctl'
    cluster of 6 elements."

         What I need to do is to put at 0 the final two bites so I "prepared" an array of 64 elements (well I actually think I did but I'm also not so sure it is correct) but this seems to be incorrect

         because the Frame CAN sink needs (as it said)  a 1D array of typedef 'XNET Frame CAN.ctl' cluster of 6 elements.

         Now, what i didn't get is that it is asking for a cluster of 6 elements...I mean, it is a 8-byte frame, where this "6" comes from and why "cluster"?


That XNet function expects a cluster that defines a message frame. That cluster contains 6 elements, among them ArbID, timestamp and message payload data. You cannot wire a simple array of 8 bytes when you need to provide a full message frame!!!

Best regards,
GerdW


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

I recommend you get familiar with those concepts:

  • Differences between signal and frame sessions, and how to convert between them using conversion sessions. Explore all shipping examples.
  • Write CAN VI requires an array input. Learn how to use an indexed for loop or index array and build array.
  • Learn how to use Unbundle By Name and Bundle by Name to access and overwrite the 'XNET Frame CAN.ctl' cluster.

 

Next to your question.

  1. Simply add the signals of the 0th to 5th bytes to the signal output session. The default value (usually zero but double check the dbc) will be used in the frame for the not added signals. In short term, ignore them if you want them to be zero.
  2. That looks correct.
  3. Correct and it is designed to be that way.

A few more advices to your VI:

  • All of your XNET Create Session VI should be moved outside and before the while loop. They only need to be called once.
  • Use Merge Error to combine all error wires into a single Simple Error Handler. You will be annoyed by the multiple popups if there are errors.
  • Use a OR node on the error wire and stop button, such that the VI will be stopped if there is any error. Otherwise, the Simple Error Handler will keep popping the dialog.
-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 3 of 5
(344 Views)

Many thanks Zyong!

I studied a litle bit and stood several things! Thank you for your advices!

Anyway, I am stuck with another issue which I really cannot go through. I would like to have a "IF CASE" for which the payload of a given frame is shown from the CAN stream. As it is shown in the pictures below, I would like to retrieve only 2 Frames from all over the CAN Cluster, which IDs are "1368" and "261" decimal. 

hex_case.jpg

dec_case.jpg

 The program works but as you can see, IDs and Payloads requested aren't shown ever even though I could see those frames to come into the table. I tried to switch one case in dec number thinking thta it could be the problem but nope...

front_panel.jpg

And of course I'm selecting the ID and payload from Cluster table because if I put those indicators outside the case struct they show me all the stuff!

Anyone can help me understanding?

 

many thanks

0 Kudos
Message 4 of 5
(154 Views)

This is what I usually do to keep the frames with the desired IDs.

ZYOng_1-1749817576134.png

 

 

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 5 of 5
(127 Views)