LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to increase the speed of my producer loop?

Hi,
I try to monitor two CAN channels and to compare values online. That's why I use a producer loop to collect all CAN messages and a consumer loop to calculate some stuff. But the producer is to slow. The queues of my CANCard are full after some minutes. The queues are already set to maximum.
The first Channel runs with 500 kBit/s, the second one with 125 kBit/s.
Should I use two Producer loops or how can I increase the speed of my existing producer?
How should I handle the different speed of the channels?
Enclosed screenshots from my VI.
Thanks,
Thomas
 
 
Download All
0 Kudos
Message 1 of 5
(2,993 Views)
Thomas,

Instead of your producer loop running too slow, since the queue is filling up, it is very possible that the consumer loop is running too slow.  What kind of calculations are taking place?  Can they happen at 500 kBit/s?  If not you will never empty your queue.  You might try a couple of different things such as reading your data slower (not always an option I know) or splitting up the consumer into different tasks(multiple consumers).  I don't think you would need to have two different producer loops since your two readings are multiples of each other. 

Please let me know if you have any other questions!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 2 of 5
(2,929 Views)

Andy,
thanks for your support!

Goal of my project is to measure both CAN channels. Between these channels is a real electronic control unit (ecu) which is able to route CAN messages between the channels. My VI has to check weather the routing works fine or not.

Each message has an identifier and I kow which messages are routed. That means I have to measure both channels, look for routed messages and compare the data and the timestamp of the messages. I try that in my consumer loop. The data are stored in several 2d arrays. And I have to look for specific data in these arrays. I think the loops over the arrays are to slow. but I have no other chance - I have to buffer the messages somehow and then to compare by their timestamps to find the right order. But that's very difficult because the order of the messages in my producer queue is not ordered by the timestamp...
If you have any idea how to solve the problem better, let me know - I would be happy!

Thanks,
Thomas

 

0 Kudos
Message 3 of 5
(2,908 Views)
The CAN channels have a different busload. The speeds are 500 kBit/s and 125 kBit/s. Because of the different busload (it can change over the time) I should use two producer loops. Right? I'll try it.
 
If I have no "wait 1ms" in both producer loops - how can I give time to calculate to the consumer loop?
If I place a "wait 1ms" in my producer - it's to slow to collect the data...
 
Thanks,
Thomas
 
 
0 Kudos
Message 4 of 5
(2,890 Views)
Wait 0 ms will also allow the loops to share processor resources but will not cause delays (other than the function call overhead which is quite small).

Lynn
0 Kudos
Message 5 of 5
(2,887 Views)