LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Autoindexing array in for loop

Hello guys!

I have the following situation:

the picture I attached displays a for loop implementation to detect certain CAD angles (rising and falling) to be input by the user and up on detection it is desired to output a pulse between the two values ( the rising of the pulse will be when I detect rising CAD input value and the falling of the pulse output will be when I detect the falling CAD input value). 

I autoindexed the incoming CAD array to the for loop so that the algorithm runs for every element ( am I correct here?). The CAD array comes in the range [-360, 360] and when I output the indexed elements out to the front panel via a numeric display, I expect to see every element. Strange though it is always displaying the first few elements (360 and around). The CAD array has about 5110 elements with in the range. Why is these all elements not shown in the display? It is strange because I have tried the logic implemented in a simulation environment and it works just fine. But now running live, the results are affected. 

Could someone help out? 

 

Thanks

0 Kudos
Message 1 of 8
(3,513 Views)

Hello henok

 

You are right. Autoindexing gives you the possibily to go through each individual element in the FOR LOOP. you can read and process every element in that array by enableing auto index. You also can enable auto-indexing by configuring a For Loop to return an array of every value generated by the loop.

I didnt understand your question actually. Do you have problems in displaying the CAD array ( that you have connected )in the front panel?  And how are the results affected? Can you be more precise in your question?

 

 

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 8
(3,486 Views)

My guess will be that the FOR loop is runing so fast that you can't see the values changing.

If you need to see the values changing, place a wait of 200ms in the FOR loop. That will slow down the loop.

 

You can also try to place an indicator connected to the I terminal of the FOR loop.

0 Kudos
Message 3 of 8
(3,462 Views)
Thanks for the confirmation, Nghtcrwlr!
My question might have been vague and I will try to clarrify. The logic inside the FOR LOOP is working fine as far as I am concerned and I have tried to verify that with every possible scenario I could think of. And when for example I use simulated input to the FOR LOOP, it works just fine. I will attach some pictures so you will get an idea of it. But when I run in the 'real' environment (though I am using a fake engine that generates CAD and TDC pulses) it is not giving me the results I expect. I am not doubting the fake engine because if I'd log the incoming CAD array I get the expected values with in range [-360, 360].
And the indicator in the front panel displays values of the CAD between 359 adn 360, which affects the result in such a way that the 'before TDC' angles (which are in the -ve half of the CAD array) not being detected at all.
I hope you get my problem now.
0 Kudos
Message 4 of 8
(3,448 Views)

...here is a picture of results and a simulated input to the FOR LOOP.

Download All
0 Kudos
Message 5 of 8
(3,446 Views)

Hello henok

 

I dont see the problem u mentioned. The CAD values in the frontpanel runs from -360 to 360 with 0.1 interval and the rising and falling edges are detected as you have programmed.

I dont see any problems.

 

Put a 5ms wait ms inside the FOR LOOP and you can see the values in the frontpanel changing from -360 to 360

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 8
(3,410 Views)
Hello Nghtcrwlr,
The results you saw are from the simulation. And I am facing a problem when I run in on live system.
I tried to use the Wait(ms) function inside the FOR loop and yes indeed I see the CAD values couting normally and the results indicated by the Boolean indicators were conforming to it.
But strange enough when I used no Wait(ms) inside the FOR loop, only the Falling Edge boolean indicator is lit. that is the sort of problem I am having in the running environment. I have no idea why that is happening.
The other problem I faced was that when I used the wait function in the FOR loop it disrupted the graphing display of channel signals (perhaps that can be fixed by inserting appropriate delays for the graphic display loop?)

I appreciate your helps!
0 Kudos
Message 7 of 8
(3,400 Views)

May be as dkfire mentioned , the FOR loop is runing so fast that you can't see the values changing even the boolean indicator. If it works with wait ms , then it should be working wihtout it.

Yeah i guess the wait inside the FOR Loop may also affect the graphic display.

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 8
(3,374 Views)