LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding array elements with its previous value

Solved!
Go to solution
I am using the VISA read function to read the value from my usb device.I am getting ascii values.I am using the string to array function for converting the value into its decimal equivalent.I have verified the values and t is working fine.The visa read function gives me array of different size every time.I need to convert this into an array of 1000 elements.i.e I am getting an array whose size can be any where between 1 to 1000.If the size is 1000 i want to come out of the while loop.If say the array value is changing for each iteration like 1,200,30,45 etc I need to cumulatively add the bulk of values to get a resultant index value of 1000 in the output array and then exit the loop.I have tried using shift registers but am stuck.Please help
Message 1 of 13
(4,579 Views)

Hi muks,

do you know the "reshape array" function? I think this should help you.

Mike



Message Edited by MikeS81 on 06-09-2008 12:51 PM
Message 2 of 13
(4,563 Views)
hi

".If the size is 1000 i want to come out of the while loop.If say the array value is changing for each iteration like 1,200,30,45 etc I need to cumulatively add the bulk of values to get a resultant index value of 1000 in the output array and then exit the loop"

Can you be a little more clear on what you are doing in the while loop?

you get different value in each iteration? and you want to come out of the loop once the array size=1000??
you want to cumulatively add BULK of values?

can you give more detail on this??


Message 3 of 13
(4,560 Views)
hi

irrespective of the contents of while loop, without using any shift register, 'reshape array' function must do your job.
Message 4 of 13
(4,557 Views)
Hi muks,

maybe this will guide you:


Wow, 5mins ago nobody seems to care about this threadSmiley Wink


Message Edited by GerdW on 06-09-2008 01:00 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 5 of 13
(4,555 Views)
Hi muks,
 
Have a look at the attached image. This code should implement the functionality you are after.
 
KostasB
 
NIUK Applications Engineering
 
p.s. I didn't realise how many people replied by the time I finished editing this post!
 
 
 
 
 


Message Edited by KostasB on 06-09-2008 06:04 AM
Message 6 of 13
(4,551 Views)
Thanx a lot for your reply.But i am still stuck.I suppose i need to elaborate a lil bit.I am attaching my block diagram.In my block diagram the unsigned byte array changes randomly from 1 to 1500000 during each iteration of the while loop.That is the read function returns random values.I need to accumulate each value till my output array is of the size 1500000.If during my first iteration itself i get 1500000 bits then i need to exit the loop and use the output array for my next stage processing.So in other words i need to get the aray size of the unsigned byte arry and add the subsequent values till i get 1500000 data.I have tried ur suggestion but am still stuck.
Message 7 of 13
(4,506 Views)

This is exactly what the code I attached is doing ( for a 1000x1 array instead of a 1500000x1). Essentially, you initialise your array outside of the loop in a shift register. You need the second shift register to store the current

index value. For example, if your first iteration produces 50 elements and the second 100, then at the third iteration you use the replace array function to insert the new data into the array starting at index 150. If the total number of

elements exceeds 1000, the loop terminal condition is met you you break out of the loop. Your data will be stored at the orange shift register and can be used for analysis.

KostasB

NIUK Applications Engineering

Message 8 of 13
(4,493 Views)
Hi kostas,
                I have tried your program.But the index is not getting incremented at all.i.e loop is not getting exited at all.


Message Edited by muks on 06-10-2008 07:10 AM
Message 9 of 13
(4,483 Views)
Hi muks,

replacing the "0" at the add operation with a wire coming from the output terminal of the shift register will do the trick...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 13
(4,461 Views)