LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Kvaser CAN bus interface

Solved!
Go to solution

Hi,

I am trying to interface Kvaser Leaf Light v2 with Labview. 

I followed the following instructions to install the labview drivers

https://www.kvaser.com/knowledge-base/how-to-install-labview-drivers/

I can able to see my device connected to my PC using the Kvaser device guide application. Attached is the picture. 

When I try to run the kvCanExample1.vi that comes with the LLB manager I get some error as the parameter is not set. 

Is there any tutorial or users guide to learn how to use the Kvaser Leaf Light v2 with Labview ?

Do I need to user NI-VISA for interfacing the hardware with a different vendor ?

I have installed the dll that comes with the kvaser library installation. What this library is for and how do i open the file ?

 

Download All
0 Kudos
Message 1 of 6
(6,727 Views)

You get some errors, what are these errors? 

How are you using the vi's? 

What have you set the controls to? 

0 Kudos
Message 2 of 6
(6,691 Views)

VISA isn't part of the Kvaser drivers, all that is needed is the DLL and the VI wrappers.

 

 

You may want to run the Get Number Of Channels, to see how many are returned.  The example shows how to initialize Channel 0 or Channel 1 but if your hardware is having problems being recognized this likely won't work.  What function returns the error?  Is it on open, write, read, etc?

 

You may also want to look into my collection of 3rd party CAN drivers found in Part 4 of my CAN Blog post.  I don't spend much time talking about Kvaser but I do include a package with drivers which should just work, but really are just cleaned up versions of the stuff from Kvaser, and put on your palette.

0 Kudos
Message 3 of 6
(6,690 Views)

@dkfire

@hoovahh

 

I didnt mention more about the errors as I didn't understand what's going on .

The error is on kvCanAccept.vi

It says error -8 the parameters are not set. 

Previously the accept flag was set to 1 for some reason and I removed it now. 

it's working but i still didnt understand any of the vi's as there is no description in labview for the vi's. 

There is only one channel (Channel 0) which i came to know from the product manual. I also tried channel 1 during executing the vi but it thrower some error. So I guess there is only one channel. The error is -3 specific device is not found. 

Attached is the screen shot of the parameters that i set in my front panel. 

The parameters are copied from my colleague's vi and I found no error. 

Could you please give me short description of these parameter's.

Example

if I highlight Exclusive what would happen and why it is used ?

what are #1 to #8

 

I went through the Introduction to the Controller Area Network fro Ti but I still need bit more examples of CAN messages. 

0 Kudos
Message 4 of 6
(6,678 Views)
Solution
Accepted by VikashKumar23

The drivers I linked to have descriptions for each function, but I believe most of the VIs already had descriptions. 

 

The Set Accept ID is used as a filter so that IDs only matching the filter will be returned.  An Accept Flag of 1 means Set Standard Mask, and then the Envelope Mask code is used where the bits that are a 1 in the Mask, will be used.

 

So for instance lets say I know my CAN bus has lots of traffic.  But the device I care about will only be sending data on ID 0x123.  I can set the Accept Flag to Set Standard Code, and Envelope Mask or Code set to 0x123 and now only the 0x123 ID will be read and all other traffic is ignored.  Or lets say my device only sends traffic on IDs where the least significant bit is a 1.  So this might be IDs like 0x1, 0x3, 0x5, 0x7, etc.  Now set the Accept Flag to Set Standard Mask, and set the Envelope Mask or Code to 0x1 and only IDs that have a 1 will be read.  In most cases you just want all traffic and don't want to use a mask.

 

I believe Want Exclusive is for getting exclusive access to the hardware, locking out other software until that reference is closed.

 

Extended I believe is for enabling extended IDs beyond the 11 bit standard IDs.

 

Virtual allows for opening virtual hardware allowing you to write software without needing the hardware.  Kvaser drivers install two virtual CAN devices to talk to.

 

Baud rate is the rate of CAN communication and needs to match your devices on your bus.

 

Bus on is for starting and stopping the bus communication.

 

Message ID is the ID or Arbitration ID, along with the 8 bytes of payload.  The DLC is the actual length of data going out so you can set that to 7 and the #8 value will be ignored.  Sending on that data you also have things like is this a Standard ID, or Extended?  Is this a Standard, Error, or Remote Frame, and optionally a high voltage Wakeup for single wire CAN.  Lots of this is covered in Part 1 and Part 2 of my CAN blog, and the CAN bus Wiki page.

Message 5 of 6
(6,670 Views)

Thanks for your detailed explanation. 

Let me have a look at your blog. 

 

0 Kudos
Message 6 of 6
(6,662 Views)