Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-XNET C API for CAN Loopback Test - No Baud Rates Above 125k Work

Solved!
Go to solution

Using the NI-XNET C API Loopback Test Example, baud values of 125k or less work as expected receiving exactly what was transmitted. Whenever I change the baud rate in the CAN database to any value above 125k baud, the loopback no longer works (received payload is all 0's). 

 

Driver used: NI_XNET 20.0

Hardware used: USB-8502

Using this Example Visual Studio Project:

C:\Users\Public\Documents\National Instruments\NI-XNET\Examples\MS Visual C\CAN\CAN_Loopback_Test

Using this Example CAN Database:
C:\Users\Public\Documents\National Instruments\NI-XNET\Examples\NIXNET_example.xml

 

I tried setting the following properties as well to no avail: nxPropClst_BaudRate64  nxPropSession_IntfBaudRate64

0 Kudos
Message 1 of 12
(2,026 Views)
Solution
Accepted by topic author whoisjohngalt

Hi,

 

you need to add termination to your CAN bus, either with external termination resistors or by setting the XNET Termination property to enabled on your two sessions before writing anything.

Message 2 of 12
(2,025 Views)

Thanks that solved it! Should have read the comment at the top of the file.

 

// Please make sure that the bus is properly terminated as this example does not
// enable the on-board termination. Also ensure that the transceivers are
// externally powered when using C Series modules.

 

 

0 Kudos
Message 3 of 12
(2,013 Views)

Hi.

I have the 120Ohms resistor externally but, I still having the timeout. My usb8502 is one port only, should be this the issue? What is wrong? Thanks 

0 Kudos
Message 4 of 12
(363 Views)

You should make your own post. If you are new to CAN you should checkout my CAN Blog.

 

https://hooovahh.blogspot.com/2017/03/can-blog-introduction-and-downloads.html

 

0 Kudos
Message 5 of 12
(358 Views)

Does it work for you at lower speeds?

0 Kudos
Message 6 of 12
(354 Views)

Yes. I am new in CAN. That i why I am looking for answers to help me to understand. Thanks for the blog link I will read it all.Thanks 

0 Kudos
Message 7 of 12
(345 Views)

Semaren979_0-1723045788535.png

Semaren979_1-1723045905302.png

 

This is what I got from LabVIEW and the CAN 120ohm termination. is it ok?

Thanks 

0 Kudos
Message 8 of 12
(337 Views)

The example you showed will write on one port, then read it back on a second port that is wired together.  You only have one port, so I'm not sure what you were expecting to happen.  It timed out because it couldn't read anything.

0 Kudos
Message 9 of 12
(331 Views)

Hello.

 

Yes Hooovahh. At the beginning I was thinking about the second port but, I was expecting to see some response once I plugged the 120Ohm. As you may know I am a beginner and i am trying by practically to understand what is happening with this example. But It seems that it does not work. So, until I have a second port I will see the final response. 

0 Kudos
Message 10 of 12
(327 Views)