|
|
| Author |
Message |
jecuzens Newbie
Joined: 18 Mar 2008
Posts: 1
|
Posted: Wed Mar 26, 2008 2:39 pm Post subject: Triggering and Acquisition 5203 |
|
|
Hi,
I just started trying to program the 5203 and ran into a bit of a problem when it came to getting data out of the scope. Whenever I used the GetValues function to retrieve the data from the scope I started getting an invalid handle error even though all of the functions had been returning PICO_OK until that point for my block read. I thought that the problem may be due to the fact that I am using sdk 13 but had the old pico software installed (11). So I downloaded the latest pico software and tried using that but it appears that I can't get the scope to trigger anymore (despite restarting the scope, uninstalling the driver and reinstalling, and restarting my computer). Is there a way I can know that the firmware was updated? I noticed that the new pico software uses 1.3.2 of the ps5000.dll while sdk 13 uses 1.3.0.9... Is this a problem???
Anyway, here is my acquisition code:
| Code: |
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<TRIGGER_CHANNEL_PROPERTIES*>(&sourceDetails);
TRIGGER_CONDITIONS *tconditions = reinterpret_cast<TRIGGER_CONDITIONS*>(&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<CPicoScope*>(pParameter)->m_bAcquisitionComplete = TRUE;
// store the acquisition status
reinterpret_cast<CPicoScope*>(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);
|
I tried to truncate the code as much as possible but this is the main idea... I know the Callback works because in the event of a timeout (which I calculate) I stop the scope which makes it hit the callback. Just can't figure out why I'm not triggering now.
Any help would be appreciated! |
|
| Back to top |
|
 |
markspencer Site Admin

Joined: 07 May 2003
Posts: 610
|
Posted: Tue May 13, 2008 11:01 am Post subject: |
|
|
Hi,
I am sorry to hear that you are experiencing problem. I have read through your source code and just have a few suggestion to your problem.
The first is that you are only enabling channel A, but you seem to be trying to use channel B as well, ie for triggering. You may have just left this out of the snipet.
The second part is the value for the delay this is most likely overflowing the unsigned long value and thus I can not determine the value.
The lastly does run block return PICO_OK? |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|