LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer consumer loop error

Hi There

 

Im really new to labview and currently studying for the CLAD exam,

I have completed all of the Core 1 and Core 2 modules and as such I am trying to get a bit of practice using them in our situation at work.

 

I am creating a program which will receive data from an SCXI thermocouple card read the data process it and eventually save it.

 

Currently we use a stacked sequence structure to process the second half of the code which times all of the raw voltages by 1000 (In the end this will be a calibration section I am simply using the x 1000 as a trial). As I understand the stacked sequence executes each of the tasks sequentially in a fast loop where as I have tried to include a Producer consumer loop to only do the calculations when the data becomes available.

 

Unfortunately I am having errors returned once the program is run either about out of available space in which case it enters into a cycle which I cannot exit or says data "becomes" not available.

 

I have attached my code to this post any help would be more than appreciated.

 

Sorry to have been so waffly I hope my explanation is suitable.

 

WARNING it does lock the PC when not in execution highlighting mode!

 

 

0 Kudos
Message 1 of 4
(2,569 Views)

1.  Your loops run forever.  That is BAD.  You need a way to gracefully stop your VI.  And using the ABORT button does not stop your VI gracefully.

2.  You have race conditions as you pass data between loops with local variables.  You are very likely to have a data loss with that setup.  You should be passing the data around with a Queue.

3.  Your consumer needs to be in separate loop than the one producing the data.  What you have is a loop that is constantly putting in the same data into the queue.

4.  Your subVI can be greatly simplified if you would have just left the data as an array.  Use a FOR loop with autoindexing and the conversion VI inside of it.

5.  Instead of 32 indicators for the thermal couplers, just use an array.  It is so much easier to deal with.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(2,539 Views)

Hey crossrulz

 

Thanks for the reply, the code is for a continuously running test rig so in the end will be used to log data, does this not mean I have to have my conversion loop continuously running?

 

Sorry to be a bit slow, I understand everything you have said individually but I dont know how to go about applying this changes to the code as I am still learning I am finding it difficult to "think" in the way that labview codes.

 

Would you be able to suggest the first steps and I will try and make a start from there?

 

Thanks

 

Alex

0 Kudos
Message 3 of 4
(2,521 Views)

Did core 1 and 2 not cover some basic consumer/producer approaches to acquisition and processing of data? I would recommend searching and studying the NI Examples to learn about the benefits of the various design approaches you can implement.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 4 of 4
(2,483 Views)