08-03-2010 10:42 AM - edited 08-03-2010 10:46 AM
Greetings,
I'm using an PXI5122 board to acquire a discretely amplitude modulated sine wave. The period of the wave is 738 us. Amplitude = 0.25*(i%5) where i is the period number.
Zero crossings of the sine wave are marked by a digital pulse. I'm using this to trigger a multi-record acquisition at 20 MS/s. Each record is 738/(1/20) = 14760 points. Here is my pseudocode:
1. Start acq triggered by digital pulse.
2. Are 14760 points done? If not wait.
3. If yes, fetch ith record of 14760 points.
4. i=i+1
5. Goto 2
Actual code:
niScope_init ("PXI1Slot4", NISCOPE_VAL_FALSE, NISCOPE_VAL_FALSE, &vi));
niScope_SetAttributeViBoolean(vi, VI_NULL, NISCOPE_ATTR_ALLOW_MORE_RECORDS_THAN_MEMORY, NISCOPE_VAL_TRUE));
niScope_ConfigureVertical(vi, "0", 2, 0, NISCOPE_VAL_DC, 1.0, NISCOPE_VAL_TRUE));
niScope_ConfigureHorizontalTiming(vi, 20e6, 14760, 0, 1024, NISCOPE_VAL_TRUE));
niScope_ConfigureTriggerEdge (vi, NISCOPE_VAL_EXTERNAL, 1.5, NISCOPE_VAL_POSITIVE, NISCOPE_VAL_DC, 0, 0));
niScope_InitiateAcquisition(vi));
niScope_ActualNumWfms(vi, "0", &numWaveform));
niScope_ActualRecordLength(vi, &actualRecordLength));
numWaveform = numWaveform / 1024;
wfmInfoPtr = malloc(sizeof(struct niScope_wfmInfo) * numWaveform);
waveformPtr = malloc (sizeof(ViInt16) * actualRecordLength * numWaveform);
if (waveformPtr == NULL || wfmInfoPtr == NULL) handleErr(NISCOPE_ERROR_INSUFFICIENT_MEMORY);
checkErr(niScope_SetAttributeViInt32 ( vi, VI_NULL, NISCOPE_ATTR_FETCH_NUM_RECORDS, 1));
do{
pointsDone=0;
while(pointsDone<14760){
checkErr(niScope_GetAttributeViReal64 (vi, VI_NULL, NISCOPE_ATTR_POINTS_DONE, &pointsDone));
}
checkErr(niScope_SetAttributeViInt32 ( vi, VI_NULL, NISCOPE_ATTR_FETCH_RECORD_NUMBER, record));
handleErr(niScope_FetchBinary16 (vi, "0", 0, actualRecordLength, waveformPtr, wfmInfoPtr));
record++;
// write data to disk
}while(!kbhit());
When I look at the data, I see that every alternate trigger has been missed. Recall amplitude = 0.25*(i%5). The amplitudes from the digitized data are 0, 0.5. 1.0, 0.25, 0.75, 0 .... instead of 0, 0.25, 0.5, 0.75, 1.0, 0 ....
I realize that the fetch function takes time as does the writing to disk, but I thought the trigger is rearmed within 100 us (<738 us in my case) and the board acquires data into onboard memory at every trigger. Since I'm missing every alternate trigger I suspect something else is wrong. See attached for waveforms.
I know it is missing alternate triggers and not random triggers because if I generate exactly 2048 periods of the sine wave and the triggering pulse, I end up with exactly 1024 acquired records.
Any help would be most appreciated.
Thanks,
Regards,
Kartik
08-03-2010 02:32 PM
Hello Kartik,
Sampling at 20 MS/s and taking 14760 points will yield a record that lasts for exactly 738 µs, which is the same as the period of the modulated sine wave. The rearm time, more specifically, is between the end of the record and when you can recognize another reference trigger. Thus, you would need at least 3 µs for the 5122, with TDC disabled, between the end of one record to when you could trigger the next record.
This is the likely reason you are missing every other record since you are not giving ample time to rearm the trigger after the end of the record (as opposed to after a trigger). If it were the case that the rearm time could be satisfied beginning after a trigger occurs, then you could ideally retrigger immediately as long as your record length was long enough to satisfy the rearm time; unfortunately, this is not the case as there will always be some downtime at the end of a record and when the next one may retrigger.
If you are sampling for the entire period of the modulated sine wave and then trying to trigger to catch the entire next period of the wave, could you just take one long acquisition such that it would not require you to rearm? I am not sure if this is possible for your application, but the fetch forever case is just an idea. Hope this helps, and best of luck!
08-03-2010 04:40 PM
Hi Daniel,
I get it. I though the trigger rearms 1-100 us after a previous trigger. But I guess the rearming starts 1-100 us after the end of the record startest by the previous trigger. I'll try and come up with something.
Thanks,
Regards,
Kartik