LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

master/multiple slave design example

Can someone please post an example of the master/slave design with multiple slaves.  I cannot get the second slave loop to start.
 
Thanks.



metzler CLAD
0 Kudos
Message 1 of 8
(6,150 Views)
Hi,

this is not too easy since Master/Slave in the original (one master, one slave) is quite "straight ahead"..but more than one slaves? Who is the master of which slave? What is the purpose of each slave?

Just one tip to clear some pitfalls:
Each Slave should have its own queue!

And another:
Each slave should only focus on one purpose!

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(6,136 Views)
You can add as many slaves as you want.
Create another notification if your loops must not run in parallel
0 Kudos
Message 3 of 8
(6,132 Views)

PNT, thank you for the example.

do both slave loops run at the same time, or can they be independently run.

Norbert, putting queues on slaves creates producer/consumer, doesn't it?

One slave will run my DAQ (from compactDAQ), another will write data into Excel, and I may need others.  According to NI, there can be multiple slaves.

Thanks.

 




metzler CLAD
0 Kudos
Message 4 of 8
(6,106 Views)
Yes, you are correct that the default master/slave uses notifier, not queues.... my mistake.

Deciding weather you use master/slave or producer/consumer is important since there are some differences between queues and notifiers:
a) Notifier can loose data, queues only unlikely (if they do, they are configured in a wrong way or the system is already messed up!)
b) Queues should not have more than one reader but can have unlimited number of writers
c) Notifiers should have only one writer, but can have unlimited readers

In the screenshot PNT attached, the slaves will run in parallel and (hopefully) will be kind of synchronized. If you dont like that, you can add different timings to both loops, which can(will) lead to loss of data.
Regarding your requirements, i think you will better use producer/consumer (so my answer wasn't too bad.... ) since i asume that you do not want to loose data!

And if you choose producer/consumer, please note my hints from the first post...

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 8
(6,097 Views)
The loops in PNT's example will all run simultaneously. Each loop needs to contain an short wait to allow CPU sharing.

If you want a parallel process to start on demand, you can either put an Idle case inside a loop which runs continuously or put the loop into a subVI which is called dynamically.

The producer/consumer design pattern usually is implemented with queues, but it could be done other ways.

I have developed several programs with three loops. One handles all the user interface (GUI). Another does the DAQ and the third handles most of the data processing and program control logic. I use two or three pairs of queues. If each loop communicates with both of the others, three pairs. If communications is GUI <-> Process <-> DAQ and never directly from GUI to DAQ, then only two pairs are used.

Lynn
0 Kudos
Message 6 of 8
(6,096 Views)

Like Lynn, I am going to use the GUI to start the DAQ functions.  This would also control writing data to Excel.  I actually have this done, but it is all within one while loop, and is quite big. 

Additionally, I need to control everything Automatically (if someone presses the Auto button on the GUI).  So, this button would turn off all GUI functions (except stop Auto) and run all the other loops, like DAQ and writing to EXCEL. 

I know I'm rambling, but the last thing that I tried on my original program has caused windows XP to shut down LabView.  I am trying to troubleshoot this but not having much success.

 




metzler CLAD
0 Kudos
Message 7 of 8
(6,089 Views)


metzler wrote:

... but the last thing that I tried on my original program has caused windows XP to shut down LabView.  I am trying to troubleshoot this but not having much success.



One thing to keep in mind is that whenever you do something like open a file, obtain a queue or notifier, create a DAQ task, ....  something like that, only do it once before your loop starts.  These operations take up a little bit of resources everytime they are used, so if they wind up in a loop, you'll eventually use up all the computer resources and cause the PC to crash.  I saw this happen on a program someone else wrote for me where they create a DAQ task each time in a sub-VI and didn't clear it.  This subVI ran in a loop.  After thousands of interations of the loop (I think it was about 80-90 thousand), about 20 minutes, the VI would crash Labview to a blue screen.  Eventually I found the error and fixed it.
0 Kudos
Message 8 of 8
(6,076 Views)