From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-27-2013 11:42 PM
I need to subtract two (uint16) 1D array of same size. with folowing output...
x - y = result(EXPECTED)
5 - 2 = 3
4 - 0 = 4
0 - 4 = 0
2 - 3 = 0
If difference is less than zero value should be zero. Right now, if I use numeric subtraction...i get ....
x - y = result(OBSERVED)
5 - 2 = 3
4 - 0 = 4
0 - 4 = 4
2 - 3 = 1
Thank You
Solved! Go to Solution.
02-27-2013 11:59 PM - edited 02-27-2013 11:59 PM
Hello rajxabc,
I'm not sure why you expect unsigned integer math to produce a 0 in the scenario you show below. The U16 will actually wrap past 0.
so,
0 - 1 = 65535
0 - 2 = 65534
0 - 3 = 65533
If you want to change the standard behavior of unsigned integer math, you'll have to create a special algorithm to produce this, something like:
There's a number of ways you could accomplish this but at the end of the day, I'm not sure I would label any of them "expected".
02-28-2013 12:51 AM
Your soultion is correct. Perhaps i was asking wrong question because i am still not able to acomplish what i wanted to do.
Kindly see attached block diagram.
incomming data is accumulated added values on each interval. (i dont have seperate access to new incomming values)
So, what i am trying to do is to , substract new array from last observed array .
for that i am using global array initialised with zero. is there a way to do that.
before i tried shift register, but on each loop my array was initialised to zeros.
Can you help me here . or i have to ask new question ?
I am accepting the previous answere.
02-28-2013 01:14 AM
02-28-2013 02:39 AM - edited 02-28-2013 02:42 AM
Hi GradW,
i tried to use feedback node, but it all got more confusing.
attached is vi file I am trying to modify for my need. I dont know LV at all.
The Idea is to save subtracted array as they come.
Array Xn - Xn-1 --> save to csv
Any suggestions would be helpfull.
Thank you