LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal simulation

Hi all,

I am doing some calculations to measure the area under the curve within differen frequency.

 I try to measure the area under the curve which is a function of tha amount of light bocked by some obstacle.

When there is no  obstacle between light source and detector, the output will be zero, and when the detector is blocked 100 % , the output will be the maximum ( about 3.075).

The first graph show the result when an object of 7mm diameter is moving between detector (4mm diameter)  and light source with 15, 30 and 45 mm/s Consecutivly.

The Second graph shows simulation of the movement of the object in front of the detector.

Based on that, I try to simulate the movement of an object with 1 mm/s infront of the detector and find output using the formula of the intersection area of two circlec ( written in yje block diagram), but the result shows something different, because I expect that the area under curve should be at least 15 times the data from 15 mm/s.

I beleive I have something wrong with my simulation results, try to help me to find that mistake..

Thanks.

Download All
0 Kudos
Message 1 of 6
(3,155 Views)

I did not try to sort through the mathematics in your simulations. I suspect that there may be an error in there somewhere. Can you post the equations (or a link to a site which has them) so that we do not need to derive the formulas from the basic geometry?

 

Here are a some of things which make it difficult to compare your simulations to the data:

1. The size of the objects appears to be different in each section. For consistency wire the R and r values to every simulation.

2. The scale factors are different in each section. Scale everything to a common amplitude range, such as the 0 .. 3.075 V of your measured data.

3. There are different numbers of steps in each loop. The number of steps and the increment in data represented by each step should be the same in all cases to make comparisons more meaningful.

 

I developed a simulation which does not depend on correctly doing the analytic geometry.  Or, more precisely, I let built in LV functions do the geometry for me. I use a picture control and draw two filled circles, on of radius R and the other of radius r. The r circle is dawn on top of the R circle.  I then move the circle of radius r along the horizontal axis of the control and simply count the number of pixels which are the color of the R circle. The result is scaled to 0 .. 3.075 and plotted.

 

I used Diagram Disable structures to stop execution of your code and placed the picture control on top of your XY Graph. It is a bit ugly.

 

Lynn

Download All
Message 2 of 6
(3,102 Views)

One thing that really complicates your code and makes it hard to debug is the insane amount of duplicate calculations. For example in the simulation loop, you are multiplying each of the 101 [i]'s 300 times with 2pi, dividing the same 300 times by 100, taking the sin&cos 300 times, etc. It is sufficient to do it exactly once. Right?

 

Whenever dealing with circles and xy graphs, consider going complex. It is simpler!

Here's how your simulation loop could look like instead.

 

 

 

I have not checked the math in your lower loop, but all you need is a i ramp, then remove the FOR loop. Typically it is more eficient to work on arrays.

 

(It also doesn't make sense to constantly divide the entire accumulating array by the factor. Wouldn't it be sufficient to instead divide each scalar before adding it to the array? Instead of building the array inside the loop, it would be sufficient to autoindex at the output terminal and eliminate the shift register. No need to update the indicator every nanosecond, once after the loop is sufficient. You won't see a difference. Of course once you follow my advice above, these points are irrelevant.)

Message 3 of 6
(3,091 Views)

Also, the formula for the "lens" area looks correct according to this page. (I have not checked if your LabVIEW implementation is correct, though)

 

Of course this area is zero of there is no overlap or full overlap, so you need to mix the area of the lens, of the small circle, and of the big circle accordingly depending on the center distance. Also remember that in the regions outside the overlap (=no lens!) the argument to acos and sqrt can be outside the valid range (-1..1, nonegative, resp.), so handle these conditions seperately.

 

0 Kudos
Message 4 of 6
(3,069 Views)

 

 

 

Hi Lynn

Thanks for your time. Actually I got themathematics of this simulations from this page  http://mathworld.wolfram.com/Circle-CircleIntersection.html.  

Regard to your notes:

- The experimental data [ first graph] the sampling rate is 2500 sample every 250 µs. Based on that I try to create the simulation.

Your Vi is very helpful, just may be I have to refine thecalculations little bit.

 

Again accept my deep appreciation.

 

0 Kudos
Message 5 of 6
(3,042 Views)

 

0 Kudos
Message 6 of 6
(3,032 Views)