LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Labview drivers for USB-CAN Adapter

nathand,

 

I guess I have to rephrase the question. I've read the CAN protocol basics. I know that the devices on the network receive all transimitted messages on the bus. However, if you want to create a vi to display updates/outputs from the different nodes on a single GUI, sort of like connecting each node on the bus to a separate channel on a scope. How would you go about doing that?

 

Thanks

0 Kudos
Message 11 of 22
(3,574 Views)

Wadel wrote:

I guess I have to rephrase the question. I've read the CAN protocol basics. I know that the devices on the network receive all transimitted messages on the bus. However, if you want to create a vi to display updates/outputs from the different nodes on a single GUI, sort of like connecting each node on the bus to a separate channel on a scope. How would you go about doing that?


Hard to answer this without knowing anything about the devices.  Do you have several of the same device, or are the devices all different?  What do they measure?  Do they send data in the same format?  Does each device transmit on a different (set of) arbitration IDs, or does the data contain some indication of the source?  Are you only receiving data from the devices, or you also need to send commands to them?

 

How do you picture your interface?  How many devices?  If you have several temperature sensors and they all send data in the same format on different arbitration IDs, you might want to plot each temperature as a separate line on the same graph.  On the other hand, if the devices are all different, you might separate them onto different tabs or different quadrants of of the screen.

 

I'm unclear if you're asking a specific technical question about a particular CAN interface, or a more general question about user interface design.

0 Kudos
Message 12 of 22
(3,551 Views)

Nathand,

I think I went a bit too far. I have 3 different devices with 120 Ohm termination at the begining and at the end on the network cable. They all measure voltage, current and temperature as well as some digital status bits.  I have a CAN utility have been implemented previously in a different programming language but and I'm trying to replicate it with labview so I can add more functionality and manage it better. I've been reading through the NI CAN SW and HW manual. From what, I know so far, the utility has just a pair of send and receive arbitration IDs that use mode dependent channels. You can send commands but it is mostly to receive data from these devices. 

 

The interface contains different quadrants on the screen for each device. 

 

My question is more about the CAN interface not the GUI. The ultimate goal is to create a VI that monitors these devices and send commands through the user interface.

I have to use the labview usb-can dll to do this because I don't have NI HW. 

 

How would you implement CAN 256 and 257 virtual interface in such a VI that uses these usb-can functions? These functions do not have defined CAN interface like like CAN0, CAN1 etc.

 

If you any example VIs that will be great. 

 

Thanks

 

0 Kudos
Message 13 of 22
(3,543 Views)

Hi Wadel,

 

The NI-CAN drivers and dlls were not designed to work with 3rd party devices.  They were only designed to work with NI hardware.

 

Regards,

 

Dayna P.

Applications Engineer

National Instruments

0 Kudos
Message 14 of 22
(3,520 Views)

Wadel wrote:

How would you implement CAN 256 and 257 virtual interface in such a VI that uses these usb-can functions? These functions do not have defined CAN interface like like CAN0, CAN1 etc. 


Have you installed NI-CAN?  This isn't as complicated as you seem to think it is.  You would do something like the screenshot below (somewhat simplified and untested since I put this together in less than 5 minutes).  Ignore Dayna's comment - you can use the NI-CAN virtual interfaces without any NI hardware, and in fact this process is explained in the documentation.

using virtual CAN device for frame-channel conversion.png

I didn't spend much time researching PCAN, maybe there's more than one, but if you're using one from PEAK System, it looks like they supply their own LabVIEW library.  You may want to use that instead, or their .NET interface (which you can access from LabVIEW).

0 Kudos
Message 15 of 22
(3,517 Views)

Nathand

 

Thank you so much for this. This last response from you has cleared a lot of fog. Yes I've downloaded NI CAN that has the 256 and 257 virtual bus. However, I do have more questions and I will start with the screenshot.

 

 

1) You set the Message Type to RTR in order to send a remote frame to the Network interface. On the initStartTask, you then specify a channel or list of channels to read if a database exists, right?

 

2) Like I mentioned in my previous post. If I want to display, say for example, the voltages, currents and boolean status bits for each of the three different devices on the network, how would you implement it in code?  

 

