04-24-2020 12:23 PM
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!
04-24-2020 03:21 PM
Hi,
you need to synchronise to the end of the acquisition before you read the data.
Sequence:
SINGle
*OPC?
CHAN:DATA?
Best Regards
Milo
04-24-2020 04:12 PM
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?
}
04-25-2020 09:20 PM
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;
}
04-26-2020 04:37 AM
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
04-27-2020 02:11 AM
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
04-27-2020 08:55 AM
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.
04-27-2020 11:47 AM
04-28-2020 11:33 AM
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