Hello,
I'm having a timing issue in a CAN application that I wrote. The application takes a list of CAN messages selected by the user and writes them to a PCI-CAN/XS2 card at specified rates, also selected by the user. The CAN code is running on an RT system. The hardware timing looks like it's working great when I monitor is using MAX Bus Monitor, but I noticed that the write loop, which I have set to run at 10ms, doesn't always run at 10ms. It alternates between 10ms and another number, which depends on how many messages I'm currently writing. For example, if you've selected 3 messages, the loop timer will alternate between 10 ms and 1510 ms back and forth. If you select to write 2 messages, it alternates between 10 ms and 160 ms. Sending 1 message, it will run at 10 ms. So even though the hardware is doing its job and sending out the messages each at their specified rates, the software loop will be slowed down occasionally and the user values will not go out to the hardware as fast as I'd like them to.
I do have a few other things going on inside my write loop, but I've tried disabling everything but the CAN Write VI supposedly to lighten it up, but I still get the same behavior. So, I did the opposite - I disabled just the CAN Write VI, and the loop runs nicely at 10 ms.
Previously I had written the CAN application to send out all the messages at the same rate of 100Hz, but I had never had such a problem. I'm thinking that the CAN Write VI doesn't like to be called this way. I had been trying to follow an example by NI, except I need to always update the write values. I've posted images of my two CAN applications and the NI example I started with.
I hope someone can shed some light for me!
Thanks,
Sima