Example #1
0
void main (void)
{
	char	ch;

	fprintf ( stderr,"\n\nOpening the device...\n");

	//open unit and show splash screen
	unitOpened.handle = ps2000_open_unit ();
	fprintf (stderr, "Handler: %d\n", unitOpened.handle );
	if ( !unitOpened.handle )
	{
		fprintf (stderr, "Unable to open device\n" );
		get_info ();
		while( !kbhit() );
		exit ( 99 );
	}
	else
	{
		fprintf (stderr, "Device opened successfully\n\n" );
		get_info ();

		timebase = 0;

		ch = ' ';
		while ( ch != 'X' )
		{
			fprintf (stderr,"\n" );
			fprintf (stderr, "D - Fast streaming triggered\n");
			fprintf (stderr, "X - exit\n" );
			fprintf (stderr, "Operation:" );

			ch = toupper ( getch () );

			fprintf (stderr, "\n\n" );
			switch ( ch )
			{

			case 'D':
				if (unitOpened.hasFastStreaming && unitOpened.hasAdvancedTriggering)
				{
					collect_fast_streaming_triggered ();
				}
				else
				{
					fprintf (stderr,"Not supported by this model\n\n");
				}
				break;

			case 'X':
				/* Handled by outer loop */
				break;

			default:
				fprintf (stderr, "Invalid operation\n" );
				break;
			}
		}

		ps2000_close_unit ( unitOpened.handle );
	}
}
Example #2
0
int main (void)
{
  char	ch;

  printf ( "PS2000 driver example program\n" );
  printf ( "Version 1.0\n\n" );

  printf ( "\n\nOpening the device...\n");

  //open unit and show splash screen
  unitOpened.handle = ps2000_open_unit ();
  printf ( "Handle: %d\n", unitOpened.handle );
  if ( unitOpened.handle < 1 )
    {
    printf ( "Unable to open device\n" );
    get_info ();
    while( !kbhit() );
	exit ( 99 );
    }
  else
    {
    printf ( "Device opened successfully\n\n" );
    get_info ();

		timebase = 0;

    ch = ' ';
    while ( ch != 'X' )
      {
      printf ( "\n" );
      printf ( "B - immediate block		          V - Set voltages\n" );
      printf ( "T - triggered block		          I - Set timebase\n" );
			printf ( "Y - advanced triggered block    A - ADC counts/mV\n" );
      printf ( "E - ETS block\n" );
      printf ( "S - Streaming\n");
      printf ( "F - Fast streaming\n");
			printf ( "D - Fast streaming triggered\n");
			printf ( "G - Signal generator\n");
			printf ( "H - Arbitrary signal generator\n");
      printf ( "X - exit\n" );
      printf ( "Operation:" );

      ch = toupper ( getch () );

      printf ( "\n\n" );
      switch ( ch )
        {
        case 'B':
        collect_block_immediate ();
        break;

        case 'T':
        collect_block_triggered ();
        break;

				case 'Y':
				if (unitOpened.hasAdvancedTriggering)
				{
					collect_block_advanced_triggered ();
				}
				else
				{
					printf ("Not supported by this model\n\n");
				}
				break;

        case 'S':
        collect_streaming ();
        break;

				case 'F':
				if (unitOpened.hasFastStreaming)
				{
					collect_fast_streaming ();
				}
				else
				{
					printf ("Not supported by this model\n\n");
				}
				break;

				case 'D':
				if (unitOpened.hasFastStreaming && unitOpened.hasAdvancedTriggering)
				{
					collect_fast_streaming_triggered ();
				}
				else
				{
					printf ("Not supported by this model\n\n");
				}
				break;

        case 'E':
				if (unitOpened.hasEts)
				{
	        collect_block_ets ();
				}
				else
				{
					printf ("Not supported by this model\n\n");
				}
        break;

				case 'G':
				if (unitOpened.hasSignalGenerator)
				{
					set_sig_gen ();
				}
				break;

				case 'H':
				if (unitOpened.hasSignalGenerator)
				{
					set_sig_gen_arb ();
				}
				break;

        case 'V':
        set_voltages ();
        break;

        case 'I':
        set_timebase ();
        break;

        case 'A':
        scale_to_mv = !scale_to_mv;
        if ( scale_to_mv )
          {
          printf ( "Readings will be scaled in mV\n" );
          }
        else
          {
          printf ( "Readings will be scaled in ADC counts\n" );
          }
        break;

        case 'X':
        /* Handled by outer loop */
        break;

        default:
        printf ( "Invalid operation\n" );
        break;
        }
      }

    ps2000_close_unit ( unitOpened.handle );
    }

	return 1;
  }