3) How would you identify each device on the network in the code?

 

4) Would it be better to have a pair of command and response frames (arb IDs) and then create mode dependent channels since there many signals to monitor?

 

5) What sort of design pattern would you use? Parallel loop/master-slave design pattern?

 

Again your last response clarified so much for me. A general description should suffice and any screenshots would be great. 

 

Thanks

 

 

0 Kudos
Message 16 of 22
(3,510 Views)

Wadel wrote:

1) You set the Message Type to RTR in order to send a remote frame to the Network interface. On the initStartTask, you then specify a channel or list of channels to read if a database exists, right?


The code I posted only sets the IsRemote input to 1 if the incoming packet from the real interface has the RTR bit set, and I only added that for the sake of completeness, to show how you would make sure that the packet sent on the virtual interface is identical to the packet received on the real interface.  It is, however, highly unlikely that your devices ever send a packet with the RTR bit set, and you should probably just hard-code that to 0 or leave it unwired.


Wadel wrote:

2) Like I mentioned in my previous post. If I want to display, say for example, the voltages, currents and boolean status bits for each of the three different devices on the network, how would you implement it in code?  

 

3) How would you identify each device on the network in the code?


Too many missing details to answer these questions.  Do you have to send a request to the device in order to retrieve data, or do the devices stream data constantly?  Do you have control over the format in which the devices send data?  The only way you'll be able to identify each device is either by arbitration ID, or possibly by information inside the data packet itself (but arbitration ID is preferable to avoid conflicts).  If you have no way to assign a unique ID to each device, then you're out of luck - you cannot put them on the same CAN network.  However, since messages in a CAN database are defined by arbitration ID, if you do have multiple devices sending the same data on different IDs, you might want to reconsider whether using channels is the best way to handle the data.


Wadel wrote:

4) Would it be better to have a pair of command and response frames (arb IDs) and then create mode dependent channels since there many signals to monitor?


I can't answer this question; again, it depends on your devices.  If you (or a coworker) are writing the code that runs on the device as well, then it's up to you to work out the best format.  If you don't have any control over the remote devices, then you're going to use whatever the device uses.


Wadel wrote:

5) What sort of design pattern would you use? Parallel loop/master-slave design pattern?


As above - not enough details.  If your needs are fairly simple - say, the devices stream data constantly and you just need to chart the data - then a single loop in which you read the most recent point from each channel and add it to the graph might be enough.  If your needs are more complex, you might need more loops.  It's not very helpful to throw out names of design patterns without considering how they'd be used.  If you used a master/slave pattern, what would be the master and what would be the slave?  What data would be exchanged between them?  Start with the goal and then pick an appropriate pattern.  You wouldn't pick up a hammer first, then try to use it for a job that requires a screwdriver; same goes for software architecture.

0 Kudos
Message 17 of 22
(3,507 Views)

Sometimes I will need to send a request to set output voltages on the different devices but the aplication will mostly be receiving data updates from the network. That is why I mentioned the design patterns so I'd have an interactive vi while recieving data at the same time.  

Can you explain what you mean by having control over the remote devices on the network?  I'm wondering if I should assign separate arb IDs for the different devices and perhaps create mode dependent channels for each ID? 

 

Thanks

0 Kudos
Message 18 of 22
(3,503 Views)

@Wadel wrote:

Can you explain what you mean by having control over the remote devices on the network?  I'm wondering if I should assign separate arb IDs for the different devices and perhaps create mode dependent channels for each ID?


I mean, do you have the ability to determine the format in which the devices send data to your computer?  You can create the channels however you want in your code, but if that's not the format the devices then those channel definitions will be useless.  It would be reasonable to assign each device a unique arbitration ID, then use a mode dependent channel for the data - but the device has to provide the flexibility for you to do that.  If you don't have that level of control, then you need to set up your code to read the data as its sent by the device.

0 Kudos
Message 19 of 22
(3,491 Views)

My dear friend, I have the same problem with CNUSB adapter. Would you please help in communicate between LABView and a LXM32iCAN, BMi motor. Also please send me the labview VI you have already send as an image that one using CAN256 and CAN257. Thanks

0 Kudos
Message 20 of 22
(2,792 Views)