PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
void CollectBlockTriggered(UNIT * unit)
{
short triggerVoltage = mv_to_adc(1000, unit->channelSettings[PS3000A_CHANNEL_A].range, unit);
short triggerVoltageHys = mv_to_adc(0, unit->channelSettings[PS3000A_CHANNEL_A].range, unit); // ChannelInfo stores ADC counts
short triggerEnabled = 0;
short pulseWidthQualifierEnabled = 0;
PICO_STATUS trigger_status;
struct tPS3000ATriggerChannelProperties sourceDetails = { triggerVoltage,
triggerVoltageHys,
triggerVoltage,
triggerVoltageHys,
PS3000A_CHANNEL_A,
PS3000A_LEVEL};
struct tPS3000ATriggerConditions conditions = { PS3000A_CONDITION_TRUE, //CH A
PS3000A_CONDITION_DONT_CARE,
PS3000A_CONDITION_DONT_CARE,
PS3000A_CONDITION_DONT_CARE,
PS3000A_CONDITION_DONT_CARE,
PS3000A_CONDITION_DONT_CARE,
PS3000A_CONDITION_TRUE}; //PWQ
struct tPwq pulseWidth;
struct tTriggerDirections directions = { PS3000A_BELOW,
PS3000A_NONE,
PS3000A_NONE,
PS3000A_NONE,
PS3000A_NONE,
PS3000A_NONE };
struct tPS3000APwqConditions pwqconditions;
memset(&pulseWidth, 0, sizeof(struct tPwq));
/* Pulse width Test Settings*/
pwqconditions.channelA = PS3000A_CONDITION_TRUE;
pwqconditions.channelB = PS3000A_CONDITION_DONT_CARE;
pwqconditions.channelC = PS3000A_CONDITION_DONT_CARE;
pwqconditions.channelD = PS3000A_CONDITION_DONT_CARE;
pwqconditions.external = PS3000A_CONDITION_DONT_CARE;
pwqconditions.aux = PS3000A_CONDITION_DONT_CARE;
pulseWidth.conditions = &pwqconditions;
pulseWidth.lower = 50000; //3206B timebase 0 = 2nS * 50000 = 100uS, 16ns * 6250 = 100us
pulseWidth.upper = 0;
pulseWidth.nConditions = 1;
pulseWidth.direction = PS3000A_RISING_OR_FALLING;
pulseWidth.type = PS3000A_PW_TYPE_GREATER_THAN;
printf("Collect block triggered...\n");
printf("Collects when value rises past %dmV\n",
adc_to_mv(sourceDetails.thresholdUpper, unit->channelSettings[PS3000A_CHANNEL_A].range, unit));
printf("Press a key to start...\n");
_getch();
SetDefaults(unit);
/* Trigger enabled
* Rising edge
* Threshold = 100mV */
SetTrigger(unit->handle, &sourceDetails, 1, &conditions, 1, &directions, &pulseWidth, 0, 0, 0);
trigger_status = ps3000aIsTriggerOrPulseWidthQualifierEnabled(unit->handle, &triggerEnabled, &pulseWidthQualifierEnabled);
printf("Trigger enabled: %d, PWQ enabled: %d\n", triggerEnabled, pulseWidthQualifierEnabled);
BlockDataHandler(unit, "Ten readings after trigger\n", 0);
}