Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

SR830 data storage for rs232

Hi,

I found a LabVIEW code here which can storage data from input signal (e.g.A/I)in SR830 and transfer it by the GPIB.

I used function generator to generate a sine wave with frequency:30Hz& Vp-p:100mVolt , conencting to SR830.

Clearly ,I got a correct result when i used the code by GPIB communication interface(left graph).

Than,I tried to change the communication interface RS232 to accept the same signal,but it has mistakes(right graph).

 

data_storge_GPIB_RS232.png

 Here is original code "data storage for GPIB"

GPIB.png

 

Here is rewrite code for RS232 by myself,but what's wrong i did?

RS232.png

 

Download All
0 Kudos
Message 1 of 5
(6,565 Views)

format strings are case sensitive and well,,,,, yours are wrong.

 

%d formats a decimal integer  "%8.0D" makes no sense at all.  The help file will guide you towards getting the actual format specifiers you need from the SR830 manual.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(5,552 Views)
And get rid of the sequence structure and the VISA Bytes at Serial Port. You have a termination character and you would simply do a read with some arbitrarily high byte count.
0 Kudos
Message 3 of 5
(5,548 Views)

The SR830 expects three integer arguments (separated by commas) for the TRCA? query:

* i = 1 or 2 specifies which buffer to download from

* j >= 0 specifies the starting point

* k>=1 specifies how many points to download

 

If you know k, you can calculate the exact number of bytes in the response. For your code, which downloads 4000 points at a time, that will be something like 60 kB (if memory serves, the response in ASCII transfer mode is 15 bytes/value). Make sure that you're not hitting any timeout or serial buffer size limits with a transfer of that size.  

 

Edit: You have your bitrate set to 9600 baud (1200 bytes/second) and a 10 second timeout. That will read 12 kB before timing out, or 1/5th of your transfer. The 830 supports baud rates up to 19,200, which will help, but you'll also need either a longer timeout or to transfer your data in smaller chunks. 

Message 4 of 5
(5,536 Views)

Hello! I’d like to ask how to make this program run infinitely, so it’s always reading the outputs from both channels. Could you help me with this? Thank you!

0 Kudos
Message 5 of 5
(153 Views)