Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I optimize this CAN program?

I currently have the program called "GCS message.vi". It reads CAN messages and has the ability to alter them. It then resends the CAN messages out. "GCS message stim and monitor.vi" runs with this, but does the opposite. It sends out messages, and then monitors the ouput of "GCS message.vi". This program runs at only a couple of Hertz, but when all the CAN programming is eliminated, the program runs extremely fast. And if all the excess programming is eliminated leaving only sending and receiving of CAN messages, then the program runs extremely fast again. I'm wondering what aspect of the program is slowing everything down and how I could program around it.

Notes:

The stim and monitor should be run first, and the start button on the VI should be pressed once the message vi is running.

To check the execution speed, put a value in the "Inject Selected Errors" box and click the button next to it. It will countdown to zero.
0 Kudos
Message 1 of 2
(3,435 Views)
Hello,

As you have noted, your problem seems to be purely LabVIEW. When you run with just your CAN commands, things are fast. One thing to note in your program (looking in CGS message.vi) is the large number of property node accesses; each access to a property node will cause a thread swap to the user interface (in the event that multiple threads have been spawned, which appears likely since you define multiple parallel tasks). Given that you have a relativel complicated GUI there, this may indeed affect performance significantly. In general, you should (if at all possible) use wires to dictate value assignment, and if necessary you may try changing the some of your property nodes (the ones that simply change the value of a control or indicator) to local variables to prevent the thread swapping. Now, this may not be the only performance enhancement to make; I would strongly recommend reading the following document to help get a better idea for how to find and correct memory and time performance issues in LabVIEW:

http://zone.ni.com/devzone/conceptd.nsf/webmain/732CEC772AA4FBE586256A37005541D3

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 2
(3,410 Views)