Example Code

Vector XL Driver - LabVIEW wrappers

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

VectorHW.pngOverview

Vector provides an API for performing low level control of their hardware.  The code posted here is primarily wrappers around their XL Driver APIs.  These functions come in the form of the vxlapi.dll, and vxlapi64.dll.

 

Description

Vector has some very nice products for testing vehicle communication buses such as CAN, LIN, MOST and FlexRay.

They sell some very expensive software and some reasonably priced hardware to go along with it.

You can buy just the unlicenced hardware and use the freely available driver that comes along with it in your own custom applications.

 

Requirements

Vector XL series hardware or VN series hardware and drivers installed.  This includes the older CANCase and newer VN16xx USB devices.

Windows Device Driver for the Vector hardware. Check if your device is recognized in Windows Device Manager.

LabVIEW 2018 or later for version 3.

Driver dll Download

The required DLLs are included in the version 3 zip.  For those that don't the instructions below are for acquiring these drivers.

 

To get the dll and driver go to the Vector download page and download it. Just be sure to choose the right options when finding the XL Driver Library containing the dll.

 

IGNORE THE LABVIEW DRIVER! It is quite restrictive, and requires a rather expensive license. 

From the download page select: XL Driver Library > Drivers & Firmware > All

Now click the button that says "Show Results...". You should now have a list of drivers available. Again, ignore the LabVIEW one. Download the XL Driver Library X.X.

 

Unfortunately the header file supplied with the driver dll doesn't readily import into LabVIEW. We had to make some significant modifications to it before it worked. Then I had to go through and make quite a number of corrections once it was done.

If you're curious the modified header file is called vxlapi3.h.

 

 

Here I just provide wrappers and an example or two to get you started. Below is one simple example of transmitting a CAN frame.

Version 3 Changes

Hooovahh has made several changes based on user feedback, and released it as Version 3.  The two main improvements to this version is to support CAN-FD reading and writing, and to support 64-bit LabVIEW as well.  A more clean example also allows for simple reading and writing of frames, along with reading analog and digital values on hardware that supports it.  

Version 3 Examples

 

 

Other Examples 

TransmitExample.png

 

The "Basic LIN test.vi" assumes you are using the LIN channel to monitor a running LIN connection. It works as a silent slave node on the network.

To actually receive any LIN frames there must already be a LIN master communicating with another LIN slave.

Basic LIN Test.pngVI in attached zip file.

 

"Simulate LIN network.vi" will transmit from one LIN channel set up as a Master node to other LIN channels set up to respond as Slave nodes.

There is now also a "Simulate LIN network -master transmit.vi" which allows you to transmit data from a Master to Slaves. (Remember that a master node MUST HAVE A PULL-UP!)

SimulateLINnetwork.png

CAN Receive example added due to popular demand (updated with documentation and code tidy):

CANReceiveExample.png

All example VIs and dependencies should now be contained in this latest zip file.

 

If you find any bugs or updates needed feel free to send me a message.

If you have a support request please post it in the LabVIEW Forum, NOT HERE.  I will get a notification and reply in the forum if you add vxlapi as a tag.

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Kdbrose
Member
Member
on

Hey Mr. TroyK

I m trying to interface your code with CANcaseXL.

With My ECU for LIN but the problem I m facing is that when I send header 1B to my ECU it show me response but at the same time my CANcaseXL error LED Flashes..so could you please provide the solution for it or could you also help me with error decoding code for LIN.

Joner
Member
Member
on

Hello everybody,

 

first of all many thanks at TroyK for offering these great working VIs!

 

I've a question depending the CANcaseXL interface, using CAN as bus type and the CANOpen protocol.

If I send e. g. a 601 SDO-Message read with the xlCanTransmit function, I receive with the xlReceive function the 601 SDO-Message and the related 581 SDO-Answer. That works fine, but I want to receive only the 581 SDO-Answer and not the original 601 Message anymore. With the xlCanSetChannelAcceptance and the xlCanAddAcceptanceRange it's only possible to fiter the SDO-Answers.

 

Is there a way to filter the Transmit messages?

Or am I wrong in using the filter functions?

 

Thanks for your help!

Best Regards,

Jonas

Joner
Member
Member
on

Hello again,

 

this could be done by switching off the receipts in the xlCanSetChannelMode-function (Tag for tx and txrq: 0).

 

Thanks to all

Jonas

梦魂飞
Member
Member
on

