LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Archetecture help

Solved!
Go to solution

Hi,
I'm attemting to take measurements with a DAQ and a Micro Epsilon laser and I was wondering about what archetecture type I should use. The problem is that I have a serial motion controller that I will tell to move a certain distance, when in place I will take a measurement then move to the next positon and so on - I must know that I have taken the measurements at each point. I have created a sample code to demonstrate the take samples section of code that I would use- essentially a for loop for each device and lots of notifiers to ensure that I get the number of measurements I need and that I only take one set of measurements per command.

Is there a better way of doing this or is this the correct way?


Regards,

Joe

0 Kudos
Message 1 of 7
(2,814 Views)
Solution
Accepted by topic author JoeMoore1331

I would just use a State Machine.  You can have a state for each measurment and another state for changing your position.  That would combine 3 of your loops and remove a lot of the confusing queue and notifier passing you have going on.

 

I would still keep a seperate loop for logging.  But you only need 1 queue.  Make the data type of the queue a cluster with a string and a variant.  The string will tell your loop what is being passed to be logged (file name, DAQ data, laser data, stop command) and the variant just holds the data.


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
Message 2 of 7
(2,793 Views)
Solution
Accepted by topic author JoeMoore1331
The thing to remember is that just as when designing a building, a program will often be a mixture of architectural elements because no one technique works universally well everywhere.

Like Tim says, the control might work very well inside a state machine, but there might also be aspects of producer/consumer in play, like the separate process that he recommends for logging data.

As I have demonstrated, a very powerful stricture can be to have your state machine be just one of several parallel processes that together create the functionality you want and need -- with the GUI and data logging being two others.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 7
(2,784 Views)

Thanks for the advice,
Reason that I separated them from each other was because I thought it would be complicated if everything was in one loop:
There is a lot of initialising that one sensor requires and also it is fairly slow to read measurements from,

Also, I'd end up putting lots of data into shift registers

And its also useful to be able to poll the sensors/ controller when not doing anything to check their status.

 

The idea behind the many notifications is to try to create a stae machine between different for loops. Each can be doing their own thing in the background but I know what they are doing when I send a command to them.

 

Mike, do you have any examples of that structure that I could look at? 

0 Kudos
Message 4 of 7
(2,768 Views)
Check my blog, starting at the beginning. A link is in my signature.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 7
(2,754 Views)

Thanks, I think I've just scratched the surface of your blog - there is some interesting stuff to read on there.

After looking at it I think the best idea would be this:
The main loop a state machine that reads from a queue - as there are a couple of states that need to be repeated for various reasons but are then processed differently ( one repeated case will be DAQ read - there will be an instance once where the output is used to calculate the next motor movement and another will be used to log data)
Another loop for the interface
Possibly a final loop using sephamores to check the status of the connected controller every seccond or so.

 

Thanks for your help,

Kind Regards,

Joe

0 Kudos
Message 6 of 7
(2,736 Views)
Something to be careful about is putting the state-machine in you main interface. As your GUI grows in sophistication over time (and it will!) its operation can negatively impact the state machine operation.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(2,720 Views)