01-25-2012 01:49 AM
Q1. I am reading data from adc using serial communication with VISA, i am using baud rate of 38400Hz, with 12 bit adc and a total of 8 channels are confihured, so as per configuration, sample rate should be 800 s/s but i am getting 200-300 s/s, what could be the reason for this?
Q2. what is the function of collector.vi( although i had referred the manual and help but i am not getting wht actually is its function), i am getting round about 200 s/s without using collector vi and with this collector.vi sample rate increases very much.
Q3. Can we define sample rate and no. of samples acc. to our requirement for visa serial communication( as in case of daq assistant), maximum limit of the daq card i am using is 800, then can i program visa for getting lesser no. of samples(without changing baud rate) .
01-26-2012 08:29 PM
Q1: First, how is the data formatted in the string? I looked at your convoluted code but without sample data, I could not be sure what is being sent from the remote device. Specifically, how are the 12 bits of data converted to characters? How do you know which data goes with which channel? How are groups of data separated, if at all?
Next. With 10 bits per character and assuming two bytes per channel and no synchronizing characters you transmit 160 bits per data set. 38400/160 = 217.5 data sets per second. Maximum. It appears that you may be sending "0" "1000" or "2000" as channel markers. That would add 9 or 12 characters (are you sending"0' or "0000"?). 205.9 Hz or 202.3 Hz.
Q2. From the help description it appears that the Collector acts like a circular buffer.
Q3. VISA and serial communications do not define the sample rate although they may limit the maximum amount of dat ayou can transfer. This effectively puts a maximum lmiit on the average sample rate. See the Next paragraph under Q1.
Lynn
01-27-2012 05:23 AM
After reading data from VISA read, i want to separte data of each channel into different string and for this i am using 1st bit of data which represents channel's address( which i am getting by using scan from string to separate next string character and then anding the given result with F000 to get the channel address), i am comparing the 1st bit with 0, 1000, 2000 to get the dat of the required channel and then to get the data of the corresponding channel i am again anding the data ( excluding next string character) with FFF to get the 12 bit data.
i am not getting, what do you mean by no synchronizing characters, and how 160 bits are transmitted per data set, please explain this.
and i am also not getting constant sample rate, e.g for 1st second it is 334s/s, then for next second it is 264s/s, then 349s/s and so on, what could be the reason for this. how can i get increased and constant sample rate?
01-27-2012 11:16 AM
OK. I am starting to get the picture. The data for each channel is sent as a string of 4 characters. First character is channel number and has acceptable values of 0, 1, 2, ..7. Last three characters are ASCII characters representing human readable hex data [0..9] or [A..F]. The attached VI will convert such a string to a channel number and a data value with a lot less effort than what you are doing.
Several more questions about the string format and the data communications:
1. You have Termination Character enabled. Does your remote device send a line feed character at the end of each data set?
2. Does a data set include the 4-character string for one channel or does it include all 8 channels?
3. Does the remote device send continuously or does it have gaps between transmissions?
4. Do you send any commands to the remote device?
5. Can the remote device send any characters for any reason which are not part of the data strings?
Synchronizing characters are things like the channel ID characters and the line feed (which may or may not be at) the end of the strings. Since your channel ID are values which can alos occur in the data, it may be difficult to tell where a channel string starts and ends.
The lack of constant sample rate may be the result of several things. As I pointed out yesterday we are really talking about communications rate, not sample rate. You check Bytes at Port once, outside the loop, immediately after initializing the port. I am a bit surprised that the output is not always zero, in which case you would never get any data. Usually one does not use both Bytes at Port and Termination Character Enabled at the same time. Both serve similar function but in different ways and they tend to conflict with each other. If your device sends line feeds, then you do not need Bytes at Port. If it does not, then Bytes at Port should be inside the loop and you need a more complex string handler because you will not in general get a complete data set each time.
Lynn
01-30-2012 06:37 PM
thanks a lot, your program helped a lot in reducing the complexity of my program, with little modification in your program now my program is quite simpler, although the sample rate is still not defined and it's also varying every second, i am not getting where is the problem.
1.yes the termination character is enabled and adc is sending line feed character at the end of each data set.
2.The data set includes 4 character string from each channel, it does not include all 8 channels.
3.yes the device is sending continously, there is no gap in between.
4.no we are not sending any scommands to athe adc.
5.no, the device is not sending any character.
we have incorporated line feed character at the end of each channel strings just to determine where the string starts and ends, and it's not that output is never zero, it's coming like this firstly the data is coming for channel 0( in this case there is no data at other channels), then for channel 1 and so on but transmission is fast that 0 is not encountered, i had also removed bytes at port as you said but still there is no differenc in sample rate, and there is one more error coming, although this error is not showing when i continously run the program, i observed this error( error -1073807252 in visa read) when i checked my program through highlighter, and this comes for first time only, in 2nd cycle it gets removed on it's own, i know this is framing error and i also tried to remove this but it still comes for the first time when i run the program.
I am attaching the new vi, i had also shown error there
01-30-2012 08:43 PM
As your program is presently configured it looks like you are getting data from up to five channels. If data comes from any channel other than 0..4, it will get processed as though it were from channel 0, the default.
For 5 channels at 4 characters per channel plus a line feed you will receive 21 characters in each data set. At with your serial port settings you can get a maximum of 182 data sets per second. 1 start bit, 8 data bits, 1 stop bit = 10 bits per character. 210 bits per data set. 38400/210 = 182.86 data sets per second. For only three channels the rate could be as high as 295.38 data sets per second.
Because your remote device transmits continuously the first data set received will generally be a partial set. It should be discarded. A data set only takes 3 to 6 ms to transmit. The time it takes the OS to set the buffer size and take the first reading is unknown but may well be longer than those few milliseconds. This accounts for the overflow error at the beginning.
Another thing which might speed up your loop is to move the charts to the file loop. Drawing a chart and telling the OS to display it might take eough time to be noticeable in your loop rate. Use of local variables can slow things down also because they operate in the UI thread. Try transferring the data via a queue.
Lynn
01-31-2012 01:08 AM
is there any simpler example avaialble for queue operation, i had seen many but they are difficult to understand, i don't have much knowledge of transferring data via queue. it would be very helpful if you will post some simpler example for this queue operation.
01-31-2012 06:38 AM
Look at the Producer/Consumer Design Pattern (Data). It is found from the main LV menu at File >> New.. (NOT New VI) >> VI >>From Template >> Frameworks >> Design Patterns >> Producer/Consumer Design Pattern (Data). It shows how to Obtain a queue reference, how to put data into the queue (Enqueue), how to take data out of the queue (Dequeue), and how to Release the queue as the program ends.
Data in a queue is like beads on a string. You push data in at one end, one element at a time and take it out at the other end, also one element at a time.
Also read the detaield help for the queue functions. It has a link to the Queue Basics.vi example.
Lynn
01-31-2012 07:21 AM
i have done some changes in the program as you said, but still the sample rate problem is not constant, how to define or increase the sample rate. i am attaching my changed vi and also the data file.
01-31-2012 09:38 AM
You will probably never get a constant sample rate when you are pushing serial communications to the limit.
1. RS-232 ia an asynchronous protocol. Even though many devices transmit without interruption, this is not required and may not always occur, even with the same device.
2. Software timed data acquisition on any desktop OS will always have jitter. Occasionally very large delays (~100 ms) may occur.
3. Dequeuing data in parallel will give very inpredictable results. Well, actually I can predict that it will produce results you will not like much. Queues should only be read (dequeued) at one place to avoid loss of data.
4. As I pointed out in an earlier post the data communication rate limits how much data you can transmit to 180-300 data sets per second, MAXIMUM, if no other delays occur. Unless you can increase baud or decrease the amount of data being transmitted, you cannot do any better.
Lynn