LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to speed up array manipulation

Solved!
Go to solution

Hi hun,

 

you DID NOT include any meaningful data in your VI ("positions").

 

As you divide by an array size of zero your VI tries to create an array of size 2^31-1 DBL elements…

 

AGAIN:
Attach the VI with meaningful data in it!

 

And please explain (in detailed manner) how you want your pulses be generated!

 

(Running your VI with two "Position" values takes just milliseconds here…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 22
(2,156 Views)

That is really odd Gerd,

 

I DID fill the inputs with data, no idea why they get lost when attaching the file! I'll try attaching the new version now...

 

Anyway I think I solved the memory problem now by using INT16 for the encoder outputs (I guess I could use INT 8 as well). 

 

Cheers

0 Kudos
Message 12 of 22
(2,145 Views)

After filling in data into relevant controls, you need to make the new values the default before saving. Do you know how to do that?

 

From a a quick glance at the code, you seem to exclusively deal with integers (except for the time and position control before multiplication). So why is there so much orange in the code??

 

Instead of "Insert into array", use "built array"".

 

The inner FOR loop is identical in the two cases, thus it belongs after the case structure. Only one instance needed.

 

The small case structure is useless, you automatically get zero if you index outside the valid range. Delete it and keep only the default code.

 

The outer loop needs to be a FOR loop because the number of iterations is known before the loop starts.

 

 

Message 13 of 22
(2,141 Views)

What are typical inputs for "time" and "amplitude"?

0 Kudos
Message 14 of 22
(2,118 Views)

Check out the In Place Element Structure.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 15 of 22
(2,085 Views)
Why? "Replace array subset" already operates in place, so that would not make a difference.
Message 16 of 22
(2,086 Views)

Hi Altenbach,

 

thank you very much for all the tips, I will take them into account and update my code! It's always nice to learn some new things from the pros. 

 

About the "orange", I can't get rid of it completely as the input array "Position" comes from another module and is in DBL format, and also when performind some divisions which don't throw integer results I have to deal with DBL variables.

 

Typical values for time are 5 to 20 seconds and amplitude will be 5, 12, or 24. 

0 Kudos
Message 17 of 22
(2,057 Views)
Solution
Accepted by thehun

thehun wrote:

About the "orange", I can't get rid of it completely as the input array "Position" comes from another module and is in DBL format, and also when performind some divisions which don't throw integer results I have to deal with DBL variables.


Yes, I noticed that. Here's a rewrite keeping approximately the original functionality. Maybe it can give you some ideas. THere are probably bugs.

Message 18 of 22
(2,048 Views)

Thanks, it definitely does! 

0 Kudos
Message 19 of 22
(2,015 Views)

@thehun wrote:

Thanks, it definitely does! 


Have bugs?   In Christian's code?  The requirements must be wrong!


"Should be" isn't "Is" -Jay
0 Kudos
Message 20 of 22
(1,984 Views)