PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
void collect_block_immediate (void)
{
int32_t i;
int32_t time_interval;
int16_t time_units;
int16_t oversample;
int32_t no_of_samples = BUFFER_SIZE;
FILE *fp;
int16_t auto_trigger_ms = 0;
int32_t time_indisposed_ms;
int16_t overflow;
int32_t max_samples;
int16_t ch = 0;
printf ( "Collect block immediate...\n" );
printf ( "Press a key to start\n" );
_getch ();
set_defaults ();
/* Trigger disabled */
ps2000_set_trigger ( unitOpened.handle, PS2000_NONE, 0, PS2000_RISING, 0, auto_trigger_ms );
/* find the maximum number of samples, the time interval (in time_units),
* the most suitable time units, and the maximum oversample at the current timebase
*/
oversample = 1;
while (!ps2000_get_timebase ( unitOpened.handle,
timebase,
no_of_samples,
&time_interval,
&time_units,
oversample,
&max_samples))
timebase++;
printf ( "timebase: %hd\toversample:%hd\n", timebase, oversample );
/* Start it collecting,
* then wait for completion
*/
ps2000_run_block ( unitOpened.handle, no_of_samples, timebase, oversample, &time_indisposed_ms );
while ( !ps2000_ready ( unitOpened.handle ) )
{
[b]Sleep[/b]( 100 );
}
ps2000_stop ( unitOpened.handle );
/* Should be done now...
* get the times (in nanoseconds)
* and the values (in ADC counts)
*/
long result = ps2000_get_times_and_values ( unitOpened.handle, times,
unitOpened.channelSettings[PS2000_CHANNEL_A].values,
unitOpened.channelSettings[PS2000_CHANNEL_B].values,
NULL,
NULL,
&overflow, time_units, no_of_samples );
/* Print out the first 10 readings,
* converting the readings to mV if required
*/
printf ( "First 10 readings\n" );
printf ( "Value\n" );
printf ( "(%s)\n", adc_units ( time_units ) );
for ( i = 0; i < 10; i++ )
{
for (ch = 0; ch < unitOpened.noOfChannels; ch++)
{
if(unitOpened.channelSettings[ch].enabled)
{
printf ( "%d\t", adc_to_mv ( unitOpened.channelSettings[ch].values[i], unitOpened.channelSettings[ch].range) );
}
}
printf("\n");
}
if( (fp = fopen( "data.txt","w" )) == NULL )
printf( "The file 'data.txt' was not opened\n" );
else
printf( "The file 'data.txt' was opened\n" );
for ( i = 0; i < BUFFER_SIZE; i++)
{
fprintf ( fp,"%ld ", times[i]);
for (ch = 0; ch < unitOpened.noOfChannels; ch++)
{
if(unitOpened.channelSettings[ch].enabled)
{
fprintf ( fp, ",%d, %d,", unitOpened.channelSettings[ch].values[i],
adc_to_mv ( unitOpened.channelSettings[ch].values[i], unitOpened.channelSettings[ch].range) );
}
}
fprintf(fp, "\n");
}
fclose(fp);
}
Is that when you print to screen or view the value of the variable using the debugging tools in Visual Studio?Rogue95 wrote:The overflow flag has a value of -859045888 after calling ps2000_get_times_and_values().