LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you do somthing like x = x + 2 in labview?

I'm trying to code an accumulator in a For loop and I'm having trouble with the issue of reading from and the writing to the same area index in the same iteration of the loop.  I tried to make use of the feedback node, but this doesn’t met my need.

0 Kudos
Message 1 of 5
(4,802 Views)
It seems to me you want to increment array elements (+value in the upper array and +1 in the lower array). thus the array needs to go in the shift register, NOT the element. (Your two size=4 arrays start out blank with each iteration of the FOR loop!).
 
I really don't have the slighest idea what you are trying to do, but I made some guesses and modified your VI as attached (LabVIEW 7.1). Modify as needed.
 
(Also note that you should wire the error out of the nodes on the left, else they may execute at a random time with respect to the FOR loop instead of before everything else starts. You need to create a data dependency to force execution order, code does not necessarily execute left to right).
0 Kudos
Message 2 of 5
(4,797 Views)
I have done some cleaning in your code since your vi was truely unreadable. Wires running backward are definitely a major source of confusion.

I still don't understand what you are trying to achieve here. There are a number of inconsistencies :
- the FOR loop will stop after 1000 iterations, but the case register has provisions for much higher values.
- the shift registers (because you used feedback nodes...) are not initialized, and record the last stored values, leading to unpredictable results on the second and further runs
- during the first 4 loops, the same array cell is replaced in the upper array...
- ...

Could you be more explicit and describe what you intend to do here ?

I have attached a simple accumulator example.
Chilly Charly    (aka CC)
0 Kudos
Message 3 of 5
(4,792 Views)

Wow, for not knowing what I was trying to do you were very helpful (clearly I didn’t know what I was doing, I did figure out on my own about half of the changes you made).

 

I am building up to a primitive voice recognition application to recognize four spoken words like “go, stop, left, right”. I’m not sure just what I will eventually do to condition the signal I get from a microphone with a hardware filter 5 to 2000 with a gain of 100; for now I’m using a power spectrum.

 

My objective is to “Extract Spectral Features”, i.e. some subsets of the power spectrum in the code you looked at; average from sample number 1 to 3 and save it as “Spectral Features” 0, etc..  I intend to do this to enough samples of the words to get a template to compare to when attempting to recognize what word is spoken.

 

Any way, thank you very much for taking the time to help me, I really appreciate it!

 

Ben

Download All
0 Kudos
Message 4 of 5
(4,788 Views)

Christian, Ben.S

funny, after cleaning, we didn't arrive at the same result.

Attached is my own version...

Chilly Charly    (aka CC)
0 Kudos
Message 5 of 5
(4,785 Views)