LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

???16 bits string to integer conversion???

I use VISA Read to read in 2-byte data, which result from a A/D conversion, then try to convert it to an integer. Straightforwardly "concanetate strings" and "hexdecimal string to number" are adopted, but the converted results don't fall into the reasonable range. Consequently, I believe, the function "hexdecimal string to number" is misunderstood by me.
Could anyone suggest me a right way?

thanks a lot in advance,

win2s
0 Kudos
Message 1 of 10
(3,518 Views)

"Hexadecimal string to number" assumes that yuor string is formatted with characters 0..F. If your two bytes are an unformatted binary string, just typecast it to a number, using e.g. a I16 or U16 diagram constant as type.

Message Edited by altenbach on 04-24-2007 08:54 AM

Message 2 of 10
(3,516 Views)
Thanks for your advice.

In an attempt to save the time and sampled data in a spreadsheet, I add "get date/time in seconds" and convert it to "DBL", but the final data sheet contains the following data:
3260276410,751 2,410
3260276410,831 2,390
3260276410,921 2,395
3260276411,011 2,395
3260276411,092 2,405
3260276411,182 2,405
3260276411,272 2,405
3260276411,352 2,405
3260276411,442 2,385
3260276411,522 2,405
3260276411,612 2,390
3260276411,693 2,390
3260276411,783 2,395
3260276411,863 2,390
3260276411,953 2,414
3260276412,033 2,410
3260276412,123 2,395
3260276412,213 2,405

Is there a wise way to get the time serie starting from "0"? I failed to find a function getting initial time instant.

win2s
0 Kudos
Message 3 of 10
(3,499 Views)
Simply subtract the first time from all the time values. 🙂
Message 4 of 10
(3,485 Views)
exactly, but which function provides the first time point?
0 Kudos
Message 5 of 10
(3,457 Views)

You don't need a function, it's the first value in the first column. 🙂

Within your code, you could place it in a shift register at [i]=0 and subtract it from the current time at each iteration. You'll get the relative times starting with zero.

Message 6 of 10
(3,432 Views)
Could you suggest an example? I'm also wiling to know it. Thanks.
0 Kudos
Message 7 of 10
(3,415 Views)


@xianese wrote:
... I'm also wiling to know it.

What is "it"??? This thread talks about (1) typecasting a string to an integer and also about (2) relative time stamps.

I thought both questions have received an adequate answer here. If you still have problems after trying the above suggestions, please be more specific about your problem. 🙂

Message 8 of 10
(3,407 Views)
Sorry for any ambiguity. "It" refers to the while loop with shift register. I guess, there is a get date/time in seconds function outside the while for the initial value.  Another get date function is to be placed inside the while loop to substract the initial value from the rest ones in each iteration. Is it correct?
0 Kudos
Message 9 of 10
(3,403 Views)
Yes, except that if you do it that way, the first point might not be true zero, especially if there is a lot of other code. The outside "get time" might execute right away, but the loop could have to wait for other code to finish.
 
Here are a few options. For small relative times, I prefer the "tick count" because it is more lightweight, but you can also use "get time" instead.
 
There is also an express VI "elapsed time" that you can use for this purpose. Make sure to disable "automatically reset after time target".
 

Message Edited by altenbach on 04-25-2007 03:31 PM

Message 10 of 10
(3,395 Views)