PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
// Setup Data channel A range and coupling.
CurrentStatus = ps4000SetChannel( Handle, PS4000_CHANNEL_A, true , true, (PS4000_RANGE)VoltageRange ); // Channel A activated, DC coupling.
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set channel A.\n\nExiting.", "PicoScope error", wxOK |wxICON_ERROR );
return( -1 );
}
// Channel A data buffer.
CurrentStatus = ps4000SetDataBuffer( Handle, PS4000_CHANNEL_A, GLOBAL_CurveData[ CurrentCurveIndex ], SampleNumber );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( wxString("Error allocating Channel A buffer :") << PicoGetErrorText( CurrentStatus ) << "\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
if( FileRibbon_PicoVoltageRange2_Choice->GetSelection() >= 2 )
{
// >> Channel B << .
CurrentStatus = ps4000SetChannel( Handle, PS4000_CHANNEL_B, true, true, (PS4000_RANGE)GLOBAL_CurvePicoVoltageRange[ CurrentCurveIndex +1] );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set channel B.\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
// Channel B data buffer.
CurrentStatus = ps4000SetDataBuffer( Handle, PS4000_CHANNEL_B, GLOBAL_CurveData[ CurrentCurveIndex +1], SampleNumber );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( wxString("Error allocating Channel B buffer :") << PicoGetErrorText( CurrentStatus ) << "\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
}
else
{
// >> Channel B << is OFF.
CurrentStatus = ps4000SetChannel( Handle, PS4000_CHANNEL_B, false, true, PS4000_1V );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set channel B.\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
}
// >> Channel C << is OFF.
CurrentStatus = ps4000SetChannel( Handle, PS4000_CHANNEL_C, false, true, PS4000_1V );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set channel C.\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
// >> Channel D << is OFF.
CurrentStatus = ps4000SetChannel( Handle, PS4000_CHANNEL_D, false, true, PS4000_1V );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set channel D.\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
// Trigger set to 'OFF'.
if( ps4000SetSimpleTrigger( Handle, 0, PS4000_CHANNEL_A, 0, ABOVE, 0, 1) != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( "Can't set Trigger.\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
// Run streaming.
CurrentStatus = ps4000RunStreaming( Handle, &SamplingPeriod, (PS4000_TIME_UNITS) (GLOBAL_CurvePicoSamplingPeriodUnit[ CurrentCurveIndex ]), 0, SampleNumber, true, 1, SampleNumber );
if( CurrentStatus != PICO_OK )
{ CurrentStatus = ps4000CloseUnit( Handle );
wxEndBusyCursor();
wxMessageBox( wxString("Error running streaming: ") << PicoGetErrorText( CurrentStatus ) << "\n\nExiting.", "PicoScope error", wxOK | wxICON_ERROR );
return( -1 );
}
// Streaming loop.
Pico_AutoStop_Flag = false;
Sleep(100);
while( Pico_AutoStop_Flag == false )
{ Sleep(100);
// Poll until data is received. Until then, GetStreamingLatestValues wont call the callback.
Pico_StreamingDataReady_Flag = false;
CurrentStatus = ps4000GetStreamingLatestValues( Handle, (ps4000StreamingReady)BcoagFrame::PicoStreamingCallBack, NULL );
}
// Close PicoScope.
ps4000Stop( Handle );
ps4000CloseUnit( Handle );