LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

16 bit receive over rs 232

Can you post your code. It will make it more easy for us to understand why you struggle.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 11 of 31
(1,580 Views)

Hello,

 

I am attaching the code., I am trying to modify and utilize the basic serial write and read.vi.,

 

Thanks.,

 

- Nagaraj Hegde

0 Kudos
Message 12 of 31
(1,574 Views)

You have a major problem with your reading.

 

You are reading the number of bytes at port with two VISA reads at the same time in parallel, one being a normal read, the other a read to file.  Those two are going to compete with each other as to which reads first.  Once one VISA read gets the bytes from the serial port, they will no longer be there for the other VISA read.

 

Also, your code has yet to show anything where you are converting your bytes read to be a 16 bit number.

0 Kudos
Message 13 of 31
(1,560 Views)

Ravens Fan is correct.  Instead of Reading to File, just use one read, the top one.  Afterwards, you can write the data to a file using Write Text File or Write to Spreadsheet File.

 

As for joining two bytes, the function you are looking for is called Join Numbers, and it can be found in the Numeric - Data Manipulation palette, and it looks like this:

 

21876iDC8720AF2A57FA75

 

Of course, you will have to convert the string from the Read to a number first.  Since the numbers are all in one string, you have to separate the bytes first (string subset).  Each character is a byte.  Then take each character and convert to a number.  See the string palette for String to Number conversions.

- tbob

Inventor of the WORM Global
0 Kudos
Message 14 of 31
(1,550 Views)

Thanks all,

 

But I don't know why., I am not able to read any number by doing what you suggested., Attached is the vi., I am using string subset and string to hex number converter but not able to write anything to the file., But using string to byte array convertor if I try writing to file, again characters will be logged in the file., Can you kindly help me?

 

Thanks again.,

 

Nagaraj Hegde

0 Kudos
Message 15 of 31
(1,530 Views)

Hello,

 

I guess I have got the solution for the first part., Attached is the vi., kindly let me know if I am correct.,

 

Also, by this method, the output I am seeing as a 32 bit integer while I wanted to see16bit.. Any idea how to achieve? The method of combilning 2 bytes makes sense but how to get 2,2 bytes from a stream?

 

Thanks and best regards,

Nagaraj Hegde

 

 

0 Kudos
Message 16 of 31
(1,517 Views)

Hello,

 

I guess I have got the solution for the first part., Attached is the vi., kindly let me know if I am correct.,

 

Also, by this method, the output I am seeing as a 32 bit integer while I wanted to see16bit.. Any idea how to achieve? The method of combilning 2 bytes makes sense but how to get 2,2 bytes from a stream?

 

Thanks and best regards,

Nagaraj Hegde

 

 

Download All
0 Kudos
Message 17 of 31
(1,517 Views)

In your typecast function, you have a constant that goes into the top that defines the datatype.  Right now you have it as an I32, thus you are getting an 32-bit signed integer as a result.

 

You need to change the representation of that constant to either U16 or I16 to get either an unsigned or signed 16-bit integer.

0 Kudos
Message 18 of 31
(1,517 Views)

And why are you trying to read 4096 bytes? If you want to read 16 bits and combine them, read 2 bytes. This has already been mentioned. And how can you tell that you are even reading the bytes in the correct order? Your read is completely asynchronous with the device that is doing the reading.

0 Kudos
Message 19 of 31
(1,503 Views)

Hello,

 

Agreed., I want to read 2 8 bits and combine them to form 16 bits of data., Can you kindly tell me how should I get those 2 different numbers to join them using join numbers? I mean the output of the type cast is giving me only the lower byte always., For ex: if I continuously send 0x0a20 from my instrument, the output of the type cast block will be 0x20 always(reading as I8). Can you help me to extract the 0x0a from this?

 

Thanks and best regards,

Nagaraj Hegde 

0 Kudos
Message 20 of 31
(1,487 Views)