Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

visa serial read and usb 6008 read simultaneously

Have anyone tried using visa serial read and a ni-usb 6008 daq device to read simutaneously? Can this be done?

0 Kudos
Message 1 of 22
(3,600 Views)

Yes, it can be done. Two different hardware interfaces.

 

What is your specific issue?

0 Kudos
Message 2 of 22
(3,595 Views)

Well, what I eventually want to do is to read and save some binary data using VISA. Because I am experiencing that through VISA, it only reads data as STRING ( is it true?). When there is too much data to be read, the system (PC) crashes. This leads to the motivation to find different ways to tackle this problem (By transferring binary data?). Maybe you can help me?

0 Kudos
Message 3 of 22
(3,583 Views)

VISA is meant to communicate via busses. This can be via strings or in binary. When the results arrive in the computer you have to convert this into meaningful data for you. This can be e.g. a series of time and amplitude values stored in an array. The same applies for the 6008 gathered data but most probable not at exact the same times, and I presume with a much greater number of samples.

So what do you want. Storing these data is step 3. First step is gathering the data and you forget the intermediate step of transforming raw data into meaningful data.

greetings from the Netherlands
0 Kudos
Message 4 of 22
(3,579 Views)

So are you saying that if I send in some binary, by using VISA Read Function, I will be reading the same binary data? 

0 Kudos
Message 5 of 22
(3,573 Views)

VISA does not care about binary or any other format. It is transferring bytes.

The question is what and how are you storing data in your pc.

If you store more data than you have memory, you get an errormessage and the program stops.

So what are you communicating from which instrument or system to your system.

too much is too much binary or not binary

greetings from the Netherlands
0 Kudos
Message 6 of 22
(3,570 Views)

I need some help for implementing Serial Read using VISA. I have the following scenario:

 

The data is transferred with structure as -

 

1st byte is ASCII "D"

2nd byte is ASCII "x"

3rd - 6th byte is a binary number for Channel one

7th - 10th byte is a binary number for Channel two

11th&12th byte is a binary number for Channel three

13th&14th byte is a binary number for Channel four

15th&16th byte is a binary number for Channel five

17th&18th byte is a binary number for Channel six

19th&20th byte is a binary number for Channel seven

 

From the above 1st byte to 20th byte, it goes on and repeats itself with all data transferred with MSB first.

 

Would anyone give me some advices for implementing this using VISA serial read?

0 Kudos
Message 7 of 22
(3,555 Views)

Okay

now you give some serious information.

 

The visa returns a string and part of that string is your information.

So first find the start, with match pattern. Find the first occurence of "Dx"

The next 18 bytes is your info. split them from the original string with substring and if you have some extra characters keep them for the next round.

 

These 18 bytes are splitted again into two 4 byte values and 5 two byte values.

Are these integers or doubles and play around in translating them, probably in a subvi to make playing with the values easier.

 

good luck.

greetings from the Netherlands
0 Kudos
Message 8 of 22
(3,551 Views)

Thanks for your promt reply. Please excuse me. I am a bit confused here already. Now i am sending data as binary (byte). I don't understand why we are operating in terms of 'string'?

0 Kudos
Message 9 of 22
(3,550 Views)

no problem.

A string and an array of bytes are the same in LabVIEW, you can "convert" them into each other and this conversion is awfully fast because it only tells the compiler to look in a different way at the memorylocations.

 

And not unimportant. VISA delivers a string to LabVIEW and you can use the string function to find Dx.

After that you can easily convert the 18 bytes in an array of bytes and use the join numbers function to build your values.

 

 

greetings from the Netherlands
0 Kudos
Message 10 of 22
(3,546 Views)

To confirm what I understood,  whatever format VISA delivers data to LabVIEW, LabVIEW through VISA read function will return in one and ONLY format, that is 'String' . By using different LabVIEW string functions, the received data can be arranged and organized to represent the orignal input data structure. Is that right? 

0 Kudos
Message 11 of 22
(1,154 Views)

completely right.

greetings from the Netherlands
0 Kudos
Message 12 of 22
(1,131 Views)

Another senario, I transfer a number, say 12 as BINARY DATA, so VISA will receive this bianary data as byte. Now VISA reads and returns something that is a string. My question is what will this string looks like when it is returned by VISA? If it is not the string '12', what string will VISA return when it is transferred as BINARY DATA? I need  to know if I want to re-organize the data.

What if i want to transfer data like 12,13, 14 as BINARY DATA, what can I expect VISA will return? 

0 Kudos
Message 13 of 22
(1,128 Views)

I don't know which version of LabVIEW you are using but below is a small example of looking at data and "converting" it by telling the compiler that you want to look differently to the data.

starting with a string You see the chars with the value 1 and 2 making the string "12"

later I add the value 12 (ascii formfeed) to this string.

strings and bytes

attached is the vi also in 2011, but you get the same if you place the snippet into an empty vi.

greetings from the Netherlands
0 Kudos
Message 14 of 22
(1,122 Views)

Thanks. It is really helpful.

0 Kudos
Message 15 of 22
(1,109 Views)

I am now experiencing a problem when I send data with the format as 'DX' followed by 18 bytes repeat; DX followed by 18 bytes of data. By using VISA in LabVIEW, I cannot receive the same data structure. When I concatenated the string. It doesn't look right. How can I correct this?

0 Kudos
Message 16 of 22
(1,089 Views)

Hi him,

 

How are you formatting your data to write, could you post your simplified code so we could see what we are working with?

------------------------------
Bill E. | Applications Engineer | National Instruments
0 Kudos
Message 17 of 22
(1,058 Views)

Hi Bill, thanks for wanting to help. I solved the problem by putting the VISA WRITE function in the while loop. However, would you share with me some of your thoughts in improving serial data transfer speed in general?

0 Kudos
Message 18 of 22
(1,047 Views)

Glad to hear that the problem was solved. In general, increasing the baud rate that the serial port is using will allow for quicker communication; however, this is highly dependent on the device you are using and the device you are connecting to as there are “standard” rates that are used based on the device.

 

Also, make sure the code that is reading from the port is in a separate loop (i.e. use a consumer/producer design pattern).

------------------------------
Bill E. | Applications Engineer | National Instruments
0 Kudos
Message 19 of 22
(1,029 Views)

Hi Bill,

You said: Make sure the code that is reading from the port is in a separate loop (i.e. use a consumer/producer design pattern)

Can you give me a simple example in coding the VI? 

0 Kudos
Message 20 of 22
(1,023 Views)

Here is an example of using a producer/consumer design pattern for data acquisition. This example uses DAQmx functions, but it illustrates the architecture and queuing well. The basic idea is that you have a producer loop (top one) that reads in your data as fast as possible and then queues that data up to be passed to the consumer loop were the processing is done; thereby, not slowing down the acquisition.

 

You can also find this pattern by in LabVIEW going to File » New » From Template » Frameworks » Design Patterns » Producer/Consumer Design Pattern (Data).

------------------------------
Bill E. | Applications Engineer | National Instruments
0 Kudos
Message 21 of 22
(577 Views)

This is very clever. Thanks for showing me.

0 Kudos
Message 22 of 22
(570 Views)