⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkds30xx_example.c

📁 TDS3000SREIALS OSC TEST PROGRAM WIRTTEN BY TEK CO.LTD
💻 C
字号:
/***************************************************************************** 
 *  Copyright 1999 National Instruments Corporation.  All Rights Reserved.   * 
 *****************************************************************************/

/*****************************************************************************
 *  tkds30xx Instrument Driver Sample Program                              
 *  Developed with LabWindows/CVI 5.1                                     
 *  Original Release: 05/24/1999                                  
 *
 *  Purpose:  This sample program initializes the scope, configures it for an
 *            edge triggered acquisition, acquires a waveform, and displays the 
 *            waveform in a message pop-up dialog.
 *
 *            To run this sample program, do the following:
 *            1) Create a new project in LabWindows/CVI.
 *            2) Add this file to the project.  To add files to the project,
 *               select the Add Files To Project from the Edit menu of the 
 *               Project window.
 *            3) Add the .fp file for the tkds30xx instrument driver to the 
 *               project.
 *            4) Check that the resource name used in tkds30xx_InitWithOptions()
 *               is correct. If simulating, change flag to simulate.
 *            5) Run the project.
 *****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <userint.h>
#include "tkds30xx.h"

main ()

{
    #define     CH1     "CH1"
    #define     CH2     "CH2"

    ViSession   vi;
    ViStatus    error = VI_SUCCESS;
    ViReal64    initialX, incrementX;
    ViInt32     actualRecordLength, actualPts;
    ViReal64    meas, *waveform = VI_NULL;
    ViChar      str[256];

        /* 
            If you want to run this sample program and the instrument is not
            present, set the Simulate flag to 1.  (Example:  "Simulate = 1")
        */
    checkErr( tkds30xx_InitWithOptions ("GPIB::1::INSTR", VI_TRUE, VI_TRUE,
                                        "Simulate=0,RangeCheck=1,QueryInstrStatus=1,Cache=1",
                                        &vi));
                                        
    checkErr( tkds30xx_ConfigureAcquisitionType (vi, TKDS30XX_VAL_NORMAL));
    checkErr( tkds30xx_ConfigureChannel (vi, CH1, 20.0, 0.0, TKDS30XX_VAL_DC, 1.0,
                                         VI_TRUE));
    checkErr( tkds30xx_ConfigureChanCharacteristics (vi, CH1, 1.0e6,
                                                     200.0e+6));
    checkErr( tkds30xx_ConfigureAcquisitionRecord (vi, 0.0025, 1000, 0.0));
    checkErr( tkds30xx_ConfigureTrigger (vi, TKDS30XX_VAL_EDGE_TRIGGER, 0.0));
    checkErr( tkds30xx_ConfigureTriggerCoupling (vi, TKDS30XX_VAL_DC));
    checkErr( tkds30xx_ConfigureEdgeTriggerSource (vi, CH1, 0.5, TKDS30XX_VAL_POSITIVE));
    
    checkErr( tkds30xx_ReadWaveformMeasurement (vi, CH1,
                                                TKDS30XX_VAL_VOLTAGE_MIN, 10000,
                                                &meas));
    sprintf (str, "Acquired Waveform: Minimum:%.2le volts; ", meas);
    checkErr( tkds30xx_FetchWaveformMeasurement (vi, CH1,
                                                 TKDS30XX_VAL_VOLTAGE_MAX,
                                                 &meas));
    sprintf (str + strlen (str), "Maximum:%.2le volts", meas);
    
    checkErr( tkds30xx_ActualRecordLength (vi, &actualRecordLength));
    waveform = calloc (actualRecordLength, sizeof(ViReal64));
    
    checkErr( tkds30xx_FetchWaveform (vi, CH1,
                                      actualRecordLength, waveform, &actualPts,
                                      &initialX, &incrementX));

    YGraphPopup (str, waveform, actualPts, VAL_DOUBLE);
    
Error:
    if (error != VI_SUCCESS)
        {
            ViChar   errStr[2048];

            tkds30xx_GetError(vi, &error, 2048, errStr);
            MessagePopup ("Error!", errStr);
        }
    if (waveform)
        free (waveform);
    
    if (vi)
        tkds30xx_close (vi);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -