LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a Vi result for calculations

Hi every one, I started this project thinking that it would be easy, but as this is my first application, it´s been more complicated that I thought it would be...

My project idea: I have a laser device that measures distances. I take a lot of measures, and all I need is the mean distance, and then calculate some other things, but the main problem is to acquire this measurements.

Basically I have the "menu principal" all I need here is to measure each one of this three positions (I measure three different points, calculate the mean distance and then operate between this three numbers) what I tried to do here is, wit the measure distance 1, call the example 2.1.1.vi.... The first problem is that it start running, but I can not see it nor set the parameters unless I go to the block program and open it....

The second problem is that it should work like this, when I push measure distance1 should open the example 2.1.1.vi, set the parameters, then if I push "detectar trigger" wait for the F3 signal, run the application, and stop when the second F3 signal arrives, I have the hardest time with this, because the start an stop button or cap is the same..Finally when it finishes take the mean distance into the mean distance 1...

Should I have one example 2.1.1.vi for each "measure distance x"? I´m I doing it more complicated than it really is? Can anyone help me with this?

Thanks so much!

Cheers!!

0 Kudos
Message 1 of 10
(3,834 Views)

You forgot somes files (the project is empty)...

 

Image.jpg

 

Jean-Marc

0 Kudos
Message 2 of 10
(3,828 Views)

My bad...here whe go again...

Download All
0 Kudos
Message 3 of 10
(3,816 Views)

I made some modifications, it is a starting point...

 

Untitled.jpg

 

Jean-Marc

0 Kudos
Message 4 of 10
(3,784 Views)

Thank´s for your reply Jean Marc, it´s seems you know a lot...Ii had a problem to run the program though..The example 2.vi have this error:

 

These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
The type of the source is typedef 'Action.ctl'
cluster of 2 elements.
The type of the sink is typedef 'Action.ctl'
unsigned word [16-bit integer (0 to 65535)] enum {Wait, Read, Update, Wait before measurement, Stop} [numFlags=0x6C6C00].

 

What does the "action" supposed to do? mime type and program path? I printed in pdf and I´m studding it, but I don´t quite get it..Ii´m sorry, as I said, is my first project and I have a lot to learn yet...

Could you please explain me?

Thank´s a lot, I needed someone to help me with this...

0 Kudos
Message 5 of 10
(3,760 Views)

« Action” is a customize (wright click – advanced - customize) enum.  You could open the type def (wright click – open type def).

Enum.jpg

 

open Typedef.jpg

 

Typedef.jpg

 

Edit item.jpg


 

Laser 1 -wait.jpg

 


 

When this VI starts, the value “wait” is stock in the “shift register”.  The default value of DETECTAR TRIGGER is false and the VI do nothing, except waiting 100 msec at each iteration.  When DETECTAR TRIGGER is switch to true then, at the next iteration of the while loop, the case structure will be switch to “Read”.

Laser 2 -read false.jpg

 

If the Boolean read is false then the VI do nothing except waiting 100 msec.

 

 

Laser 2 -read true.jpg

 

When the boolean Read is turn to true, then "one read" is done at the serial port and at the next iteration the case will be “update”.

 

Laser 3 -update.jpg

 

The VI do some calculations and the next step is “wait before measurement”.

 

Laser 4 -wait before.jpg

 

 

The VI waits “time between loops (ms)" and the next step is "read" and so on until the boolean “Stop 2” is switch to true,

 

Jean-Marc

0 Kudos
Message 6 of 10
(3,749 Views)

Thank´s JM!!! It´s been so useful!!! I´ll try with this during the weekend and see what happens, I´ll let you know how it´s working....have a nice weekend!!

Later...

0 Kudos
Message 7 of 10
(3,717 Views)

Hi J-! I´ve been working the during the week end in the project, and I wanted to say thanks, since your advice helped me to do what I needed.

The only question I have, is the next, as I checked the vi, I found that it seems to "slow down" as the vi runs...i mean, the first measures goes as fast as 58 measures per second, 30 seconds later it runs at 32 measures per second (this is with time between loops 0 ms-the fastest to measure-, delay before read 10 ms. At first I thought it may be a problem with the cases you added, but then o checked the original project and it has the same problem....

May I ask you two more questions?

1. What may be causing this problem? Is it the cases? The buffer? The shift register? The VISA close function? I don´t really know if this can make a vi slower..i tried deleting one of this at the time, and even though with come combinations runed faster, the problem remains...

2. Is it any way to run the vi faster? With 9600 bauds y should be able to collect +-180 measures per second..Instead I can only take +-60 measures per second....what should I consider when I´m programming, so a can take all the measures I can?

0 Kudos
Message 8 of 10
(3,674 Views)

Post your latest version.  I will take a look at the end of the day or tomorrow.

 

 

Jean-Marc

0 Kudos
Message 9 of 10
(3,660 Views)

j-m, i really appreciate your help, i´ve been working in the big formula to put everything together and in the laser as well...

regards!

0 Kudos
Message 10 of 10
(3,621 Views)