PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
status = ps5000OpenUnit(&m_InstrumentID);
//range = PS5000_100MV
status = ps5000SetChannel(m_InstrumentID, PS5000_CHANNEL_A, TRUE, TRUE, range);
//dDelayTime = 25000; fSampleTime = 2e-9
unsigned long ulTrigDelay = unsigned long(dDelayTime/(fSampleTime*8.0));
status = ps5000SetTriggerDelay(m_InstrumentID,ulTrigDelay);
//dTrigLevel = 0
short sTriggerVoltage = mv_to_adc((short)dTrigLevel, m_Channel);
//default structs
struct tTriggerChannelProperties sourceDetails;
sourceDetails.thresholdMajor = sTriggerVoltage;
sourceDetails.thresholdMinor = sTriggerVoltage;
sourceDetails.hysteresis = 0;//256 * 10;
sourceDetails.thresholdMode = LEVEL;
struct tTriggerConditions conditions;
conditions.channelA = CONDITION_DONT_CARE;
conditions.channelB = CONDITION_DONT_CARE;
conditions.channelC = CONDITION_DONT_CARE;
conditions.channelD = CONDITION_DONT_CARE;
conditions.external = CONDITION_DONT_CARE;
conditions.aux = CONDITION_DONT_CARE;
conditions.pulseWidthQualifier = CONDITION_DONT_CARE;
TRIGGER_DIRECTIONS directions;
directions.channelA = NONE;
directions.channelB = NONE;
directions.channelC = NONE;
directions.channelD = NONE;
directions.ext = NONE;
directions.aux = NONE;
//Determine the trigger parameters
if (m_Channel == PS5000_CHANNEL_A){
sourceDetails.channel = PS5000_CHANNEL_B;
conditions.channelB = CONDITION_TRUE;
directions.channelB = RISING;
} else {
sourceDetails.channel = PS5000_CHANNEL_A;
conditions.channelA = CONDITION_TRUE;
directions.channelA = RISING;
}
//Convert the structures into the appropriate typedefs
TRIGGER_CHANNEL_PROPERTIES *tproperties = reinterpret_cast(&sourceDetails);
TRIGGER_CONDITIONS *tconditions = reinterpret_cast(&conditions);
//Configure the properties for this trigger using the properties struct (properties can be compounded)
status = ps5000SetTriggerChannelProperties(m_InstrumentID, tproperties, 1, FALSE, 0);
if (status != PICO_OK)
return FALSE;
//Configure the conditions of the trigger using the conditions struct (conditions can be compounded)
status = ps5000SetTriggerChannelConditions(m_InstrumentID, tconditions, 1);
if (status != PICO_OK)
return FALSE;
status = ps5000SetTriggerChannelDirections(m_InstrumentID,
directions.channelA,
directions.channelB,
directions.channelC,
directions.channelD,
directions.ext,
directions.aux);
//m_lSpectrumSize = 7040; m_SampleBuffer = (short*)malloc(m_lSpectrumSize * sizeof(short));
status = ps5000SetDataBuffer(m_InstrumentID, m_Channel, m_SampleBuffer, m_lSpectrumSize);
//unNPointsToAcquire = 7040; m_ulTimeBase = 1
status = ps5000RunBlock(m_InstrumentID,
0,
(long)unNPointsToAcquire,
m_ulSelectedTimeBase,
0,
NULL,
0,
CallBackBlock,
this);
//Callback function
void CALLBACK CallBackBlock(short handle, PICO_STATUS status, void * pParameter)
{
// flag to say done reading data
reinterpret_cast(pParameter)->m_bAcquisitionComplete = TRUE;
// store the acquisition status
reinterpret_cast(pParameter)->m_psAcquisitionStatus = status;
}
//Unit must be stopped before any other scope interactions take place (happens after callback)
ps5000Stop(m_InstrumentID);
unsigned long ulSampleCount = m_lSpectrumSize;
status = ps5000GetValues(m_InstrumentID,0L,&ulSampleCount,1,RATIO_MODE_NONE,0,NULL);