非常非常感谢您的分享,解决了我的大难题。“CANdriver_for_LabVIEW_EN”只能读写信号,无法直接操作帧数据,难以满足柔性化的应用需求。我不知道您是否可以看懂汉语,总之,thankyou!

stao7
Member
Member
on

Hello,

 

I greatly feel it is useful. and I try to use it.

But it fail:

1. when load it, display warning, Capture1.PNG

2. ID display 0x98FED980, and error code 6101

CAN Receive Example.vi<ERR>
vector xl driver error 101 XL_ERR_WRONG_PARAMETER


<b>Complete call chain:</b>
     CAN Receive Example.vi

alamanna
NI Employee (retired)
on
cwq421950415
Member
Member
on

Hello TroyK,

It's a great share, especially for LIN communication.

Recently I have a project refering to FlexRay communication. But I found only fer VIs in FlexRay folder.

So can you kindly share some FlexRay examples or more VIs if you have.

Thank you in advance.Smiley Happy

amit.bonage3
Member
Member
on
Hello, Anybody Tried writing data to DUT through VN1630A, using labview?
lello88
Member
Member
on

Hello,
I am new to the community and I am writing for information on the possibility of sending cyclic CAN messages with the Vector CANcaseXL tool (XL libraries).

Your work in Labview is very interesting, I am developing the same application in C # and what I am missing is a cyclic transmission that is precise, like the CANalyzer software.
I currently use a thread that compares the cycle time of each message in the list with the time since the last sending of that ID.
In these iterations, I lose something in terms of periodicity, and therefore I would like to know if there is a more efficient way of managing the transmission messages (e.g. cyclic transmission events).

Were you able to send messages cyclically? How?

Thank you for your availability.
Lello.

TroyK
Active Participant
Active Participant
on

@cwq421950415 Sorry, I haven't done anything with FlexRay.  The VIs included were automatically imported when I ran the dll import wizard on the modified .h file many years ago.  They were never tested. Try this forum thread: https://forums.ni.com/t5/LabVIEW/FLexRay-xlFrSetConfiguration-VI/m-p/3875133/highlight/true#M1098297

 

@amit.bonage3 VN1630 Could have CAN or LIN buses. I assume you're asking if you can send CAN frames out on a bus??? Yes you can (pardon the pun). "writing data to DUT" is dependent on the what is implemented on the DUT.

 

@lello88 The XL Driver Library does not have a built in method for scheduling cyclic messages in the way you're hoping.  You can set up timer schedules, but they only send timer events, it's up to you to then send an event. I get reasonable enough accuracy sending frames on a schedule. Not too much delay added by Windows OS, maybe 1 or 2 ms.

 

@all Please note the concluding statement in my example document...
If you have a support request please post it in the LabVIEW Forum, NOT HERE.  I will get a notification and reply in the forum if you add vxlapi as a tag.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
MARK
Member
Member
on

MARK_0-1620287799499.png

MARK_1-1620287839183.png

Hi 

I use "Can Receive Example" vi,but It show 6112 Error code,

How can i fix it?

Can you tell me the answer?

Thanks you!

 

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

I'm not certain, but an Invalid Access error might mean that you have the hardware reserved somewhere else.  You don't have CANalyzer running on this hardware at the same time do you?  Your hardware Index, and Hardware Channel could also be incorrect.  I'd check in the Vector Hardware tool to make sure the hardware is recognized. 

lolalilo
Member
Member
on

ToyK

 

I would like to combine the receive.vi and the transmitt.vi in one single .vi.

This .vi should be able to receive and transmitt can message in parallel. I dont't know how i can

Can sombody please help me with this problem or had somebody a complete .vi with this

features? I think it should be possible to receive and send in one .vi. OR not?

 

Best regards!

 

Luna

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

If you are trying to perform a CAN write, and then wait for a specific response, then I can see some value in a Transmit, that also has a Receive in it.  However to do this properly you'd want a way to specify what the ID of the response is expected to be, and then only return those, and then on the next read, return all the frames you read that weren't part of the filtered IDs from the last read, maybe with a VIG, or DVR.  When I made the ISO15765 set of VIs here, I created a state machine that would look for a response ID and return it after transmitting a request.

OBV10
Member
Member
on

Hi, 

I´m trying to connect LV with Vector but the truth is that im very new in this. 

I have 2017 LV version and i already install the XL driver but then i dont know how to run the files attached in the forum 

any help?