07-31-2012 08:57 PM
127 decimal = 111111 binary.
Try setting the format string on the Format Into String connected to Messages to %b
Lynn
08-01-2012 07:25 AM - edited 08-01-2012 07:26 AM
This is an interesting way of getting the final character. What are you trying to do here?
If you are after individual bits, you need to convert to a boolean array.
08-01-2012 05:05 PM
@crossrulz wrote:
This is an interesting way of getting the final character. What are you trying to do here?
If you are after individual bits, you need to convert to a boolean array.
Thanks for the reply...
I can't find how to convert from a byte array to a boolean array.....suggestions?
The earlier poster that showed how a boolean array could be transformed to a byte array using the >0 was interesting....is there another comparison, or other component that I can use to convert from byte array to boolean array....?
TIA,
cayenne
08-01-2012 05:17 PM
cayenne,
One issue is just what you want the output array to look like. Do you want a 2D array where each row reperesents the bits in one byte or do you want a 1D array with the booleans concatenated?
Here is how you could do the first.
The other is a bit more involved.
Lynn
08-01-2012 05:45 PM
@johnsold wrote:
cayenne,
One issue is just what you want the output array to look like. Do you want a 2D array where each row reperesents the bits in one byte or do you want a 1D array with the booleans concatenated?
Here is how you could do the first.
The other is a bit more involved.
Lynn
I believe the 2D array is best way...I could more easily go through each byte at a time to parse them, and act on them.
I see in the functions pallete, the number to array component you used in the loop...but where is the boolean array object you're feeding into there? I can't find that.....
From your example I'd go something like?
Thank you,
C
08-01-2012 06:05 PM - edited 08-01-2012 06:06 PM
It's an indicator.
Wire from the Number to Boolean Array to the edge of the For Loop. You should wind up with an auto-indexing tunnel. Then right click on that and choose Create Indicator.
PS: You don't need to get the Array Size and wire that to the N node of the loop. That is taken care of automatically by the auto-indexing input tunnel.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
08-01-2012 06:49 PM - edited 08-01-2012 06:52 PM
@Ravens Fan wrote:
It's an indicator.
Wire from the Number to Boolean Array to the edge of the For Loop. You should wind up with an auto-indexing tunnel. Then right click on that and choose Create Indicator.
PS: You don't need to get the Array Size and wire that to the N node of the loop. That is taken care of automatically by the auto-indexing input tunnel.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
Ok...an indicator...that was what was throwing me off.
I'm needing to initially display this into a text box....iterating through the array....converting it to string, and printing each row of bits for each byte, a carriage return , then the next.
I need this to start out with, to show what I'm receiving on the screen...I'm going to have messages going back and forth eventually...and am trying to use the text box "Messages" (indicator seen on the other vi examples I'd show where I had it totally wrong)...but I was wanting to show each byte array as a row on the text box area indicator and have them scroll by as they were received (will also later put in there what is sent, so I can compare sent to received).
Is this closer to what I'm needing to do?
I can't connect to the Messages area yet...I'm just not getting how to iterate through this byte array, and convert it to rows to print to the screen...
Dislplaying on the Messages area like
11100001
11111111
11111110
etc...
Thank you for the links...I'm trying to look through all of those now too!!!
I've been trying to learn all this from my read through of LabView for Everyone. I'll need to go back to find the chapters on for loops and the index tunnels, etc...looking into all this now.
If I can just get this example in my head and vi down...I think I can figure it out....I've just never tried working with bits and bytes before...very confusing, and not nearly as straightforward as working with text/strings, with construction, parsing, regular expressions, etc....
cayenne
08-01-2012 07:24 PM
cayenne,
Based on your last comments I suggest that you take pencil and paper and write down what is on each of the wires in that segment of code.
At the output of the VISA Read write down the value of the string - just like it would look on a string indicator. Use some real data, perhaps simplfied to meake it easy to understand.
Then write down the values in the byte array. Then the boolean array inside the for loop. And so on. Make sure that you understand how each transformation works.
This may help you understand how all the characters, bytes, bits, and arrays of these work.
Even though I have been programmming for more than 40 years, I still do things like this when I think it will help me understand what is going on.
Lynn
08-04-2012 10:53 AM - edited 08-04-2012 10:56 AM
@johnsold wrote:
cayenne,
Based on your last comments I suggest that you take pencil and paper and write down what is on each of the wires in that segment of code.
At the output of the VISA Read write down the value of the string - just like it would look on a string indicator. Use some real data, perhaps simplfied to meake it easy to understand.
Then write down the values in the byte array. Then the boolean array inside the for loop. And so on. Make sure that you understand how each transformation works.
This may help you understand how all the characters, bytes, bits, and arrays of these work.
Even though I have been programmming for more than 40 years, I still do things like this when I think it will help me understand what is going on.
Lynn
Thank you. Good advice. I think I'm a bit closer now, and have done what you said, and I've set a bunch of probes, and breakpoints, to go through and see how things really were working.
I'm much closer now, but have a question at the end, where I'm receiving the byte array back..I've successfully converted it back to a boolean array.
At this point, I'm trying to use an Array Subset, to grab off the first 8 bits, but it seems to be sending them all for some reason, and I'm a bit stuck.
I'm attaching the vi to this point.
Here is the section where I"m trying the subarray that isn't working like I thought it would:
This is the readings on the probes:
08-04-2012 04:03 PM
cayenne,
I am not sure what you are expecting that you are not getting. The bytes are there. The bits are ordered with the least significant bit on the left. Since 127 has seven 1s the eighth bit is a zero. It is there because averything is done in 8-bit bytes.
Lynn