LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex String related problem

Solved!
Go to solution

Hi Simon,

 

have you searched for "moving average" in the forum?

 

Well, I would keep the last 10 values in an array (which is kept in a shift register). When a new value arrives, the oldest data get overwritten...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 18
(1,053 Views)

Hi GerdW,

 

I do seach the forum for moving averaging, and try it somehow still not able to get result. Refer to test.jpg

For moving averaging, i may need to get (t0 to t9)/10, follow by (t1 to t10)/10,...etc & plot to the graph.

If deleted the old data, it just like averaging which not a problem.

 

regards,

Simon

0 Kudos
Message 12 of 18
(1,047 Views)

What result are you getting?

 

The one error that jumps out at me is the way you are replacing the element in the array.  For a 5 element array, the index of the last element is 4.  (Array indices are zero based.)  So it looks like you need a decrement (-1) function on the blue wire after you establish the size of the initial array.

0 Kudos
Message 13 of 18
(1,026 Views)

Hi Ravens,

 

You are right. To get the 5 data moving averaging, initial array need set to 6.

Attach with the simulate pic.

Is it possible to get the "Mean" for hex string or still need to do convertion?

 

thanks and regards,

Simon

0 Kudos
Message 14 of 18
(1,004 Views)

You aren't taking the mean of a hex string, you're taking the mean of the integer values you converted from the hex string.

 

The question is whether it is working for you now or not.  It seems like you've changed a lot more in that VI than what I told you.  You've changed 4 or 5 things.

0 Kudos
Message 15 of 18
(1,002 Views)

----------------------------------------------------------------------------------------------------------------------------------------------------------------- 

You aren't taking the mean of a hex string, you're taking the mean of the integer values you converted from the hex string.

 

The question is whether it is working for you now or not.  It seems like you've changed a lot more in that VI than what I told you.  You've changed 4 or 5 things.

------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

Since the incoming data is normal hex display (23f,..etc) --> convert to hex string --> convert to integer --> Take Mean --> plot to graph. Final result is to get the waveform. Is there any alternatively for better code improvement or remove unnecessary step of my code?? That's the Q refering to.

 

Yup. Is working now. If based on prev vi, how can need to amend??

Thanks once again for your help & guidance.

 

Regards,

Simon

0 Kudos
Message 16 of 18
(994 Views)

-------------------------------------------------------------------------------------------------------------------------- 

So it looks like you need a decrement (-1) function on the blue wire after you establish the size of the initial array.

---------------------------------------------------------------------------------------------------------------------------

 

How can i do it??

 

 

0 Kudos
Message 17 of 18
(988 Views)
Right click the blue wire, Insert, Numeric Palette, pick the -1 function.
0 Kudos
Message 18 of 18
(981 Views)