PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
static int input_ranges [PS2000_MAX_RANGES] = {10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000};
void ofPicoScope::beginStreaming(int secToRec, int sampPerSec)
{
bStreamData=true;
tracePoint=0;
bufferLength=secToRec;
sampsPerSec=sampPerSec;
printf ( "Begin streaming...\n" );
set_defaults ();
ps2000_set_trigger ( unitOpened.handle, PS2000_NONE, 0, 0, 0, 0 );
/* Collect data at 10ms intervals
* Max BUFFER_SIZE points on each call
* (buffer must be big enough for max time between calls
*/
cout << "Streaming with " << BUFFER_SIZE << endl;
//ps2000_run_streaming ( unitOpened.handle, 10,1000, 0 );
//ps2000_run_streaming_ns (
ps2000_run_streaming_ns ( unitOpened.handle, 1000000/sampsPerSec, PS2000_US, 10000, 0, 1, 50000 );
startThread();
}
void ofPicoScope::setup()
{
printf ( "PS2000 driver example build for openFrameworks\n" );
printf ( "\n\nOpening the device...\n");
//open unit and show splash screen
unitOpened.handle = ps2000_open_unit ();
printf ( "Handler: %d\n", unitOpened.handle );
if(!unitOpened.handle) printf("Unable to open the device; check connections.\n"),bInited=false;
else bInited=true;
get_info();
set_voltages(8); //this is where the voltage is selected from the list (see above)
}
void ofPicoScope::set_voltages (int num)
{
int i;
short ch = 0;
/* See what ranges are available...
*/
for ( i = unitOpened.firstRange; i <= unitOpened.lastRange; i++ )
{
printf ( "%d -> %d mV\n", i, input_ranges[i] );
}
if(num > unitOpened.firstRange && num < unitOpened.lastRange){ // sets the voltage to the input...only if it's possible
unitOpened.channelSettings[ch].range=num;
}
}
Code: Select all
void testApp::drawGraph() {
ofEnableSmoothing();
ofSetLineWidth(2);
ofSetColor(201, 219, 84);
for(unsigned int i=0; picoScope().trace.size()>10&&i
Code: Select all
while ( bStreamData )
{
ps2000_get_streaming_last_values (unitOpened.handle, ps2000FastStreamingReady);
ps2000_stop (unitOpened.handle);
no_of_values = 0;
no_of_values = ps2000_get_streaming_values_no_aggregation (unitOpened.handle,
&startTime, // get samples from the beginning
values_a, // set buffer for channel A
values_b, // set buffer for channel B
NULL,
NULL,
&overflow,
&triggerAt,
&triggered,
BUFFER_SIZE_STREAMING);
ps2000_run_streaming_ns ( unitOpened.handle, 1000000/sampsPerSec, PS2000_US, BUFFER_SIZE_STREAMING, 1, 1, 50000 ); //changed 100 to 50
// Print out all of the readings just received
if(no_of_values){
printf ( "%d values\n", no_of_values );
for (int i = 0; i < no_of_values; i++ ){
short ch=0;
if (unitOpened.channelSettings[ch].enabled){
if(trace.size()=bufferLength*sampsPerSec-1) marker=0;
}
}
}
}
}
Code: Select all
ps2000_run_streaming_ns ( unitOpened.handle, 1000000/sampsPerSec, PS2000_US, BUFFER_SIZE_STREAMING, 0, 1, 50000 ); //changed 100 to 50
while ( bStreamData )
{
ps2000_get_streaming_last_values (unitOpened.handle, ps2000FastStreamingReady);
// Print out all of the readings just received
if(no_of_values)
{
printf ( "%d values\n", no_of_values );
for (int i = 0; i < no_of_values; i++ )
{
short ch=0;
if (unitOpened.channelSettings[ch].enabled)
{
if(trace.size()=bufferLength*sampsPerSec-1) marker=0;
}
}
}
}
}
ps2000_stop (unitOpened.handle);
no_of_values = 0;
no_of_values = ps2000_get_streaming_values_no_aggregation (unitOpened.handle,
&startTime, // get samples from the beginning
values_a, // set buffer for channel A
values_b, // set buffer for channel B
NULL,
NULL,
&overflow,
&triggerAt,
&triggered,
BUFFER_SIZE_STREAMING);