LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Loop foor with register shift

Hi,

 

I have a problem with 2Darray and loop with register shift

I have 2 1D array row X and row Y (the data are always Boolean (0,1)

In the final, I have one 2D array which represents X.Y.

In the result of the multiplication, if I have one, I add +1 in the final output array

 

 

Step 1 : X = 00 and Y = 10

The result is of the output array is :

  10

  10

 

Step 2 : X = 11 and Y = 10

The result is of the output array is :

  01

  01

But I want to have this result for the output array :  (previous output array + new array = new array)

  10 +  01 =   11

  10 +  01 =   11

 

Step 3 : X = 00 and Y = 10

The result is of the output array is :

  10

  10

But I want to have this result for the output array :

  11 + 10 = 21

  11 + 10 = 21

 

The problem, is that for each loop for the ‘loop with register shift’, Labview take the the previous data, but the init array.

 

Can someone help me ?

 

Thanks

0 Kudos
Message 1 of 15
(4,103 Views)
Hi Mini...,

can you provide default data in your controls? Fill in values for X and Y, right-click the array control and select data ops->set current to default and save the vi again.

What values do you have in those X/Y-arrays? Just 0/1 (boolean values) or "10" (multi-digit binary numbers?)???
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(4,096 Views)
Hi,


In the arrays X and Y, I have just boolean value 0 or 1

Thanks
0 Kudos
Message 3 of 15
(4,088 Views)
Hi Mini...,

you only provided 2 values for X&Y each, so you will only calc 2 steps/iterations...

I still don't know what you really want to achieve as you use X&Y for indexing (just the upper left corner of the bigger array as both X&Y are only 0&1). How do you want to add "10" and "01"?


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(4,061 Views)
Hi,

In the final, I have 11 bits of data
7 for X et 6 for Y

For the sample, I had juste take 2 for X and 2 for Y

For explain you, in the first step, I made X.Y and I have a 2D array
The second step, so a second acquisition, I made X.Y, and I have a 2D array, that I add to the last 2D array. That is why I have use the register shift to get the last value of the 2D array

In the final program, you have 11 bits of data = 7 Led for X array, and 6 Led for Y array.
Then I made the product X.Y and I have a 2D array of Led (7x6)

What I want in the final, is having a 2 array of value.

In the final, if X+Y=1, the result is 1, so I add +1
0 Kudos
Message 5 of 15
(4,044 Views)
Hi Mini...,

you want to add to the shift register, but each time you call the vi you re-init it with the "Init Array" function...

Where do you do your multiplication? Look at the attached vi with some added code. Maybe you can rework your vi to reflect more accurately your goals?

Why do you want to test for "X+Y=1" after 10 (or more) iterations/aquisitions? Then you may have any result not just one? Still problems to follow you...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 15
(4,039 Views)
Sory for my english, but I think that I have not really explain what I want to do
So there a new vi
You have array X and Y and the 2D array which represent X.Y

If on the 2D array, I have a led at 1, I add +1 in the correct case in the data array

The second run, if I have no change in the 2D array, I do nothing, but if I have a new Led at 1, I do +1 in the correct case in the data array

Do you better understand what I want to do ?

But I know that the problem is with the shift register and the Init array, but I don't know how I can solve this problem.

Thanks
0 Kudos
Message 7 of 15
(4,036 Views)
Hi Minikisscool,

so you will have to initialize only on first call of the vi! Smiley Wink
See attachment, I used a second SR to remember the state of the vi (first run or not). There is also a "First Call?" function in the data communication->synchronization palette, but using a SR allows for additional logic for resetting this state.

Also included an easier way of adding "1" to the array bypassing both FOR loops Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 15
(4,003 Views)
Hi,

Thanks for your help.
I have test the vi this morning.

The initi is very well.
But the program don't really work as I want.I will explain you.
You must do +1 just with a new state 0 to 1 do +1 in the array
If you have 1 to 1, you must do nothing.

I have test the program with DAQ Assistant and my USB-6009.All is good, but there is this litte problem.

Here is the new vi

Thanks
0 Kudos
Message 9 of 15
(3,987 Views)
Hi mini...,

you have to use one more SR to determine the changed LEDs - whenever you want to determine changes in a loop you should use SRs...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(3,980 Views)