05-15-2012 06:24 AM
Have anyone tried using visa serial read and a ni-usb 6008 daq device to read simutaneously? Can this be done?
05-15-2012 08:01 AM
Yes, it can be done. Two different hardware interfaces.
What is your specific issue?
05-15-2012 02:41 PM
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?
05-15-2012 02:55 PM
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.
05-15-2012 03:23 PM
So are you saying that if I send in some binary, by using VISA Read Function, I will be reading the same binary data?
05-15-2012 03:29 PM
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
05-17-2012 01:24 PM
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?
05-17-2012 01:33 PM
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.
05-17-2012 01:43 PM
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'?
05-17-2012 01:51 PM
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.
05-17-2012 02:18 PM
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?
05-18-2012 06:06 AM
05-18-2012 06:26 AM
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?
05-18-2012 10:00 AM
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.
attached is the vi also in 2011, but you get the same if you place the snippet into an empty vi.
05-18-2012 03:41 PM
Thanks. It is really helpful.
05-31-2012 11:43 AM
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?
06-03-2012 05:22 PM
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?
06-04-2012 12:04 PM
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?
06-05-2012 06:27 PM
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).
06-06-2012 12:38 AM
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?
06-07-2012 05:53 PM
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).
06-08-2012 02:51 AM
This is very clever. Thanks for showing me.