PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
#include
#include "adc200.h"
#define MAX_SAMPLES 20000
#define PORT 1
void main(void)
{
long times[MAX_SAMPLES];
short chA[MAX_SAMPLES];
short chB[MAX_SAMPLES];
unsigned short channel_mv[A200_MAX_CHANNELS];
unsigned short ranges [A200_MAX_CHANNELS] = {A200_5V, A200_5V,A200_5V, A200_5V};
unsigned long ns;
unsigned char is_slow;
printf("ETS Example.\n\n");
// Open the unit on 'port'.
printf("Opening unit... ");
short ok = adc200_open_unit(PORT);
ok ? printf("SUCCESS.\n") : printf("FAILED.\n");
for(int ch = 0; ch < A200_MAX_CHANNELS; ch++)
{
channel_mv[ch] = adc200_set_range(ch, ranges [ch]);
adc200_set_dc(ch, false);
}
// Set up the basic ADC properties, these would be the same
// with or without ETS.
adc200_set_range(A200_CHANNEL_A, 7);
adc200_set_time_units (A200_FS);
adc200_set_channels(A200_CHANNEL_A);
adc200_set_oversample (1);
adc200_set_timebase (&ns, &is_slow, 0);
adc200_set_trigger(true, A200_SOURCE_A, false, 0, 100);
// Set up ETS. This call is explained in the help file.
adc200_set_ets (10, 50, ETS_SLOW);
// Set up the unit to collect MAX_SAMPLES samples at a time.
printf("Collecting samples... ");
if(!adc200_run(10001))
printf("FAILED.\n");
else
printf("SUCCESS.\n");
// We're putting our faith in the device becoming ready.
// This is usually bad karma but we're not asking the device
// to do anything stressful so it should be okay.
while(!adc200_ready());
// Okay our device is ready. Stop it and retrieve the values.
adc200_set_time_units(A200_FS);
adc200_get_times_and_values(times, chA, chB, 10001);
// Print all the results onto the screen. This could take some time.
// probably better to pipe the output into a file.
for(int i = 0; i < 10001; i++)
{
printf("%d, %d\n", times[i], chA[i]);
}
adc200_close_unit(PORT);
}