05-02-2015 12:27 PM
You really haven't told us enough for us to fully understand your question. So I'm going to guess here, and show you what might be happening (and how you should deal with it).
I'm going to assume that you have a device that produces a value, which I will assume is a Dbl (Float), and may be either represented as a Float or as a String representing a Float (i.e. it is either the number 12.34 or the string "12.34"). In any case, it is transmitted to LabVIEW in string representation as an array of bytes (U8).
Here is a Snippet of the process, showing the original number (Value), the representation as a String (using Format Into String) and the conversion of the String to a Byte Array (String to Byte Array). At this point, we have an array of U8, similar to what you showed.
The final two functions reverse the process. Byte Array to String recovers the String, and Scan from String reconvers the number.
As resonable as this may be, it is possibly quite wrong, as your example shows a Byte value of 251, which corresponds to the character "û", clearly not part of what we consider a string representation of a number. So not only don't we (I shouldn't say "we", I should say "I") understand what you are attempting, I don't have "typical data" that you are trying to reformat (indeed, it wasn't until recent posts that I realized that you were dealing with Byte arrays).
So please, tell us in detail (a) what the original value (from Arduino?) represents, and whether it is an Integer or a Float, (b) how the data are transmitted to LabVIEW, and (c) provide a complete example of the data array. I dare say, many of us would almost instantly recognize whether what you are showing is an Ascii string representation, the byte components of a multi-byte Integer, or the byte components of a multi-byte Float. Once we know this, the conversion process will be clear (to us) and we can help you.
Bob Schor
05-02-2015 12:34 PM - edited 05-02-2015 12:47 PM
@joap wrote:
Please resize that array container so it show all elements. How many elements are there?
What's the name of the LINX function in the middle and what does the help say about it?
(In any case, you might get more specialized advice posting this on the LabVIEW MakerHub forum.)
05-02-2015 12:59 PM - edited 05-02-2015 01:15 PM
hello
I have tried that already and in the string indicator there comes only this: û
05-02-2015 01:00 PM
this is what a custom command is: labiewhacker.com/doku.php?id=learn:libraries:linx:tutorials:adding_custom_command
I wrote in arduino:
int batterij(unsigned char numInputBytes, unsigned char* input, unsigned char* numResponseBytes, unsigned char* response)
{
x = analogRead(3);
y = map(x, 0, 1023, 0, 255);
//y = (x/1023)*5;
response[0] = y;
*numResponseBytes = 1;
return L_OK;
}
05-02-2015 01:14 PM
hello, thank you for your reply
I got that string scan used but then I get an error that the type of the string is not correct.
The exact way the data is sent to LabView I do not know because we had to do this so our supervisor
In arduino I have an array U8 with the response
This is the link where I found information on the custom command:
https://labviewhacker.com/doku.php?id=learn:libraries:linx:tutorials:adding_custom_command
(apologies for my poor english)
05-02-2015 01:21 PM
@joap wrote:
hello
I have tried that already and in the string indicator there comes only this: û
OK, so you probably only get a single character (hard to tell, because some might not be printable). Why don't you right-click on the string indicator and select "hex display"? What does it say now?
Maybe all you need to do is use "index array" to get the first element as a U8 number?
05-02-2015 01:23 PM
Thank you for your answer
These are all elements that response exists (I can make it very long but there is nothing sent to)
and I will ask again at the forum, the linx function in the middle is custom command
05-02-2015 01:33 PM
now it says F9
05-02-2015 01:45 PM
F9 in hex is 249, very similar to 251 that you saw, previously. Something very strange is going on here -- I think that I am "out of my comfort zone" ...
Bob Schor
05-02-2015 03:31 PM
Your map command seems to scale the raw sensor value to a range of 0..255. Simply use "index array" to convert the single elements U8 array to a U8 scalar and wire it to you indicator.