LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shift registers and arrays

 Hi everyone,

 

I want to do the following with the help of shift registers:

For an arbitrarty array, I want to subtract one element of the array by its follower for

all array indexes from 0 to n-1.

As an example, for an array "3, 2,1", that should give me "1,1".

I tried to create such a vi (and it should include shift registers) , but it doesnt work as I want..

can someone help please?

0 Kudos
Message 1 of 10
(4,716 Views)

Three possible methods for you: (with and without Shift / Loops):

 

Arrays.png

 

Andrey.

 

Message 2 of 10
(4,708 Views)

Array.png

 

Why do you need shift registers?

What exactly was not working in your understanding?

 

 As much as I understand from your post, you need array as an result. You can not get an array using scalar indicator (as you have did in your vi). Shift registers are not necessary. 

 

Edit: Andrey, how much hands do you have? 😄 I see that I have missed the "-1" for the number of cycles to be used.

Message Edited by Giedrius.S on 02-16-2010 02:14 PM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 3 of 10
(4,705 Views)

Well, thanks a lot.

Im totally new to labview.

Now the second option of yours with the shift registers (yes, I need those..): The input is not an array but

a scalar, right?

Further on, what kind of array (method) are you using for the output? Is it a "insert into array"? That didnt work

for me though...

Hmm..

And one last question: Does it matter, if I build the array on the front- or the blockpanel? The icons seem to be

different, so I wondered...

 

Cheers, Mychelle

 

0 Kudos
Message 4 of 10
(4,681 Views)
here also the vi
0 Kudos
Message 5 of 10
(4,679 Views)

Shift Register is scalar. Input array (it is array) is AutoIndexed (as well as output array). Use input array from your first exercise and combine it with last exercise.

You can place arrays on the front panel as controls or indicators or on block diagram as constants. If array placed on front panel, then it appeared as Terminal on the block diagram, then you can create local variables for according terminal, and if array placed on block diagram - you can't. Like variables and constants in C language.

 

Andrey.

 

0 Kudos
Message 6 of 10
(4,671 Views)

Thanks, that helped a lot.

Still Im encountering two problems:

 

- For the "insert into array" I am using at the output, it seems that it has to be wired with two arrays as an input..?
If not, it shows me an error.

But if I wire it with two arrays, it will of course show the result twice, as for input "3 4 2" the output would be " 1  2 1 2"

instead of only "1 2". So what can I do?

 

Regards,

M

0 Kudos
Message 7 of 10
(4,635 Views)

Why "Insert into Array"??? In the example above "Delete from Array" primitive was used. The first elementh in the output is undefined, therefore was deleted from output.

 

Andrey.

 

0 Kudos
Message 8 of 10
(4,628 Views)

Mychelle,

 

There are probably as many possible solutions as there are ways of (trying to) interpreting what you are trying to achieve.

 

Can you tell us what it is that you are trying to do and why you are trying to do this?  Maybe if we get that perspective, more adequate solutions can be proposed.

 

I read the posts, and it sounded like you wanted to work with arrays, meanwhile, you're really dealing with scalars.  It might be one or the other or both... So again, what's the purpose of this exercise?  Where does the data come from?  What form is it in?  What are your constraints?  What is the expected output.  

 

I'm sure the solution is simple, but will any suggestion be the right one?  <- that's the question...  🙂

 

R

0 Kudos
Message 9 of 10
(4,618 Views)

Hi,

 

I just missunderstood Andrejs explanation first - now I got it and it works, but thanks anyways Ray!!

Cu,

Mychelle

0 Kudos
Message 10 of 10
(4,577 Views)