LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift register/2 loops

Hello, I've created a program which gets one row of 20 elements per second ( it's just a part of the bigger program ). I want to fill the array up to 20 rows ( 20 rows = 20 seconds, it works like timer ) and then make the program to overwrite this array, starting from the beginning. When it overwrites the row, it also subtracts the new elements of the row from the old row which gets overwritten. The thing is it works fine while in a loop with a shift register. My bigger program got one loop already so I cannot put the second loop in the main one. That means also that I can't implement the shift register because i got no second loop, and making this register on the main one doesn't really do the trick.

 

Should I use the producer/consumer structure ? I tried but I cannot get this working.

 

I attach the vi, the core is inside the loop, the rest is just for simulation purpose.

 

 

Kind regards

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

I just change a bit your code test if it is what you want

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

You can have a single sub-vi with a "one cycle only" while loop or a for-loop with a N of 1.

This Subvi has the shiftregister un-initializes ( not connected on the left side ) but does have a 1d array input.

 

Each call to this vi you add / replace a block of data, and the only place that has the large memory allocated is this subvi.

Floris Reinders
Senior Project Engineer / CLA
0 Kudos
Message 3 of 10
(3,333 Views)

Hi

@Hatef : Thanks for improving this code but I don't see the difference in working 😞

 

@mr_builder : I don't get that correctly, I tried making a subvi but it still prevents the main loop from working. Is there a special option to create a type of subvi that you mentioned ?

 

I hope that you still got it in mind that it's just a part of the big program.

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

@Galjuntur wrote:

My bigger program got one loop already so I cannot put the second loop in the main one. That means also that I can't implement the shift register because i got no second loop, and making this register on the main one doesn't really do the trick.

 


Then show us the bigger code. We don't want to solve a problem that does not apply to the given example.

 

Is there any reason your code is polluted with dynamic data for no good reason at all? This is plain silly! You apparently use it to get one element of the size(s) array. All you need is use "index array" before quotient&remainder and do the rest of the operations on scalars.

 

If you have an outer loop, you can place the shift register it the outer loop instead, right?

 

And I agree that this should get wrapped into a subVI with an uninitialized shift regsiter or feedback node. Have a look inside the ptbypt VIs for some ideas.

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

As you said, I attached the whole vi code. Part of the program was created by sprzysta.

 

The only good reason for pollution with ddt is that I'm not experienced so I make my code in the simplest way. I noticed that I cannot put a block of write to a measurement file at the output array.

I tried to make a shift register on the outter loop but then I got the feedback node. Even though, the program still doesn't work properly.

 

Regards

Gal

 

 

BTW I guess that if I got cjc constant ( room 20 degC ) then I apply to a thermoocuple conversion block a constant block with the vlue of 20, right ?

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

@Galjuntur wrote:

 

The only good reason for pollution with ddt is that I'm not experienced so I make my code in the simplest way.


Dynamic data never makes anything simpler. (see also here)

 

 

I'll have a look at your new attachment....

Message 7 of 10
(3,239 Views)

Here's a quick draft. I assume that each row contains 20 elements and that there are 3600 rows.

(I took the liberty to simplify a few other things. Modify as needed).

 

Let me know if you have any questions.

Message 8 of 10
(3,214 Views)

Right, this looks a lot cleaner than it used to. I got only three questions but they don't apply to the program mechanics which is clear. I hope you won't mind answering them.

 

1) As I asked before, if I want to put a stable constant temperature of for example 20 degC, should I add a constant with that value to the conversion block or should I convert somehow this temperature to get a voltage value and then add it ?

 

2) As you noticed, I got two graphs (charts). Which one in your opinion shows more accurate values ? Because the data presented is a bit different from each other.

 

3) iIs there an option which will allow me to see only the currently changing row ? To see the actual values and not all.

 

Big Thanks for helping with getting rid of ddt.

 

0 Kudos
Message 9 of 10
(3,199 Views)
  1. Dealing with scalars is very cheap. It is easier to maintain the program if you add a diagram constant of 20 and convert it, instead of creating a digaram constant of some complicated converted value. Makes it easier to maintain, e.g. if you later want to replace it with a 30 degC value.
  2. I would use chart 1. they both contain the same data. You data has no time information, so converting to ddt does not add anything useful. I am sure you can change the way it is formatted (axis range & format, update mode, etc.) to look exactly as you like.
  3. To see the chaging row, you can create a 1D array indicator or graph wired to the data coming out of the subtraction node. You don't really need the 2D array indicator. It is chepaer to not bother the UI will all that internal data.
Message 10 of 10
(3,181 Views)