PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
#include
#include
#include
#include "ps4000Api.h"
short gReady;
void _stdcall ReadyCallback(short handle, PICO_STATUS status, void * pParameter)
{
gReady = 1;
}
void main()
{
long nSamples = 2000;
unsigned long timebase = 400;
short threshold = 0;
PICO_STATUS status;
short handle;
if(ps4000OpenUnit(&handle) != PICO_OK) return;
if(ps4000SetChannel(handle, PS4000_CHANNEL_A, 1, 1, PS4000_1V) != PICO_OK) return;
if(ps4000SetChannel(handle, PS4000_CHANNEL_B, 1, 1, PS4000_1V) != PICO_OK) return;
//Set up the trigger
TRIGGER_CONDITIONS conditions;
conditions.channelA = CONDITION_DONT_CARE;
conditions.channelB = CONDITION_TRUE;
conditions.channelC = CONDITION_DONT_CARE;
conditions.channelD = CONDITION_DONT_CARE;
conditions.aux = CONDITION_DONT_CARE;
conditions.pulseWidthQualifier= CONDITION_DONT_CARE;
TRIGGER_CHANNEL_PROPERTIES properties;
properties.thresholdLower = 0;
properties.thresholdUpper = threshold;
properties.thresholdLowerHysteresis = 0;
properties.thresholdUpperHysteresis = 300;
properties.channel = PS4000_CHANNEL_B;
properties.thresholdMode = LEVEL;
if(ps4000SetTriggerChannelConditions(handle, &conditions, 1) != PICO_OK) return;
if(ps4000SetTriggerChannelDirections(handle, NONE, RISING, NONE, NONE, NONE, NONE) != PICO_OK) return;
if(ps4000SetTriggerChannelProperties(handle, &properties, 1, 0, 0) != PICO_OK) return;
long timeIndisposed;
short counter = 0;
while(!_kbhit())
{
gReady = 0;
if((status = ps4000RunBlock(handle, 0, nSamples, timebase, 1, &timeIndisposed, 0, ReadyCallback, NULL)) != PICO_OK)
{
printf("ps4000RunBlock status = %Xh", status);
_getch();
return;
}
while(gReady == 0)
{
Sleep(0);
}
printf("Trigger: %d\n", counter++);
}
ps4000CloseUnit(handle);
}