LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need your help - what is the best concept for my project?


Hello,

 

I have used LabVIEW every now and then in the last years and learned it by doing. Last week I have attended the LabVIEW Basics II course to improve my programming skills and it was really worth it.

 

Currently I have to programm a test bench control program.


Before I attended the course, I had already written a program, which works, but the performance was not so good. Reasons were: 1. Too many local variables, 2. program structure was mostly sequencial

 

So with my new skills I want to improve that program, but I don't really know how - I am confused, there are so many posibilities and I fear to do it wrong again.

The program has to poll 12 digital input chanels, 8 analog inputs, 4 DMS chanels and has to control 16 digital outputs and 2 analogue outputs.
A period time of 50 ms is mandatory.
There is also a user interface and a chart to display measurement data, a table where the user enters his test sequence and sometimes measurement data have to be saved on the hard disk.
The basic cycle should be: poll inputs - process data - apply outputs

Attached you find my vi with a simplified scheme, so that you can see my idea of structuring the program.

Is that concept ok or is there a much better way?

 

Instead of one huge sequence, I created loops and events.

Loops:
1. poll DMS chanels
   poll analogue In
   poll digital In
   apply analogue outputs
   apply digital outputs
2. process data 

 

Events:
1. Save Data
2. send data

 

Data:
I send some measurement data from the source to the consumer loop by a queue. I don't know if that is a good idea. There is a lot of data to be exchanged between the loops. Should I always use queues? If yes, then the VI will be full of queues. I liked the local variables much more 😞
And I am not sure if it's ok to have the data output in an event case. maybe it is better to put it in a loop and block by a semaphor until new data is available to send?

I have heard, that the block diagram should not be bigger than the screen. How do I achieve that? Even my little program is bigger than the screen and I am already using sub VIs.

Please have a look on my VIs (testbench_control.vi is the main-VI) and help me improving it. In the vi you will find some more coments. You will notice that the program does not do what I want... 

 

I will post the VIs in the next message!

 

Greetings
Johannes

LabVIEW 7.1

Message Edited by johanneshoer on 10-01-2009 08:01 AM
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 1 of 54
(3,795 Views)
 
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 2 of 54
(3,781 Views)

wait a second... I have found a mistake. I need to set the timeout to 0 otherwise the program hangs up.

i will upload a new version in a minute...

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 3 of 54
(3,769 Views)

here it is.

it works exept for the end-button

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 4 of 54
(3,761 Views)

You need to make a few more changes other than just.

 

  1. get rid of the sequence structure, Use dataflow from the error cluster to sequence things.
  2. The bottom event structure must have a while loop around it if you want it to run continuosly, right now the way that you have it, it will only run once when that event fires and never run again.
  3. use a real producer consumer architecture. You should of had that in the basics two course you just took. If not there are lots of examples in the example finder and on the forum.
  4. The locals that you have in the bottom loop have the potential to cause a race condition. 

If I had a way to save back to your version of LV I would show what I am talking about.




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 5 of 54
(3,753 Views)

Joe,

thank you for the answer.

1. Do you mean the three frame sequence? That'S haw I learned it years ago. First frame initialisation (could be a lot), second the main program, third frame is the closing frame. I could get rid of it, but then the block diagram becomes larger.

 

2. yes you are right, I will fix that

 

3. Yes, it was part of the course. I will check out the producer consumer part again.

 

4. Yes. But how should I exchange the data then? Should I place another producer consumer architecture?

 

Johannes

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 6 of 54
(3,751 Views)

The reason that the END functionality does not work correctly is because of the event structure at the bottom is waiting for an event that will never happen because you stopped the other two loops that produce the event.

 

Put a while loop around the bottom event structure. Add an event to that event structure that triggers off of the END button and wire a true constant out to stop the loop.

 

You program is not too bad you just need to learn more about code structure. Your doin good Hang in there you are about to get it.

 

event.png




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 7 of 54
(3,743 Views)

Joe,

I have fixed the bottom event structure. now after each output event the loop stops and also after an timeout.

 The end button stil does not work.

 

I understood the producer consumer architecture, but I dont know what to do if I have two producers and consumers. I mean, the first producer is the input and the data processing loop is the consumer. but then the data processing loop becomes the producer and the output loop becomes the consumer.

Should I create two producer consumer architectures?

 

Currently I have only one of that structures and I send the output data via a local variable, which is not good.

 

John

Message Edited by johanneshoer on 10-01-2009 09:33 AM
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 8 of 54
(3,727 Views)
heres the vi again
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 9 of 54
(3,724 Views)
your close. all you need to do now is change your boolean constants (that end the while loop) in the bottom loop. The only one that should be true is the one in the "END" event the others should be false. 



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 10 of 54
(3,716 Views)