LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Binary Data using TCP/IP

This is frustrating.  We make suggestions, you raise objections, yet we're pretty sure that the (several) things we suggested will work just fine.  But I just realized we have no idea what data you are trying to send (except that it is "binary" data) (but isn't all data on a digital computer, almost by definition, "binary" data?).

 

Time to demand politely request that you attach the VI that illustrates the data you are trying to send via TCP/IP.  I, for one, am curious if it is "unstructured" (such as a text string you might get from an instrument) and how it is being produced (including how fast, how much data/unit time).  Please, do not attach a picture of the VI -- we need to be able to see the whole thing, including the "not-the-top" Case elements.  Note that if you have multiple VIs all in the same folder (such as a LabVIEW Project), you can compress the file holding them all and attach the resulting .zip file (this really helps us understand the code).

 

Bob Schor

0 Kudos
Message 11 of 24
(1,859 Views)

Sorry Bob for the late response

 

I haven't actually started the VI yet. I am about to do it now. I will post as soon as I have something. 

But here is the sample structure: 

For Example: 

If I send write  0x08 to the host (microcontroller), I would receive this ADC value:  0x00000001. 

So, the main purpose of the VI is to send the command and receive the value from system and record that value. 

I hope it makes sense. 

 

0 Kudos
Message 12 of 24
(1,856 Views)

I should also mention that the communication is through ethernet, so I need to use TCP/IP. 

0 Kudos
Message 13 of 24
(1,855 Views)

OH!  That's completely different from what I thought you were trying to do (and what I'll bet all the other contributors thought).  I thought you were using TCP/IP for data transfer, not for doing VISA-like communication with a remote device a byte-at-a-time.  Hmm, now I'd want to know much more about the hardware you are using and the (just-mentioned) "micro-controller" ...

 

Time to tell us a lot more about what you are doing -- Network Streams are definitely not appropriate, as (I suspect) is much of what many of us envision when we think about TCP/IP in LabVIEW ...

 

Bob Schor

0 Kudos
Message 14 of 24
(1,851 Views)

@manny09 wrote:

Sorry Bob for the late response

 

I haven't actually started the VI yet. I am about to do it now. I will post as soon as I have something. 

But here is the sample structure: 

For Example: 

If I send write  0x08 to the host (microcontroller), I would receive this ADC value:  0x00000001. 

So, the main purpose of the VI is to send the command and receive the value from system and record that value. 

I hope it makes sense. 

 


Do you know the PORT?? If so, you can open a socket. The snippet below sends 0x08 and reads back 8 bytes.

simple_tcp_ip.png

0 Kudos
Message 15 of 24
(1,835 Views)

Hi Jamiva,

 

I am using Labview 2014, so can't use this snippet. Can you make the snippet in 2014 version of Labview?

I tried to make the VI based on the snipped, but I not sure how to make 0x08 show up as you have in the snippet?

0 Kudos
Message 16 of 24
(1,823 Views)

That one is easy enough to recreate from scratch.  For the constant, right click on that terminal and pick Create Constant.  If it isn't already set, right click on that and set display style to hex.  Then enter 08

0 Kudos
Message 17 of 24
(1,818 Views)

Thanks. I recreated from scratch as you suggested. 

I have another issue now. Actually, I need to input 2 hex numbers before I can get anything back.  Ex. 

I have to write: 0x01 and 0x0000000000000000, and I should get 3 outputs: 0x01, 0x0000000000000000 and 0x0001.

But I am not sure how to send 2 inputs together. Do I use 2 TCP-Write sub VIs or there is a way I can combine these together? 

And how would the output show 3 separate hex values? Do I need to use TCP-Read 3 times or just once to read all of them?

 

Thanks for the help. I really appreciate it.

0 Kudos
Message 18 of 24
(1,815 Views)

You can use multiple TCP Writes, or you can concatenate the strings and send them out once.

 

You can do multiple TCP Reads, or read the 3 bytes at once and use string functions to break out the values. 

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 19 of 24
(1,812 Views)

You could actually do this with VISA as well.  At least I have with oscilloscopes and power supplies (talking over TCP/IP to control the instruments).  I don't remember what the VISA Session is exactly formatted, but you can make the connection through MAX (and test your communications in MAX as well) and just use the VISA alias in your code.

 

The real beauty of using VISA is when somebody decides to use USB or serial port to talk to the microcontroller instead.  The only thing you would need to change is the initialization.  The rest would work with no changes needed.

 

But I'm just muddying up the waters now...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 20 of 24
(1,804 Views)