From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem initializing shift register

Solved!
Go to solution

Hi,

 

I am using labview 7.1 to control a spectrometer. In my program, I have a certain function that runs 32 times and adds up, and the whole set again runs n times. I am using two "for loop"s one inside the other. In the inner loop I have a shift register to send the information from one iteration to another so that it adds up. But i guess there is some problem with the shift register because i just receive a blank graph after the loop executes. I used an indicator to check the output of the function, and it is certainly working. I guess problem occurs when i add up result from two iterations. Sometimes when I would forget to initialize the shift register i use to have this problem, but this time I cannot initialize the shift register because the create constant option is disabled for some reason. can anyone please help me out! Thanks!

0 Kudos
Message 1 of 16
(4,073 Views)

Can you add a screenshot of your block diagram?

 

Chris

0 Kudos
Message 2 of 16
(4,069 Views)

I have attched the program. It is not complete yet. Thank-you!

 

0 Kudos
Message 3 of 16
(4,064 Views)

Please attach a simplified version of your VI.

 

Most likely you cannot initialize your SR because it does not have a defined datatype yet. Simply use a diagram constant of the correct type and wire it to shift register as initialization. What is the datatype you want?

 

How do you wire out of the SR and into the graph? For a graph, you typically need an array. Is your SR an array or a scalar?

0 Kudos
Message 4 of 16
(4,063 Views)

Well, don't use dynamic data for this. 😉

 

Maybe you can add a small case structure around the "add". If [i]=0, you would wire the data across, and in the default case you would add to the old. Now you don't need to initialize.

 

We don't have any of your subVIs, so we cannot run. What is the graph supposed to show?

 

(Your use of an event structure is a bit odd, especially since your boolean is not set to latch action. What is the purpose of the sequence structure? Since all nodes rely on wired connection, the execution order can be fully determined by dataflow if correctly wired.)

 

You might want to use a state machine architecture instead.

Message Edited by altenbach on 07-02-2009 08:37 AM
0 Kudos
Message 5 of 16
(4,049 Views)
I have attached a simplified version. It is not terribly simplified but I have tried to include only the parts that matter.
0 Kudos
Message 6 of 16
(4,044 Views)

Hi Altenbach,

 

I would say my SR is an array because I need to take the y co-ordinates of a graph from one iteration and send it to the next iteration and add them up. I tried initialing a 1D array of zeros and feeding it to SR to initialize it but it did not work.I will try using a case structure and see if it helps. My graph is supposed to show intensity Vs wavelenght of a white light sourse and there are some calculations that I need to do with it and thus, I need to be able to add the intensities from two iterations. I have used the flat sequence structure because I donot want the close spectrometer vi to execute before the for loop which are in parallel and not series ( they are both wired to initial wrapper and not to each other. Thanks!

0 Kudos
Message 7 of 16
(4,038 Views)
Solution
Accepted by topic author labview_dummy

labview_dummy wrote:

I will try using a case structure and see if it helps.


Seems to work just fine here:

 


labview_dummy wrote:

I have used the flat sequence structure because I donot want the close spectrometer vi to execute before the for loop which are in parallel and not series ( they are both wired to initial wrapper and not to each other. Thanks!


Then make them "in series" by wiring the input across the FOR loop, for example. 😄

Message Edited by altenbach on 07-02-2009 09:48 AM
Message 8 of 16
(4,024 Views)

Hi Altenbach,

 

Thank-you for the help!I tried doing what you showed but instead of giving me the sum, it just gives me whatever waveform I send in. I used highlight execution to see what was going on and aparently it is summing up every nth iteration (n being the number of iterations i specify for the "for loop") and for all other it gave me exactly the same waveform i send in. 

0 Kudos
Message 9 of 16
(4,010 Views)
Please attach your new code again. Did you define the correct case as default, for example?
0 Kudos
Message 10 of 16
(4,006 Views)