Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read oscilloscope data in real time

My oscilloscope is "Rohde & Schwarz rtb2004", and I need to read the acquired data of the oscilloscope in real time on the PC (USB-TMC that I use). I have tried to send SCPI commands "SINGle" and "CHAN: DATA? "To perform “Single acquisition” mode, and loop multiple times. However, some sampling points will be lost between each acquisition. I try to use continuous sampling mode, but how can I read data while sampling is in progress? If I have to wait for the “Continuous acquisition” to finish before reading the data, is there a better way to obtain continuous real-time data through the oscilloscope? If I can get advice, I would appreciate it!

0 Kudos
Message 1 of 9
(5,249 Views)

Hi,

 

you need to synchronise to the end of the acquisition before you read the data.

Sequence:

SINGle

*OPC?

CHAN:DATA?

 

Best Regards

Milo

0 Kudos
Message 2 of 9
(5,222 Views)

I synchronized every time after sampling, and my code is the same as yours.

But each synchronization takes about 0.6ms (sampling rate: 20kSa / s). The oscilloscope stops sampling during this period of time, so the data of this period is lost, about 12 sampling points. So I want to try the continuous sampling mode (RUNContinous),but I don't know how to read the data. 

But still thank you for your help ~

 

Code:

while(1)

{

SING     //

*OPC? //Need time about 0.6ms, lost data.

CHAN:DATA?

}

 

0 Kudos
Message 3 of 9
(5,217 Views)

this is  the method of my read oscilloscope data .but  I don't know miss data or not .

":ACQ:POIN:VAL 10000; only sampling 10000 point 

  

sprintf_s(cmd, ":CHAN%d:DATA?", channel);
GpibWrit(Addr_Osc, cmd);
Sleep(50);
j = 7;
for (i = 0; i < 10000; i++)
{
V = double(*(buf + j ));
*(hV + i) = V;
j++;
}
sprintf_s(cmd, ":CHAN%d:DATA:YOR?", channel);
ReadBuff_Osc = GpibRead(Addr_Osc, cmd, 10);
Regex(NumCode, ReadBuff_Osc, &MatchNumber, MatchPchar);
YOrigin = atof(MatchPchar[0]);

sprintf_s(cmd, ":CHAN%d:DATA:YINC?", channel);
ReadBuff_Osc = GpibRead(Addr_Osc, cmd, 10);
Regex(NumCode, ReadBuff_Osc, &MatchNumber, MatchPchar);
YIncrement = atof(MatchPchar[0]);

sprintf_s(cmd, ":CHAN%d:DATA:XOR?", channel);
ReadBuff_Osc = GpibRead(Addr_Osc, cmd, 10);
Regex(NumCode, ReadBuff_Osc, &MatchNumber, MatchPchar);
XOrigin = atof(MatchPchar[0]);

sprintf_s(cmd, ":CHAN%d:DATA:XINC?", channel);
ReadBuff_Osc = GpibRead(Addr_Osc, cmd, 10);
Regex(NumCode, ReadBuff_Osc, &MatchNumber, MatchPchar);
XIncrement = atof(MatchPchar[0]);

for (i = 0; i < 10000; i++)
{
*(hV + i) = YOrigin + *(hV + i)*YIncrement;
}

0 Kudos
Message 4 of 9
(5,163 Views)

Hi,

Thanks for your reply.

 

These 10,000 data points are the result of once "SINGle" acquisition by the oscilloscope(Such as 0.5s to complete,20kSa/s). But I need to perform a loop of "SINGle" (such as 5000 SINGle, 5000 * 0.5s, 5000*10,000 points), need to synchronize between each sampling, which will take time (* OPC?). Of course your code is no problem for once single sampling.

 

Thank you again for your help.

 

Hao

 

 

0 Kudos
Message 5 of 9
(5,152 Views)

Hi, with RUNContinous you will not manage to synchronize properly. You have to use the single acquisition mode. I'd set the acquisition points to maximum possible.

However, you will always have gaps in acquisitons.

 

BR

Milo

0 Kudos
Message 6 of 9
(5,131 Views)

Yes, I agree with you.

 

I think I chose the wrong hardware device. The oscilloscope is not suitable for continuous monitoring of the external environment for a long time. I think I should use a microcontroller to connect the sensor to collect data.

 

Thank you very much for your reply and your time.

0 Kudos
Message 7 of 9
(5,128 Views)

depending on the speed that you need and the resolution, NI sells nice hardware that can do that.

Continuous acquisition can be done by a lot of IOcards.

greetings from the Netherlands
0 Kudos
Message 8 of 9
(5,121 Views)

Hi,

 

Thank you for your suggestion, I am now going to give up using an oscilloscope and choose Raspberry Pi or Arduino or NI card.

 

Hao

0 Kudos
Message 9 of 9
(5,100 Views)