LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine VS producer consumer architecture - Time Analysis

After learning various methods to program efficiently and learn how to use SM and Producer consumer. I built a program to control stepper motor in both these techniques.

 

Here is the RESULT. As we can see a simple state machine without any complicated producer consumer technique performs faster than the second one.

 

I am not sure which is still the best based on performance and optimization. Please advise which one should I keep and why.

 

TIME_ANALYSIS_FINAL.png

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 1 of 13
(2,805 Views)

The Producer Consumer will typically run a little faster simply because stuff can run in parallel.  For most of my applications, this type boost isn't really that much due to my sequencing.  But when I am crunching a lot of data or saving to a file, the Producer Consumer will help a ton.


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 13
(2,792 Views)

But in my case its the producer consumer loop structure is the one that takes time. Nearly 40-50% more.

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 3 of 13
(2,786 Views)

I'd have to see your code to do any more analysis.

 


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 4 of 13
(2,779 Views)

To give any comments on this, we need to see your code.

 

We need to how your are measuring the time in both cases.

A state mashine and a producer/consumer pattern can be programmed very effectiv, but also very ineffective.

0 Kudos
Message 5 of 13
(2,761 Views)

This is with state machine alone

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 6 of 13
(2,758 Views)

You do realize your event structure for what you claim is the stop case is actually looking for the status on the error out.  That is not going to work for you.

 

Plus you still need to post the Producer Consumer.  I recommend just putting everything inside of a zip file and posting that.


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 7 of 13
(2,751 Views)

This is with producer/consumer architecture.

 

EDIT: I am sorry, I posted before I read your reply.

 

The attached containsboth files DEV 3 being state machine and DEV 6 being PC method.

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 8 of 13
(2,748 Views)

Your producer/consumer version has flawed timing.  You are timing not only how long it takes the code to run, but how long it takes the user to press the Run button.

 

Run your VI again and wait 10 or 15 seconds to press the run button and see how big your timer value gets then.

 

In the state machine version, you don't have that problem so much.  Your code begins running after the 100 msec wait for the timeout of the event structure occurs, or even quicker if you change an input value fast enough.

Message 9 of 13
(2,729 Views)

Damn!! Yes ... Never gave a thought to that!.

 

How can I start the executiuon by default in producer loop event structure ?

 

I dont want to trigger the event by clicking on the Run button. Instead just running the VI should start it. Is there a way to do that ? So that I can do the time analysis automatically. 

 

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 10 of 13
(2,719 Views)