ssm Posted February 3, 2022 Share Posted February 3, 2022 (edited) Dear Help, I am trying to sync the scope in reading a signal applied using WaveGen for measurement, here is the code/pseudocode for the scope: SampleRate = 170.4997 NoSamples = 302 MaxVdd = 0.5 FDwfAnalogInChannelEnableSet(hdwf, -1, true); FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeSingle); FDwfAnalogInChannelRangeSet(hdwf, -1, 2); FDwfAnalogInFrequencySet(hdwf, SampleRate); FDwfAnalogInBufferSizeSet(hdwf, NoSamples); FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1); //(samples/2-10)/frequency FDwfAnalogInTriggerPositionSet(hdwf, (NoSamples/2 -10) / SampleRate); FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 1.0); FDwfAnalogInTriggerTypeSet(hdwf, trigtypeTransition); FDwfAnalogInTriggerLevelSet(hdwf, 0.0); FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive); FDwfAnalogInChannelFilterSet(hdwf, -1, filterAverage); FDwfAnalogInConfigure(hdwf, true, false); WaveGen setting MeasurementTime = NoSamples/SampleRate CustomSignalFreq = 1/MeasurementTime FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true); FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcCustom); FDwfAnalogOutNodeOffsetGet(hdwf, 0, AnalogOutNodeCarrier, &pvoltOutOffset); for (int i1=0; i1<NoSamples; i1++) { InputFileSamples[i1]=(OriginalInputFileSamples[i1]-pvoltOutOffset)/EXP->MaxVdd; } FDwfAnalogOutNodeDataSet(hdwf, 0, AnalogOutNodeCarrier, InputFileSamples, NoSamples); FDwfAnalogOutNodeFrequencySet(hdwf, 0, AnalogOutNodeCarrier, CustomSignalFreq); FDwfAnalogOutRunSet(hdwf, 0, 1.0 / CustomSignalFreq); FDwfAnalogOutNodeAmplitudeSet(hdwf, 0, AnalogOutNodeCarrier, MaxVdd); The Measured Signal is the one read by the scope and it is supposed to be like the signal above it, please can you tell me what am I doing wrong? thank you for the help, ssm Edited February 3, 2022 by ssm Link to comment Share on other sites More sharing options...
0 attila Posted February 3, 2022 Share Posted February 3, 2022 Hi @ssm The transition triggering is more complex. It requires specifying the TriggerChannel, Level, Hysteresis, Condition, Length, LengthCondition You could simply make the Scope trigger on Wavegen like this:FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1) # trigger on analog-out 1 start FDwfAnalogInTriggerPositionSet(hdwf, NoSamples/SampleRate/2) # T0 on left, trigger the first sample ... FDwfAnalogInConfigure(hdwf, 0, 1); make sure the analog-in as suffice time for prefill/pretrigger before analog-out is started, use software sleep or AnalogOutWait FDwfAnalogOutConfigure(hdwf, 0, 1); Link to comment Share on other sites More sharing options...
0 ssm Posted February 3, 2022 Author Share Posted February 3, 2022 thank you @attila for the quick reply, sorry I forgot to mention that I do have a pulse at the start the goes up to 0.5V and then -0.5 to trigger the scope, you can notice that from my figure above, I thought this should be good enough to trigger the system thanks again ssm Link to comment Share on other sites More sharing options...
0 ssm Posted February 3, 2022 Author Share Posted February 3, 2022 thank you again for the reply, >>make sure the analog-in as suffice time for prefill/pretrigger before analog-out is started, use software sleep or AnalogOutWait is there a way to estimate this time based on the SampleRate and the measurement time? or it is not relevant? Link to comment Share on other sites More sharing options...
0 ssm Posted February 3, 2022 Author Share Posted February 3, 2022 it worked, thanks a lot, I added Wait(0.1) Link to comment Share on other sites More sharing options...
0 attila Posted February 3, 2022 Share Posted February 3, 2022 Hi @ssm The delay should be at least, prefill = MAX(0, TriggerPosition - NoSamples/SampleRate/2) For precise measurements to prevent temperature drift, if your application opens and closes the device often or you start this app often, use run or stop as initialization before open. The default shutdown will reduce power consumption app exit or device close but cause slight temperature drift.dwf.FDwfParamSet(DwfParamOnClose, c_int(0)) # 0 = run, 1 = stop, 2 = shutdown The first open or offset change should wait 1-2 seconds for these to stabilize, or 10-20 minutes to reach stable operation temp. Link to comment Share on other sites More sharing options...
Question
ssm
Dear Help,
I am trying to sync the scope in reading a signal applied using WaveGen for measurement,
here is the code/pseudocode for the scope:
SampleRate = 170.4997
NoSamples = 302
MaxVdd = 0.5
FDwfAnalogInChannelEnableSet(hdwf, -1, true);
FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeSingle);
FDwfAnalogInChannelRangeSet(hdwf, -1, 2);
FDwfAnalogInFrequencySet(hdwf, SampleRate);
FDwfAnalogInBufferSizeSet(hdwf, NoSamples);
FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1);
//(samples/2-10)/frequency
FDwfAnalogInTriggerPositionSet(hdwf, (NoSamples/2 -10) / SampleRate);
FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 1.0);
FDwfAnalogInTriggerTypeSet(hdwf, trigtypeTransition);
FDwfAnalogInTriggerLevelSet(hdwf, 0.0);
FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive);
FDwfAnalogInChannelFilterSet(hdwf, -1, filterAverage);
FDwfAnalogInConfigure(hdwf, true, false);
WaveGen setting
MeasurementTime = NoSamples/SampleRate
CustomSignalFreq = 1/MeasurementTime
FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true);
FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcCustom);
FDwfAnalogOutNodeOffsetGet(hdwf, 0, AnalogOutNodeCarrier, &pvoltOutOffset);
for (int i1=0; i1<NoSamples; i1++) {
InputFileSamples[i1]=(OriginalInputFileSamples[i1]-pvoltOutOffset)/EXP->MaxVdd;
}
FDwfAnalogOutNodeDataSet(hdwf, 0, AnalogOutNodeCarrier, InputFileSamples, NoSamples);
FDwfAnalogOutNodeFrequencySet(hdwf, 0, AnalogOutNodeCarrier, CustomSignalFreq);
FDwfAnalogOutRunSet(hdwf, 0, 1.0 / CustomSignalFreq);
FDwfAnalogOutNodeAmplitudeSet(hdwf, 0, AnalogOutNodeCarrier, MaxVdd);
The Measured Signal is the one read by the scope and it is supposed to be like the signal above it,
please can you tell me what am I doing wrong?
thank you for the help,
ssm
Edited by ssmLink to comment
Share on other sites
5 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