Advanced CAN Frame to Channel Conversion Reference Example
The CAN Frame to Channel Conversion Example is a set of open source VIs for converting CAN frames to scaled channel data.
Table of Contents
This example shows how CAN frames can be converted to channels providing a high level organization to CAN applications. It is specifically written for use with the NI 9853 CAN module in a cRIO platform, but could be modified for other NI CAN devices and platforms.
It is recommended to use the “Frame Channel Conversion Library” or the NI-CAN Channel API when possible as these API’s are generally faster, more complete, and better tested. Benefits currently specific to using the Native LabVIEW Frame to Channel Conversion Example include:
• Support for mode depended channels on cRIO
• Open source CANdb (Vector database) and NI-CAN database file parsing
• Open source frame to channel conversion
This example is a CAN datalogger utilizing a cRIO controller and the NI 9853 CAN module. It consists of two main VI’s. The “CAN Channel Data Import.VI” (CCDI) and the “Frame to Channel Conversion.VI” (FTCC). The CCDI parses CAN database files into a LabVIEW structure (cluster) that other VI’s can easily interact with. CANdb or Vector files (.dbc) as well as NI-CAN database files (.ncd) are supported. Figure 1 shows the cluster into which the CAN database data is organized.
Figure 1. LabVIEW cluster containing all CAN message and channel data.
The cluster represents one message with an array of channels within each message. Multiple messages would be contained in an array of the cluster. This framework provides a way to add other details to the code if needed. The cluster is saved into a file that the FTCC uses to process raw CAN frames into scaled channel data.
Figures 2 and 3 show the front panel and block diagram of the CCDI. To import the CAN channel data, the user selects a CAN database file which is then parsed and presented in a table format. The messages of interest can be selected which are then saved into a file for the FTCC to use.
Figure 2. Front Panel of CAN Channel Data Import.VI
Figure 3. Block Diagram of CAN Channel Data Import.VI
The FTCC VI converts raw CAN frames to scaled channel data using the previously organized message cluster. This example is setup to process frames as they arrive, but could be re-organized to post process frames if desired. Post processing would reduce CPU utilization and allow faster CAN frame capture. Figures 4 and 5 show the front panel and block diagram of the FTCC VI.
Figure 4. Front Panel of Frame to Channel Conversion.VI
Figure 5. Block Diagram of Frame to Channel Conversion.VI
The software supports only Intel and Motorola Forward byte ordering when parsing CANdb files and does not support all CANdb functionality. Channel to Frame conversion (writing CAN data) is not supported in this example.
National Instruments respects the intellectual property of others, and we ask our users to do the same. The use of the SOFTWARE is intended only for use with content owned by the user, public domain content or properly licensed content. By downloading and/or using the SOFTWARE, you agree that you shall only use the SOFTWARE in a manner that complies with all applicable laws in the jurisdictions in which you use the SOFTWARE, including, but not limited to, applicable restrictions concerning copyright and other intellectual property rights.
Application Software: LabVIEW Full Development System 8.5
Toolkits and Add-Ons: LabVIEW Real-Time Module 8.5, LabVIEW FPGA Module 8.5
Hardware Group: CAN, CompactRIO, Real-Time (RT)
Hardware Model: NI 9853
Driver: NI-RIO 2.3.1
Reader Comments | Submit a comment »
Is there any possibility to convert this
nice example to LV7.1??
- firstname.lastname@example.org - Jun 11, 2009
What a mess !
I was expecting a neat packaging which would just require me to drag a directory to my project (maybe called "lib") and use a couple of VI with *relevant names* (from a subdirectory maybe called "API"). If needed do some side application with VI in a "tools" directory.... Instead there is a big pile of ... hum, well you see my point. I will loose a couple hour know trying to figure how integrating this in my project in a clean way (isn't it the purpose of a library ?). Common NI, after few years of using your stuff, I wasn't expecting this non-sens from you !
- Etienne ZIND, University Technologi Malaysia. - Feb 19, 2009