06-25-2020 02:06 AM
Dear Experts,
Assume, I am sending the value of 2 boolean buttons,
1st boolean value being 0, It would occupy 1 byte
2nd boolean value being 1, It would occupy 1 byte
Hence, I will be sending 2 bytes of information. Kindly someone let me know how I can accommodate the value of both boolean buttons into 1 byte of data. Thank you in advance
Solved! Go to Solution.
06-25-2020 02:18 AM - edited 06-25-2020 02:21 AM
Hi Diaspora,
@Diaspora wrote:
Kindly someone let me know how I can accommodate the value of both boolean buttons into 1 byte of data.
Build an array from your two boolean values.
Then convert this boolean array to number, then convert the number to U8:
06-25-2020 02:51 AM
Wow! Thank you for the solution, dear GerdW. I will try implementing the same.
06-25-2020 02:53 AM
Using one byte, you can send information of up to 8 booleans, of course.
What is on the receiving end? Do you have control over that? How does the other side expect the information?
06-26-2020 12:13 AM - edited 06-26-2020 12:28 AM
Dear GerdW, I am able to implement the same. Thank you.
06-30-2020 12:50 AM
Dear Experts and GerdW,
I tried implementing the same, but my output is differing a bit. As you can see, your output is displayed as follows
But, my output is displayed as follows.
Kindly let me know why this difference is and how to achieve the output representation as yours. Herewith, I attach my vi here. Thank you in advance.
06-30-2020 12:55 AM - edited 06-30-2020 01:00 AM
Hi Diaspora,
@Diaspora wrote:
Kindly let me know why this difference is and how to achieve the output representation as yours.
While I used one TRUE and one FALSE boolean your two booleans are both TRUE…
(Did you take some time to learn about those different display/radix options of numerics? Do you understand how to read numbers formatted and displayed with binary radix?)
On your VI:
Why do you need the local variable? Why do you introduce a race condition?
Why is there no wait function in the loop, so polling for user input as fast as possible?
06-30-2020 03:41 AM
While I used one TRUE and one FALSE boolean your two booleans are both TRUE…
When I do the same, this is the ouput.
(Did you take some time to learn about those different display/radix options of numerics? Do you understand how to read numbers formatted and displayed with binary radix?)
As you can, the radix for binary is chosen.
06-30-2020 06:08 AM - edited 06-30-2020 06:08 AM
@Diaspora wrote:
Dear Experts and GerdW,
So you don't think GerdW is an expert? 😋
For the numeric, go into the display settings and change the display format to "%08b". This will set the minimum length to 8 characters and pad 0s on the the left in a binary format.
For the string, I am not sure what %u will do as that is supposed to be fractional seconds for a timestamp. Set the format to %08b.
06-30-2020 12:28 PM - edited 06-30-2020 12:29 PM
Hi crossrulz,
as an expert I can say %u formats an unsigned integer… 😄