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.
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.
WIth the attached project1A.vi I can receive the data on screen in Hex... Thanks to you!!! I also learnt from project1B.vi what Altenbach had earlier said in the post that "there is no need for creating and clearing a new task with each iteration".
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 (project.vi 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.
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.
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 datareverse.vi.
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,
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". 😉
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 NI.vi for above A,B and C.
All I found was that when I use the reverse 1D array block (project.vi) 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,
Can anyone tell me how to reinitialize a string(indicator) in the attached String Reinitialise.vi? I have to write 0 to it outside the while loop but it doesn't help. Is there a another way?
Thanks and regards,