private static string UID = "XYZ"; // Change XYZ to the UID of your Voltage/Current Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletVoltageCurrent vc = new BrickletVoltageCurrent(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current voltage (unit is mV) int voltage = vc.GetVoltage(); Console.WriteLine("Voltage: " + voltage/1000.0 + " V"); // Get current current (unit is mA) int current = vc.GetCurrent(); Console.WriteLine("Current: " + current/1000.0 + " A"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletVoltageCurrent vc = new BrickletVoltageCurrent(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register current callback to function CurrentCB vc.Current += CurrentCB; // Set period for current callback to 1s (1000ms) // Note: The current callback is only called every second // if the current has changed since the last call! vc.SetCurrentCallbackPeriod(1000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Voltage/Current Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletVoltageCurrent vc = new BrickletVoltageCurrent(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get threshold callbacks with a debounce time of 10 seconds (10000ms) vc.SetDebouncePeriod(10000); // Register power reached callback to function PowerReachedCB vc.PowerReached += PowerReachedCB; // Configure threshold for power "greater than 10 W" (unit is mW) vc.SetPowerCallbackThreshold('>', 10*1000, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
// Callback function for power reached callback (parameter has unit mW) static void PowerReachedCB(BrickletVoltageCurrent sender, int power) { Console.WriteLine("Power: " + power/1000.0 + " W"); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Voltage/Current Bricklet #endregion Fields #region Methods // Callback function for current callback (parameter has unit mA) static void CurrentCB(BrickletVoltageCurrent sender, int current) { Console.WriteLine("Current: " + current/1000.0 + " A"); }