LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex String related problem

Solved!
Go to solution

Hi,

I like to add 20hex string together & divide by 20 but somehow i can't get the correct result.

Attach with my vi here.

 

thanks and regards,

Simon

0 Kudos
Message 1 of 18
(3,760 Views)

Could you add your input string to the VI, make current values default, save and attach it once more? Also tell us what result you expect.

 

(Your code seems overly complicated. Can't you just cast the string to an array of U16, convert to e.g. U32 to avoid overflow, take the sum, and divide by 20?)

0 Kudos
Message 2 of 18
(3,752 Views)

Hi,

Attach with vi again.

I expect to get back FFFF(maximum so U16 is sufficient) for the average of 20 points reading.

Thanks alot.

Simon

 

0 Kudos
Message 3 of 18
(3,746 Views)
Solution
Accepted by topic author simon76

Try the attached VI, I changed the offset you were using in the search/split string to 2 because you are displaying the input string as hex, so when labview operates on the string it operates on the ASCII representation of the string (which is one character) even though your display is in hex (two characters per one ascii character) so you only need to split at an offset of 2 instead of 4. For example, ÿÿ = FFFF.

 

-RW

Message 4 of 18
(3,736 Views)

Isn't this easier and pretty much along the lines of Altenbach's suggestion?

 

 

 

PS:  The latest version of code capture tool works great.

Message Edited by Ravens Fan on 12-17-2009 12:01 AM
Message 5 of 18
(3,720 Views)

Hi, 

How you get the final result?? i getting -1 here...

 

regards,

Simon

0 Kudos
Message 6 of 18
(3,707 Views)
Make sure the representation for the array constant is U16 and not I16. FFFF is -1 in I16, but 65535 in U16.
0 Kudos
Message 7 of 18
(3,705 Views)

Now i get it. This approach much simple.

Thanks once again.

 

regards,

Simon

0 Kudos
Message 8 of 18
(3,693 Views)

Here's my idea mentioned above (eliminates coercions and orange wires).

 

Message Edited by altenbach on 12-17-2009 12:18 AM
Download All
Message 9 of 18
(3,680 Views)

Hi,

 

If i like to have moving averaging let say for N=10 datapoint, how can i do it??

e.g. t0,t1,t2.....t9,t10,t11,...t(n-1) : t0~t9, t1~t10,.... & plot into the graph.

 

My incoming data is read from UART with the data format as pic attachment.

 

thanks & regards,

Simon

0 Kudos
Message 10 of 18
(3,509 Views)