Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CAN hardware with 2 VI

I want to use my CAN hardware with 2 VI. Each VI will send and recieve CAN frames to CAN network. I must run once Cconfig and Copen VIs and  use Copen outs (ObjHandle out and Error out) in this 2 VI. How is Data communication among 2 VI? 
0 Kudos
Message 1 of 7
(7,457 Views)

Hello ismail505,

 

I'm not sure I understand what data you want to communicate to where...

 

Do you want to know how to write data from one CAN port to the other CAN port?

If so, then the data you use in the write VI will be written on the bus.  You can use the read VI to read it on the other CAN port.

 

If I'm not understanding correctly, can you explain what data you want to communicate between which 2 VIs?  You can even post a VI if you think that would help.

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 7
(7,441 Views)

I have NI USB-8473s CAN bus hardware. I want to use this hardware with 2 VI. First VI will communicate First microcontroller and Second VI will communicate Second microcontroller. I upload an image that what I want to do.

 

CAN.jpg

0 Kudos
Message 3 of 7
(7,432 Views)

Hello ismail505,

 

This makes more sense.

 

You will not be able to use the 8473 at the same time with 2 different VIs.  When you call the ncOpen function, the module is locked to that VI (or task) and you need to call ncClose to use it in another VI, or task.

 

That being said, you should not need 2 VIs to communicate to your 2 micro-controllers since they are both on the same CAN bus (according to your image).  They can both read and write to the 8473 and the 8473 can read and write to both micro-controllers.

 

Let me know if that clears things up.

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 4 of 7
(7,430 Views)
I wan to communicate 2 micro-controller. This micro-controllers are on same CAN-bus. But this micro-controllers controlling different systems. And this systems will controlled by different users at the same time. how can I do this?
0 Kudos
Message 5 of 7
(7,428 Views)

Well, only one reference to the device can be opened at once, so each VI will need to use this reference.  Calling read/write from 2 different VIs using the same handle/reference may not be very good. 

 

I would suggest building a lower layer VI that handles the CAN communication.  For example, if you read temperature using ID 1 for uC 1 and ID 2 for uC2, your lower level VI can handle the CAN communication and just set 2 global variables temp1 and temp2.  A higher level VI could just read the global variable temp1 and ignore temp2 (and also ignore CAN communication).  So, a lower level CAN communication VI that sets and read global variables.  Higher level VIs (controlled by users) that set and read globals.

 

You could also purchase another USB-CAN and connect each device to a single micro-controller...but that's more expensive and sort of defeats the purpose of having a bus...

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 6 of 7
(7,416 Views)

For example VI 1 send and recieve CAN bus messeges which has ID:1

VI 2 send and recieve messeges which has ID:2 how can I do this. Please can you sent me en example...  

0 Kudos
Message 7 of 7
(7,412 Views)