Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Use NI-488.2 to Query Signal Source Analyzer trace info.

I am trying to use a SCPI query to pull trace information from a
Agilent Signal Source Analyzer (Model E5052A).

The results are comma seperated string types (ASCII).
They are around 904 points and is about 20 Kilobytes.

My actually code is as follows:

Dim resultsData     As String * 18080

Call Send(BoardID, GPIBAddr, ":CALCulate:PN1:TRACe1:DATA:SDATa?", DABend)
Call Receive(BoardID, GPIBAddr, resultsData, DABend)

Now once I do this the "resultsData" shows me partial results (comma seperated values).
Since a string limitation is 255 characters it is truncating.

1. How do I get the complete trace information.
2. Is their a way wherein I could read the data in chunks.

I would appreciate any help on this ASAP.

Thanks

0 Kudos
Message 1 of 6
(4,784 Views)
Hi,
 
You will have to set a higher buffer size or count, if the data you're receiving is much larger than buffer size, try running call receive in a loop. You can use the sipping exapmles for this and refer to NI488.2 help for further details on call receive function. Also, check your manual to see if the data you receive are send with commas or no. Why is it important for you to receive data in chunks and are you using vs or cs programming?
 
Thanks,
Arjun K
National Instruments
Applications Engineer
0 Kudos
Message 2 of 6
(4,761 Views)
Thank you Arjun for the reply.
Its works good when I increase the buffer size.
But it doesn't work good when I try to get the data in chunks.
The code is given below:

    'Data download in one shot
    -----------------------------------
    Dim data as string * 20000
   
   "Data writting to temp.csv file in progress..."

    'read from E5052A
    Call Receive(giBoardID, 2, data, DABend)
   
    If (ibsta And EERR) Then GoTo READERR

    Open "temp.csv" For Output As #1        'Store the data in a file
    Print #1, data                                           'Write data
    Close #1                                                  'Close the file

    "Done writting data to the temp.csv file ."
     ----------------o0o------------------------------
    'Data download in chunks
    ---------------------------------
    Dim data as string * 1024
   
   "Data writting to temp.csv file in progress..."

    Do
        'read from E5052A
        Call Receive(giBoardID, 2, data, DABend)
   
        If (ibsta And EERR) Then GoTo READERR

        If Not bOnlyOnce Then
            bOnlyOnce = True
           
            Open "temp.csv" For Output As #1        'Store the data in a file
            Print #1, data                                           'Write data
            Close #1                                                  'Close the file
        Else
            Open "temp.csv" For Append As #1        'Store the data in a file
            Print #1, data                                            'Write data
            Close #1                                                   'Close the file
        End If
        data = Replace(data, vbLf, "\n")
    Loop Until InStr(1, data, "\n")

    "Done writting data to the temp.csv file ."
  ------------------o0o---------------------------------------
Please let me know if their is better way to handle data in chunks.

Handling data in chunks would be better b'cos in future the data file (it is comma seperated one) might increase in size or
number of data points might increase. Having said that vb string can only goto up to say about 60000 bytes max.
By the way I am using visual basic 6.
Thank you
0 Kudos
Message 3 of 6
(4,751 Views)

Hello,

Your code looks good as far as getting data and storing it is concerned, however your code does not parse through the data to get rid of commas. This is a job of instrument drivers. You have to check with the manufacturer of your instrument if there are any specific instrument driver calls that will parse through the data to remove commas. You might even have to write a code yourself if such dirver calls are unavailable and parse through the data to search and delete commas. In that case, run your acquired string through a loop searching for comma and delete it. Before you start writing your code, contact the manufacturer.

Thanks,

Arjun K

National Instruments
Applications Engineer
0 Kudos
Message 4 of 6
(4,701 Views)
Hi Arjun
I am getting data points which are comma seperated.
For example frequency,power (10.1800975118,-65.5865721999)

So if I get rid of the commas then it will be difficult to distinguish the data.

Finally I write these data points to a comma seperated file (.csv)
and save it in the database.

Now I am having trouble with how to crunch/compress the .csv file and
reduce the file size before saving it to the access database.
The file size is (32Kilobytes).

Any help on this would be highly appreciated.

Thanks once again for all your help.

- Ravi

0 Kudos
Message 5 of 6
(4,666 Views)
Hi Ravi,
 
There a couple of options for you. First, you can either directly write the data to your database, instead of saving it to a file and if that is not an option then write to a binary file. If you don't know how to write to a binary file, then please refer to the DAQ large data stream example. If you don't have DAQ drivers, then you can refer to other web resources to find examples of this. I'm afraid that you won't be able to compress this file in any other fashion.
 
Thanks,
Arjun K
National Instruments
Applications Engineer
0 Kudos
Message 6 of 6
(4,637 Views)