Reading from a sensor without event handler

Supporting Visual Studio on Windows
taylornicole906
Fresh meat
Posts: 1
Joined: Thu Oct 22, 2020 2:37 pm
Contact:

Reading from a sensor without event handler

Postby taylornicole906 » Thu Oct 22, 2020 2:42 pm

Is there a way to get a voltage reading from a sensor outside of using an event handler? The only examples I've seen of reading voltage ratio look like this:

Code: Select all

private void LoadCell_VoltageRatioChange(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
        {
            //when the sensor detects a voltage change, it executes this.         
            if (loadCellRatioVoltageChangeArray.Count <= 50)
            {
                loadCellRatioVoltageChangeArray.Add(e.VoltageRatio);                       
            }           
        }


I want to be able to read from the sensor without having the voltage ratio change event happening.

User avatar
mparadis
Site Admin
Posts: 733
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Reading from a sensor without event handler

Postby mparadis » Thu Oct 22, 2020 2:45 pm

You can always use the VoltageRatio property, like this:

Code: Select all

using System;
using Phidget22;

class Program {
   static void Main(string[] args) {
      VoltageRatioInput ch = new VoltageRatioInput();
      try {
         ch.Open(Phidget.DefaultTimeout);

         double VoltageRatio = ch.VoltageRatio;

         ch.Close();
      } catch (PhidgetException ex) {
         Console.WriteLine("Failure: " + ex.Message);
      }
   }
}


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 2 guests