Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Utilising NI-XNET with non-NI CAN modules (PCAN)

Hello everyone, 

 

I am currently trying to create a small test interface on Labview that will communicate with the hardware via CAN as a kind of stand-in for the wider system. The test interface has a number of controls and displays, the values of which are communicated with the hardware I'm testing. This is done via simulink and a .dbc file for managing the signals, with a Peak-CAN (or PCAN) USB module used between my desktop and the TI board. Previously, I have made similar interfaces using Peak's PCANBasic library for labview, where the modules have input/output of a single cluster, with each part of the cluster containing one section/byte of data (example of both below).

 

ahrem_0-1662384179448.png

This has worked well in the past with very simple CAN message structures, with each signal being a byte (or multiples) long. However, I am now looking to improve upon this method via .dbc files where the messages are different lengths across multiple bytes, as this speeds up development of the simulink codebase significantly. I'm sure I could manually do some bitshifting etc to achieve what I'm looking for, but that would seem like a huge amount of effort for code that would be very difficult to reuse elsewhere.

 

I have started using Hooovahh's code for CAN frame/signal conversions as this seems the perfect joining point between labview's built-in functionality and my own needs, however I am having trouble pulling the two together. I am trying to join together the PCANABasic library's read/write functionality with XNET's CAN Frame and its conversions, but struggling to understand how to use Hooovahh's code to manipulate the frames. If anyone can point me towards a more targeted example or provide some specific help, it would be greatly appreciated.

 

I am using LabVIEW 2021, with a PCAN-USB module.

 

Thanks for your help.

 

0 Kudos
Message 1 of 2
(2,022 Views)

Hello, Hooovahh here.  What issue are you having?  If you run the demo you can see that it first takes in a DBC that was included, then uses some values in engineering units, that are scaled, and turns them into the raw frames.  Then it changes those frames a bit, and converts them back into engineering units for the signals.  You can do the same here.  The only thing you'll have to do is change from one cluster type to the other, since the API for PCAN returns a different cluster, but one that contains the same data.  Like they have 8 U8 values, one for each byte of the payload.  But the XNet cluster instead uses an array of bytes.  So in this case you'll need to use something like a build array, to go to the XNet cluster, or index array to go to the PCAN cluster.  If you are familiar with what the data represents it shouldn't be hard to make a subVI that converts from one format to the other.

0 Kudos
Message 2 of 2
(1,988 Views)