Example Code

Programmatically Write To The BTR Registers With NI-CAN

Code and Documents

Attachment

Introduction

While most CAN devices work with the standard baud rates that NI-CAN supports, sometimes you need a custom baud rate or sometimes you need to modify some other timing settings such as the sync jump width (SJW), the time before sampling (TSEG) or Sample Point. Using the ncSetAttr.vi function, you can programmatically set the Bit Timing Register Values.


Read these KnowledgeBase articles for more details:

KnowledgeBase 0ZEF3MHR: How Can I Set Nonstandard Baud Rates in NI-CAN?

Tutorial: How to Configure CAN Ports for Custom Baud Rates

Additional Notes

It's important to note that if you are trying to set a standard baud rate, you can set the baud rate as a decimal value, and can pass that value directly.  However, to set any value other than the standard values requires that you follow the steps found in the KnowledgeBase given above.

hex.png

BTR1.png

Also, note that you can use the port Settings in MAX to view and modify these Bit Timing Registers. This interface provides a little more insight into what the bits represent.

Thanks!

---

Peter Flores
Applications Engineer

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

Contributors