Függvény generátor GPIB

A Fizipedia wikiből

Agilent 33220A kezelése C# programból. Fájl:FGEN GPIB.zip

Referenciákhoz hozzá kell adni: NI4882

In English: Controlling the Agilent 33220A function generator from a C# program. Add NI4882 to the references, if needed.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NationalInstruments.NI4882;
 
namespace FGEN
{
    public partial class FGEN : Form
    {
        private Int32 FuncGenAddr = 2;
        private Device FuncGen;
 
        public FGEN()
        {
            InitializeComponent();
        }
 
        private void FGEN_Load(object sender, EventArgs e)
        {
            //Connect to Function Generator via GPIB
            FuncGen = new Device(0, (byte)FuncGenAddr);
        }
 
        private void IDbutton_Click(object sender, EventArgs e)
        {
            FuncGen.Write("*IDN?");
            IDtextBox.Text = FuncGen.ReadString();
        }
 
        private void Freqbutton_Click(object sender, EventArgs e)
        {
            FuncGen.Write("FREQ "+FreqtextBox.Text);
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                FuncGen.Write("OUTP ON");
            }
            else
            {
                FuncGen.Write("OUTP OFF");
            }
        }
 
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                FuncGen.Write("FUNC SIN");
            }
        }
 
        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton3.Checked)
            {
                FuncGen.Write("FUNC SQUARE");
            }
        }
 
        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
            {
                FuncGen.Write("FUNC RAMP");
            }
        }
 
        private void FGEN_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Close Device Communication
            FuncGen.Dispose();
        }
    }
}