Exemple #1
0
 public DaqAo(string channel)
 {
     _myAoChannel = _analogOutTask.AOChannels.CreateVoltageChannel(
         "dev3/" + channel,
         "myAOChannel",
         0,
         5,
         AOVoltageUnits.Volts
         );
     _writer = new AnalogSingleChannelWriter(_analogOutTask.Stream);
 }
Exemple #2
0
    public void setChannel(int line, double value)
    {
        Task      task        = new Task();
        string    devFullname = string.Format("{0}/ao{1}", name, line);
        AOChannel channel     = task.AOChannels.CreateVoltageChannel(devFullname, "", 0.0, 10.0, AOVoltageUnits.Volts);

        task.Start();
        AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(task.Stream);
        IAsyncResult             result = writer.BeginWriteSingleSample(true, new double[] { value }, null, null);

        task.Stop();
    }
        public static void InitializeInstrument()
        {
            //Initializing Task
            motorLoadTask      = new Task();
            motorControlTask   = new Task();
            motorRotationsTask = new Task();

            //Initializing channels
            //Voltage analog in
            motorLoadChannel = motorLoadTask.AIChannels.CreateVoltageChannel("dev1/ai0", "Motor Load Channel", AITerminalConfiguration.Rse, 0, 10, AIVoltageUnits.Volts);

            //Voltage analog out
            motorControlChannel = motorControlTask.AOChannels.CreateVoltageChannel("dev1/ao0", "Motor Control Channel", 0, 5, AOVoltageUnits.Volts);

            //Voltage digital in
            motorRotationsChannel = motorRotationsTask.DIChannels.CreateChannel("dev1/port0", "Motor Rotation Channel", ChannelLineGrouping.OneChannelForAllLines);
        }
Exemple #4
0
    public void setChannelValues(int line, double[] values)
    {
        Task      task        = new Task();
        string    devFullname = string.Format("{0}/ao{1}", name, line);
        AOChannel channel     = task.AOChannels.CreateVoltageChannel(devFullname, "", 0.0, 10.0, AOVoltageUnits.Volts);

        task.Timing.ConfigureSampleClock("", 1000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, values.Length);
        task.Stream.WriteRegenerationMode = WriteRegenerationMode.AllowRegeneration;
        AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(task.Stream);

        writer.WriteMultiSample(false, values);
        task.Start();
        while (task.IsDone == false)
        {
            ;
        }
        task.Dispose();
    }
 public void Write(string output, double outputVoltage)
 {
     try
     {
         Task      analogOutTask = new Task();
         AOChannel myAOChannel   = analogOutTask.AOChannels.CreateVoltageChannel(
             Device + "/" + output,
             "myAOChannel",
             Settings.Vmin,
             Settings.Vmax,
             AOVoltageUnits.Volts
             );
         AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(analogOutTask.Stream);
         writer.WriteSingleSample(true, outputVoltage);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }