Porting triggering with PWQ from 2405A to 4244A
Porting triggering with PWQ from 2405A to 4244A
void
AcqPicoscope::setTriggerChannelConditions()
{
#pragma pack(1)
PS4000A_CONDITION triggerConditions[] =
{
{ PS4000A_CHANNEL_A, PS4000A_CONDITION_TRUE }, // enable triggering on channel A only
{ PS4000A_CHANNEL_B, PS4000A_CONDITION_DONT_CARE }, // channel B
{ PS4000A_CHANNEL_C, PS4000A_CONDITION_DONT_CARE }, // channel C
{ PS4000A_CHANNEL_D, PS4000A_CONDITION_DONT_CARE }, // channel D
{ PS4000A_EXTERNAL, PS4000A_CONDITION_DONT_CARE }, // external
{ PS4000A_TRIGGER_AUX, PS4000A_CONDITION_DONT_CARE }, // aux
{ PS4000A_PULSE_WIDTH_SOURCE, PS4000A_CONDITION_TRUE } // pulse width qualifier is enabled
};
#pragma pack(0)
sts = ps4000aSetTriggerChannelConditions(
mConfig.device, &triggerConditions[0], 7, PS4000A_CLEAR);
if (sts != PICO_OK)
{
cout << "Set channel trigger conditions failed: err = " << sts << endl;
mOkay = false;
}
return;
} // end setTriggerChannelConditions()
void
AcqPicoscope::setTriggerChannelDirections()
{
#pragma pack(1)
PS4000A_DIRECTION directionConditions[] =
{
{ PS4000A_CHANNEL_A, PS4000A_THRESHOLD_WINDOW_TRIGGERED }, // enable triggering on channel A only
{ PS4000A_CHANNEL_B, PS4000A_NONE }, // channel B
{ PS4000A_CHANNEL_C, PS4000A_NONE }, // channel C
{ PS4000A_CHANNEL_D, PS4000A_NONE }, // channel D
{ PS4000A_EXTERNAL, PS4000A_NONE }, // external
{ PS4000A_TRIGGER_AUX, PS4000A_NONE } // aux
};
#pragma pack(0)
ps4000aSetTriggerChannelDirections(mConfig.device, // device handle
&directionConditions[0], 6 );
if (sts != PICO_OK)
{
cout << "Set channel trigger directions failed: err = " << sts << endl;
mOkay = false;
}
return;
} // end setTriggerChannelDirections()
void
AcqPicoscope::setTriggerChannelProperties()
{
double maxRange = mConfig.channel[PS4000A_CHANNEL_A].frange;
int16_t uprThreshold = int16_t((mConfig.uprTriggerThreshold/maxRange)
* kPSMaxA2DValue);
int16_t lwrThreshold = int16_t((mConfig.lwrTriggerThreshold/maxRange)
* kPSMaxA2DValue);
uint16_t uprThresholdHystOffset = kPSResolutionInBits;
uint16_t lwrThresholdHystOffset = kPSResolutionInBits;
#pragma pack(1)
PS4000A_TRIGGER_CHANNEL_PROPERTIES triggerChannelProperties[] =
{
{
uprThreshold, uprThresholdHystOffset,
lwrThreshold, lwrThresholdHystOffset,
PS4000A_CHANNEL_A, PS4000A_WINDOW
}
};
#pragma pack(0)
sts = ps4000aSetTriggerChannelProperties(
mConfig.device, &triggerChannelProperties[0], 1, 0, 0);
if (sts != PICO_OK)
{
cout << "Set channel trigger properties failed: err = " << sts << endl;
mOkay = false;
}
return;
} // end setTriggerChannelProperties()
void
AcqPicoscope::setPulseWidthQualifier()
{
// Minimum pulse width in units of samples.
uint32_t minPulseWidth = uint32_t(kMinPulseWidthSamples);
#pragma pack(1)
PS4000A_CONDITION pwqConditions[] =
{
{ PS4000A_CHANNEL_A, PS4000A_CONDITION_TRUE }, // enable pulse width trigger on channel A
{ PS4000A_CHANNEL_B, PS4000A_CONDITION_DONT_CARE }, // channel B
{ PS4000A_CHANNEL_C, PS4000A_CONDITION_DONT_CARE }, // channel C
{ PS4000A_CHANNEL_D, PS4000A_CONDITION_DONT_CARE }, // channel D
{ PS4000A_EXTERNAL, PS4000A_CONDITION_DONT_CARE }, // external
{ PS4000A_TRIGGER_AUX, PS4000A_CONDITION_DONT_CARE } // aux
};
#pragma pack(0)
sts = ps4000aSetPulseWidthQualifierConditions(
mConfig.device, // device handle
&pwqConditions[0], // pointer to condition structure
6, // number of structures
PS4000A_CLEAR
);
if (sts != PICO_OK)
{
cout << "Set pulse width qualifier conditions failed: err = " << sts << endl;
mOkay = false;
}
sts = ps4000aSetPulseWidthQualifierProperties(
mConfig.device, // device handle
PS4000A_RISING_LOWER,
minPulseWidth,
0,
PS4000A_PW_TYPE_GREATER_THAN
);
if (sts != PICO_OK)
{
cout << "Set pulse width qualifier properties failed: err = " << sts << endl;
mOkay = false;
}
return;
} // end setPulseWidthQualifier()
Re: Porting triggering with PWQ from 2405A to 4244A
Code: Select all
sts = ps4000aSetTriggerChannelConditions(
mConfig.device, &triggerConditions[0], 7, (PS4000A_CLEAR | PS4000A_ADD) );
Technical Support Manager