Jump to content

serial communication in labview problem


Recommended Posts

Hi,

I want an byte interface that transfers the data serially which makes my USB device not busy. i attched the file that i used for interface but i have doubt about weather it is byte communication or string communication. I am totally new to LABVIEW. how can make byte communication means reading data in bytes and sending data in byte directly but i fell that given VI is receive string and send string. i dont want to convert the string in labview. i want only bte communication.

OR

i am feeling that VISA will read the dat whatever coming from USB wether it may be byte are any type and then read will produce as string. and the same write that send given string as number of btes. is it right.

Thank you.

Doc1.doc

Edited by sjukheter
Link to comment

Hi Sjukheter

The VISA interface in LabVIEW accepts string data only so you will have to convert the byte information e.g. by typecasting the data etc...

Then how can i make the byte interface to the coming data. i want to get the data from USB which transfers some 8 bytes of data..

Link to comment

Then how can i make the byte interface to the coming data. i want to get the data from USB which transfers some 8 bytes of data..

The internal representation of a char (1 character of a string) is a byte. If you write the character "A" it s a byte of value 101 (decimal) or 41 (hex). So when you write A to the port you are in fact writing a byte of value $41.

A string is an array of characters and therefore an array of bytes. So writing "ABC" you are actually write an array of bytes $41,$42,$43. You can easily convert to and from the representations by using using the "String To Byte Array" and "Byte Array To String" primitives in the string/array/path palette (under the strings palette). But you can only ever write read and write strings using the VISA functions;.

Now.

When you read (or write) "bytes" that are in the printable character range everything is fine. You will be able to type in values to string controls when writing and when you read it back you will see characters if you usea string indicator

However.

What if you want to write a hex byte of value 0?.

Labview has a very easy way of doing this. If you right click on a string control (or indicator) you will see a menu option for "\" Codes Display and "Hex display. Setting the control/indicator to these will display the "string" in either the escaped format (e.g \00 \00) or in hex byte format (e.g 00 00). so unless you are going to do some function on the values of the bytes (like a CRC) then there is no need to convert and has the added bonus that you can use the string splitting functions to break up the data..

Edited by ShaunR
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.