LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Display data types sent with serial.write in labview after send receive.vi

I am trying to understand the display of data I have shipped over the interface with serial.write to labview after using the send receive.vi ....

I am apparently not quite getting a handle on what the appropriate technique should be in labview as I am a rank beginner...

I am resistant to sending data in text format, and persistent enough to beat my head against a wall trying.

I was successful getting a PING sensor to give me what I wanted using the arduino alone and printing to the serial monitor. Then I created a function code in the LIFA to deal with a request from Send Receive.vi... and I am merrily pinging along without being able to quite get intelligible numbers out of labview. This caused me to look at how I should have sent the bytes (unsigned long, or unsigned int will do) representing the echo responce in microseconds from the PING sensor. I know what the numbers should look like, but can't seem to duplicate the success in labview...

Could someone help me understand what labview wants upon receiving either 4 or 8 bytes across the interface and how to display them? Also desired is if there is any trick to how they are sent (in binary) from Arduino...

Included a snap of vi so far...

Thanks so much...

(Forehead nicely flattened now)

Tim

PING.PNG

0 Kudos
Message 1 of 4
(4,503 Views)

There are generally two thing that I analyze when converting things to work with LIFA.  I look at how LabVIEW works with other functions and I also look at working Arduino code (that you mentioned already).  Generally, any manipulation or interpretation of the raw data is moved over to LabVIEW.  This way, all you need to be concerned with when sending stuff to LabVIEW from Arduino, you only have to send the original raw data.

This may not apply for all situations but I can't be any more specfic without the working Arduino code.  So, post the working Arduino code and your LabVIEWInterface.pde (or .ino which ever it is you have).

0 Kudos
Message 2 of 4
(3,383 Views)

Okay... after further flattening the forehead...

I discovered some examples (THANK YOU NATHAN!) illustrating some data "takeout" which showed how some data can be reassembled on the other side through labview... (which showed me how I might send the data in a responsible manner).

I think I learned that it is NOT NECESSARILY a hard and fast rule for how to send data from Arduino or how to receive data from LabView... but what IS necessary is that both sides agree and are "privy" to it.

I could have done this upside down and backwards, and as long as both sides agree... "It just doesn't matter!" (maybe)...

I found my array could be re-sized... (didn't know that... thought it was fixed and dynamic depending....), and that I could take data out in different order...

Here is my latest (and I am happy to say... successful atttempt) vi as a response to my underpriveledged and short on reasoning power first attempt.

PING2.PNG

And THIS.... is how I sent the data from my LIFA addition after reading about the technique to put high and low bytes (or words) together...

#

      Serial.write( (retVal >> 24 & 0xFF) );
      Serial.write( (retVal >> 16 & 0xFF) );
      Serial.write( (retVal >>  8 & 0xFF) );
      Serial.write( (retVal >>  0 & 0xFF) );
#

I wrote the values in reverse order after finding that the vi to put bytes and words together wanted a HIGH, then LOW byte (or word)... and after getting two sets of HIGH and LOW bytes together... it wanted a HIGH and LOW WORDs in the same order... so I knew I had to supply my array with bytes whose order was conducive to re-assembling the bytes with the tools provided. HIGH words and HIGH bytes first...

And in all fairness... it isn't necessary to send them in that order... what IS necessary is knowing ahead of time how you would like to deal with the data... and that perhaps if there was a style guideline... examples of ONE person's style on one side of the interface cause ANOTHER'S pain in the cost of assumptions while learning...

I understand a teeny bit more... and I hope this helps...

I now have a working VI for the PING PARALLAX SENSOR in both regular arduino code and in LABVIEW... (yeah!)

And... once again... THANKS NATHAN!....

I guess one could consider this answered... but I still want to know what I REALLY should be doing to be consistent for others...

Tim

Tim

0 Kudos
Message 3 of 4
(3,383 Views)

anotheralias wrote:


I still want to know what I REALLY should be doing to be consistent for others...

Well, IMO, it doesn't really matter.  As long as it works and is easy to read, it is fine.  Anybody who looks at any of these functions should be looking both at the Firmware and LabVIEW functions simultaneously to understand how they actually work.

Everybody has a different style (as you can see, there are at least two different "styles" used in the official LIFA).

0 Kudos
Message 4 of 4
(3,383 Views)