Page 1 of 1

Controling LED intensity using VINT Port

Posted: Tue Feb 02, 2021 1:29 pm
by flavioluz
Hello, Using a LED directly in a VINT port, the LEDForwardVoltage of DigitalOutput allways give's this error: 'outp.LEDForwardVoltage' threw an exception of type 'System.NullReferenceException'

If I don't set this, the LED works ok but in low intensity.

Can anyone help?

Thank you

Re: Controling LED intensity using VINT Port

Posted: Wed Feb 03, 2021 9:01 am
by mparadis
LEDForwardVoltage and other LED-specific functions can only be used by our dedicated LED drivers, like the LED1000. When using LEDs on normal digital outputs, you can control brightness with setDutyCycle.

0 = off, 1 = max brightness, and anything in between will have varying brightness, although not a linear scale so 0.75 is not necessarily 3x brighter than 0.25.

Re: Controling LED intensity using VINT Port

Posted: Thu Feb 04, 2021 5:48 am
by flavioluz
I've already set the DutyCycle to 1 or less and there's no change in led brightness.
using:
outp.DutyCycle = value;
outp.State = value > 0;

or
outp.BeginSetDutyCycle(value, delegate (IAsyncResult result) {
try
{
outp.EndSetDutyCycle(result);
outp.State = value > 0;
}
catch (PhidgetException ex)
{
Console.WriteLine("Async Failure: " + ex.Message);
}
}, null);

being value a double number between 0 and 1.
the line outp.State could be inside the try catch or after the call for BeginSetDytyCycle.

Re: Controling LED intensity using VINT Port

Posted: Fri Feb 05, 2021 2:30 pm
by mparadis
The correct usage in C#/.NET is the first one you posted, outp.DutyCycle = value;

Note that State and DutyCycle both modify the same thing, so if you set DutyCycle to 0.5 and then set State to true or 1, that will set the DutyCycle to 1. From your code it looks like you might be immediately setting state to true after setting the duty cycle, so it will always be at full brightness.

The reason we have two properties that control the same thing is because State is a safe property to use with electronics that don't support duty cycle control (like non-dimmable lights and relays).

Re: Controling LED intensity using VINT Port

Posted: Mon Feb 08, 2021 4:32 am
by flavioluz
Thank you for that explanation. I can now change the LED intensity. The difference is that in VINT port, the output voltage is 2.5v max and the LED needs more to be brighter. In an LED controller we can give a higher voltage.