I have been using the ADP3450 with a Raspberry Pi 4. I am running a C++ script to pull data from 3 channels at a target sampling rate of 6 MSPS, using 16-bit signed data type. Using the record acquisition mode and reading in a loop. But I am getting effectively about 1 MSPS no matter how fast I set the ADP's sampling rate. I am using a USB cable which I have measured is getting 38-39 Mbps. This should equate to ~5 MSPS maximum, so I don't know what is happening to get a much slower rate. My code is pasted below, the initialize function and the querying function.
Also, when setting the sample rate to 1 MSPS just to verify, I noticed the USB transfer rate is only 8 Mbps. But at or above 4.5 MSPS, the USB transfer rate is maximized at 38-39 Mbps. At 8 Mbps, this only equates to 0.5 MSPS, so why does the device send data at half the desired rate in this instance?
e.g. the file size at 6 MSPS is 830 MB per channel. but for 1 MSPS it is 190 MB when it should be 600 MB
Thank you,
Abby
Code:
void initOscope(void) {
char szError[512] = {0};
cout << "Entered initOscope()\n"; //DEBUG
printf("Open automatically the first available ADPro device\n");
// if(!FDwfDeviceConfigOpen(-1, 1, &hdwf)) {
if(!FDwfDeviceOpen(-1, &hdwf)) {
FDwfGetLastErrorMsg(szError);
printf("ADPro device open failed\n\t%s", szError);
return;
}
//enable channels
for(int c = 0; c < NUM_CHANNELS_USED; c++){
FDwfAnalogInChannelEnableSet(hdwf, c, true);
}
//set pk2pk input range for all channels
FDwfAnalogInChannelRangeSet(hdwf, -1, 5);
// wait at least 2 seconds with Analog Discovery for the offset to stabilize, before the first reading after device open or offset/range change
Wait(2);
// start
FDwfAnalogInConfigure(hdwf, 0, true);
cout << "Exiting initOscope()...\n"; //DEBUG
}
...................................
while (stopRecord == false && newFileFlagRf == false) {
// get the samples for each channel
for(c = 0; c < NUM_CHANNELS_USED; c++) {
if(!FDwfAnalogInStatus(hdwf, true, &sts)) {
cout << "FDwfAnalogInStatus() error\n";
}
if((sts == stsCfg || sts == stsPrefill || sts == stsArm)){
// Acquisition not yet started.
continue;
}
FDwfAnalogInStatusRecord(hdwf, &cAvailable, &cLost, &cCorrupted);
if(!cAvailable) continue; //only get data samples if there are any available
if (c == CH1_REF) {
FDwfAnalogInStatusData16(hdwf, c, sampleFileBuf1, 0, cAvailable);
Question
AbbyM
Hello,
I have been using the ADP3450 with a Raspberry Pi 4. I am running a C++ script to pull data from 3 channels at a target sampling rate of 6 MSPS, using 16-bit signed data type. Using the record acquisition mode and reading in a loop. But I am getting effectively about 1 MSPS no matter how fast I set the ADP's sampling rate. I am using a USB cable which I have measured is getting 38-39 Mbps. This should equate to ~5 MSPS maximum, so I don't know what is happening to get a much slower rate. My code is pasted below, the initialize function and the querying function.
Also, when setting the sample rate to 1 MSPS just to verify, I noticed the USB transfer rate is only 8 Mbps. But at or above 4.5 MSPS, the USB transfer rate is maximized at 38-39 Mbps. At 8 Mbps, this only equates to 0.5 MSPS, so why does the device send data at half the desired rate in this instance?
e.g. the file size at 6 MSPS is 830 MB per channel. but for 1 MSPS it is 190 MB when it should be 600 MB
Thank you,
Abby
Code:
void initOscope(void) {
char szError[512] = {0};
cout << "Entered initOscope()\n"; //DEBUG
printf("Open automatically the first available ADPro device\n");
// if(!FDwfDeviceConfigOpen(-1, 1, &hdwf)) {
if(!FDwfDeviceOpen(-1, &hdwf)) {
FDwfGetLastErrorMsg(szError);
printf("ADPro device open failed\n\t%s", szError);
return;
}
//enable channels
for(int c = 0; c < NUM_CHANNELS_USED; c++){
FDwfAnalogInChannelEnableSet(hdwf, c, true);
}
//set pk2pk input range for all channels
FDwfAnalogInChannelRangeSet(hdwf, -1, 5);
//acquisition mode
FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeRecord);
//sample rate
FDwfAnalogInFrequencySet(hdwf, SAMPLE_RATE);
FDwfAnalogInRecordLengthSet(hdwf, 0);
// wait at least 2 seconds with Analog Discovery for the offset to stabilize, before the first reading after device open or offset/range change
Wait(2);
// start
FDwfAnalogInConfigure(hdwf, 0, true);
cout << "Exiting initOscope()...\n"; //DEBUG
}
...................................
while (stopRecord == false && newFileFlagRf == false) {
// get the samples for each channel
for(c = 0; c < NUM_CHANNELS_USED; c++) {
if(!FDwfAnalogInStatus(hdwf, true, &sts)) {
cout << "FDwfAnalogInStatus() error\n";
}
if((sts == stsCfg || sts == stsPrefill || sts == stsArm)){
// Acquisition not yet started.
continue;
}
FDwfAnalogInStatusRecord(hdwf, &cAvailable, &cLost, &cCorrupted);
if(!cAvailable) continue; //only get data samples if there are any available
if (c == CH1_REF) {
FDwfAnalogInStatusData16(hdwf, c, sampleFileBuf1, 0, cAvailable);
}
else if (c == CH2_REF) {
FDwfAnalogInStatusData16(hdwf, c, sampleFileBuf2, 0, cAvailable);
}
else if (c == CH3_REF) {
FDwfAnalogInStatusData16(hdwf, c, sampleFileBuf3, 0, cAvailable);
}
FDwfDeviceClose(hdwf); //close the device
}
Link to comment
Share on other sites
27 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now