From 02:00 AM CST Saturday, February 4 - 06:00 AM CST Saturday, February 4, 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
Did you mean:

g libraries for avoiding truncation of interleaved array?

Hello

I know if we interleave two 1D arrays of different size, the obtained array looses some elemets of the array that is greater in size!

I wanted to ask is there any solution to this, other than build array unction?

is there any open G libarary that exists for the solution of this?

Thanks

Sara

Message 1 of 16
(2,024 Views)

Re: g libraries for avoiding truncation of interleaved array?

I don't know of any open G code to do this.  But here's a snippet I put together real quick that should do the job.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 16
(2,013 Views)

Re: g libraries for avoiding truncation of interleaved array?

I was planning to submit this to OpenG. Here is a library I put together for resizing arrays.

Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 16
(2,008 Views)

Re: g libraries for avoiding truncation of interleaved array?

Thanks alot1

Can I get the VI of this?

If you can please attach the code so that I can try that out!

Message 4 of 16
(1,986 Views)

Re: g libraries for avoiding truncation of interleaved array?

How do i have to work with this resize array attachment?

Does this avoids truncation of two 1D arrays of different sizes?

Message 5 of 16
(1,985 Views)

Re: g libraries for avoiding truncation of interleaved array?

In the above code what I have perceived from  png pic that is attached,

although it retains all the elements in the array out, but when we decimate this 'array out' to obtain again the required arrays it mix ups the elemets!

For examle array1 {10,20,30,40}

array2{1,2}

arrayout will be {10,1,20,2,30,40} so when we will try to decimate this array to obtained the actual array1 and array2 that we have interleaved we will be getting

array1 {10,20,30}

array2 {8,2,40}

the extra elements are divided again into both of the decimated arrays!

I donot want this because I would be interleaving my data at RT side and then decimating at fpga side! I cannot afford mixing of elemets!

What do you recomd me for this?

tHANKS

SARA

Message 6 of 16
(1,974 Views)

Re: g libraries for avoiding truncation of interleaved array?

Hi Sara,

Mark provides a polymorphic VI for setting an (1D or 2D) array to a certain size. You just use that VI as is given in it's context help. As it handles just one array that VI will not solve your problem on its own - but you can use it in your routine to solve your problem...

@Mark:

You always check your primary dimension for "<>0". Why that?

Wouldn't be ">=0" more suitable?

- You may also want to resize to size zero.

- "-1" is most often default for "out of range"-condition when it comes to array indices.

- There's no difference in setting to any negative dimension...

Edited for SARA:

You CANNOT interleave 2 arrays of different length and append the remaining elements of the longer array and on the same time insist of simply decimating the result on the receiving target! THAT WILL NOT WORK! (If you don't believe this: draw on a sheet of paper...:) )

You have to provide more input to the FPGA side, maybe by including information on number of elements or data source...

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO
Message 7 of 16
(1,972 Views)

Re: g libraries for avoiding truncation of interleaved array?

Hey

Thankyou

But I havent understood what exactly ypu are trying to say!

Is this that I cannot get decimated arrays as I want ??

And I think so for my purpose the mark code wouldnot help!

I am actually unable to understand what you said! have you understood my actual point? maybe I am not able to convey it or have I?

Thanks

Message 8 of 16
(1,961 Views)

Re: g libraries for avoiding truncation of interleaved array?

Are you doing anything with the data between the interpolating and decimating other than sending it to the FPGA?  If not, I wouldn't bother interpolating.  Either send them separately or just append.

But here's a caviat.  The FPGA has to have fixed length arrays.  So on your RT side, you need to set your arrays to the proper length before sending them down.  This is where Mark's code will come in handy.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 16
(1,958 Views)

Re: g libraries for avoiding truncation of interleaved array?

I am dealing with FPGA!

interleaving my data at RT side and sending to FPGA by decimating

But what if we donot know our array size because  I am giving an angle to my motor that uses spline interpolation to reach its position! interpolates point and feed to fpga continousally!

So with every time we change angle array size would be changed! as the interpolated points will be different each time the angle is different!

So does that mean that we cannot do this?

Message 10 of 16
(1,949 Views)