Controling LED intensity using VINT Port

Any hardware type questions or problems for all other Phidget devices.
Post Reply
flavioluz
Phidgetsian
Posts: 5
Joined: Tue Oct 27, 2020 12:31 pm
Contact:

Controling LED intensity using VINT Port

Post 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
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Controling LED intensity using VINT Port

Post 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.
flavioluz
Phidgetsian
Posts: 5
Joined: Tue Oct 27, 2020 12:31 pm
Contact:

Re: Controling LED intensity using VINT Port

Post 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.
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Controling LED intensity using VINT Port

Post 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).
flavioluz
Phidgetsian
Posts: 5
Joined: Tue Oct 27, 2020 12:31 pm
Contact:

Re: Controling LED intensity using VINT Port

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests