Showing results for 
Search instead for 
Did you mean: 

Sending Hex Value on DIO

Nick26 wrote:

 Data of element Y shows = 00000000 10101010 01010101 10101010. I have attached Array data.jpg for reference.

I would appreciate if you attach a vi.


Thanks and regards,




The data looks ok then, since that is binary for 00AA55AA.

Here's something to try, in the first version i just changed the code which converts the bits to a string, so try that first.


If that works, have a look at the second version, which has the task creation outside the loop.


Good luck!



Download All
0 Kudos
Message 11 of 27

Nick26 wrote:


I tried the above solution but I get element x = 1 and y = 0. I am expecting a String e.g. 00AA55AA. I can see the data in the 1D array cluster of two elements. Data of element Y shows = 00000000 10101010 01010101 10101010. I have attached Array data.jpg for reference.

OK, I'm probably missing the point, but gettting a string of 00AA55AA out of a cluster of two I16 values (x=0 and y=1) seems like pure voodoo math to me. Do you want a hex formatted string consisting exclusively of the letters 0..F, two letters/byte, or do you want a binary hex string.


If th element of y is 00AA55AA, it means you messed up, because the Y value is I16 and thus only contains 2 bytes.


Your FOR loop at the end makes no sense. It will run so fast that you'll only see the last value.


I am afraid we'll need better specifications before we can give more detailed advice.

0 Kudos
Message 12 of 27

Hello MaxCrunch,


WIth the attached I can receive the data on screen in Hex... Thanks to you!!! Smiley Happy I also learnt from what Altenbach had earlier said in the post that "there is no need for  creating and clearing a new task with each iteration". 


Hello Altenbach, 


You said "Since you are sending between 1 and 4 bytes of data you need to make sure you are using the correct datatype. Once you have a byte array, you could just autoindex on a FOR loop to send the bits in sequence." I could not implement as you can see in the attached vi.

With my exisiting code by using a increment block and feedback, formula node the array reads from 1st bit and not the 0th bit ( in this thread). 


 Also Initially i will send AA55AA90 to the controller after I get a response on screen, I want to send a new command to the microcontroller which will vary from 1 to 40 bytes. Can you suggest how can i go ahead with the implementation of this?


 Thanks for your support.


0 Kudos
Message 13 of 27

Hi Nick, glad the code did what you wanted.


I would suggest that before you add more functionality, you might want to consider the overall structure of your program.
This would make it easier to add more code while keeping it easy to debug and maintain.


An event driven approach or a state machine (or combination) might be appropriate.



0 Kudos
Message 14 of 27

Hello MaxCrunch,


I am a newbie to Labview but I will surely use your your advice on event driven or statemachine approach. But for now I am stuck with the problem of sending commands to microcontroller which are more than 4 bytes..My application needs 40 bytes data to be sent at a point of time after initialisation activity with 4 bytes. As you can see in this post Ihave mentioned this earlier but could not get a solution. For e.g when the user sends data AA55AA90 to the microcontroller, the microcontroller reads it as 0955AA55. so I have to convert (reverse the command). Which is posssible upto 4 bytes (32bits) which labview can handle with Reverse 1D Array block. I even tried to split the data(8 bytes) and reverse the command. This is a large amount of code and only works upto eight bytes

After I get this inversion then I have to sent this data bit by bit to the microcontroller. And the counter has to be initialized after each command sending is complete.


Thanks in advance,



0 Kudos
Message 15 of 27

Nick26 wrote:

For e.g when the user sends data AA55AA90 to the microcontroller, the microcontroller reads it as 0955AA55. so I have to convert (reverse the command).


 I don't see how AA55AA90 is the reverse of 0955AA55. Can you explain?


Again you do way too much work, juggling between datatypes. All you maybe need is "reverse string". 😉

0 Kudos
Message 16 of 27

Hello Altenbach,


What I meant is that if I send AA(1010 1010) to the microcontroller, it reads 55 (0101 0101) and when I send 55(0101 0101) then microcontroller reads AA(1010 1010). I have also checked this for some other values as below:-

            Sent                Read by Microcontroller

1) 01(0000 0001) -->  80(1000 0000)

2) 02(0000 0010) -->  40(0100 0000)

3) 03(0000 0011) -->  C0(0000 0011)

4) 04(0000 0100) -->  20(0010 0000)


A) I tried reverse string But the output of it is AA55AA90 --> 09AA55AA. And what I a need is 0955AA55.

B) I even tired to convert the string to little endian format using  flatten to string, but the string remained same.Is there a way by which I could use a array of 10 hex numbers 4 bytes each and operate upon array element using decimate array.

C) I also tried the rotate block and rotating each byte by 7. But I do not get correct results for all 1 - 4 listed above.It only seems to work with AA, 55 and 01.

Please find attached Reverse String for for above A,B and C.


All I found was that when I use the reverse 1D array block ( it works sucessfully but only for 4 bytes. And as you know my requirement is sending atleast 40 bytes. Is there a way that I can check the string length then make a for loop and process(reversing using reverse 1D array) each of the 4 bytes, 10 times in my case..?


Can you give a solution for this :- Autoindex on a FOR loop to send the bits in sequence.


Please Help me with a solution!!


Thanks and regards,


0 Kudos
Message 17 of 27

Sorry I made a mistake the correct way is...Smiley Wink


3) 03(0000 0011) -->  C0(1100 0000)





0 Kudos
Message 18 of 27

Hello All,


Can anyone tell me how to reinitialize a string(indicator) in the attached String I have to write 0 to it outside the while loop but it doesn't help. Is there a another way?


Thanks and regards,



0 Kudos
Message 19 of 27
You shouldn't be having any problem with your string indicator.  You initialize both shift registers with either an empty string for the string shift register or an empty array for the array shift register.  So any old data should disappear after a stop and restart on that VI.
0 Kudos
Message 20 of 27