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
Solved! Go to Solution.
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.
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".
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.
do you see all the red dots in your VI?
Why do you have a "0" constant as DBL instead of using an integer datatype as shown before?
Why don't you use a feedback node instead of globals?
Attach the real VI...
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.