10-01-2009 07:59 AM - edited 10-01-2009 08:01 AM
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
10-01-2009 08:08 AM
10-01-2009 08:26 AM
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...
10-01-2009 08:32 AM
here it is.
it works exept for the end-button
10-01-2009 08:55 AM
You need to make a few more changes other than just.
If I had a way to save back to your version of LV I would show what I am talking about.
10-01-2009 09:06 AM
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
10-01-2009 09:17 AM
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.
10-01-2009 09:30 AM - edited 10-01-2009 09:33 AM
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
10-01-2009 09:34 AM
10-01-2009 09:41 AM