Jump to content

Do I need some relays ( Idiot check )


Inverted

Recommended Posts

Hey all,

 

I'm making a new panel for use with DCS BIOS.

It has 8 LED switches which I would imagine would be too much load for the Arduino's max 40Mah max output.

 

So just to double check, I would need a relay for each of the LED switches to control the lights so I don't overload the board?

Link to comment
Share on other sites

If you know for a fact that the load will exceed the max limit for the Arduino board you might want to do some research into logic level mosfets rather than use relays. Mosfets are easy to use, inexpensive and will handle loads of current depending on what mosfet you choose. There is lots of info on using mosfets with Arduino's so all you need to do is ask google.

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

If you need 8, i'd spring for a ULN2803. (or one of the dozens of alternatives with pretty much the same footprint). Cost something like 50 cents and has 8 inputs+outputs, and can sink 500mA and control everything up to 50V.

 

Simply hook up the inputs directly onto the arduino, and the outputs to the negative lead of your LED's.

uln2803.jpg

 

5v on pin 1 for example and the negative lead of a led (with resistor) on pin 18 = light. 0v on pin 1 = no light. Repeat 8 times :D

 

*And hook up 9 to 0V/GND and pin 10 to whatever you stick in your leds before the resistor, like 5V. Saves the pain of soldering a ton of mosfets. And if you stick it on a IC socket or on 2 rows of simple headers, you can replace it if you brake it.


Edited by CrashO
  • Like 1
Link to comment
Share on other sites

Pretty much what was said above.relays are easy to understand , but It's not 1950 anymore. semiconductors are the way to go so time invested in reading the datasheet will not be a waste at all. Aside of all technical advantages MOSFETs are significantly cheaper too.

 

With that I still use discrete darlington transistors for all high amp switching needs. Maybe not ideal and not as compact but they work and I managed to collect several bags of them in both flavours :)

  • Like 1

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

Relays are for high-power-draw devices such as motors. They are complete overkill for LEDs and have major disadvantages (slow switching speed, makes a clack noise as it switches, requires high input voltage to flip the relay, etc). Basically, it's the complete wrong choice for controlling LEDs.

 

The 40 mA max power draw on the Arduino is per pin. A typical LED with the correct resistor should only draw 20-30 mA. This means that you shouldn't run into any issues powering 8 LED switches directly through the Arduino, because each LED needs to be on its own pin. Even if you're powering the Arduino through USB and all 8 LEDs are on, that's only a 240mA power draw, with the Arduino itself using 50-80mA. You're safe up to around 400-500mA, with 500mA being the USB limit. If you're using the AC adapter, then the Arduino can source up to 900mA. So you're well within the margins with just 8 LEDs. Just don't pull more than 40mA per pin (in other words, make sure you use a resistor, and don't put more than 1 LED per pin).

 

With only 8 LEDs, you don't need a MOSFET or a ULN2803. Those are used to source a lot more current (think 1000 LEDs), and are complete overkill for what you're trying to do.


Edited by Ranma13
Link to comment
Share on other sites

Something else to consider you may not want to drive the LED that hard for 2 reasons typical high efficiency (modern) LED's produce a lot of light so you could use between 5 and 10ma of current per LED/PIN. This maybe heaps bright enough and requires a series resistor from Arduino pin to the LED.

 

So roughly 5V-1.7V (V FWD drop LED) =3.3V (Assume 5V Arduino board)

 

3.3V/10ma = 330R

 

3.3V/5ma = 660R 680R will do fine.

 

Even if you feel the need to run the LED @ 20ma which I don't recommend for various reasons. :)

 

3.3V/20ma = 165R so a 180R resistor would work fine. But you might want sunglasses because they will be bright compared to the screen(s) especially night flying.

 

I generally use 1KR series resistors when prototyping, food for thought, personally I'd just do the series resistor thing here, although the ULM 2803 is a great interface so to the FET's which I have used in the past but are not really needed here.

 

YMMV

Control is an illusion which usually shatters at the least expected moment.

Gazelle Mini-gun version is endorphins with rotors. See above.

 

Currently rolling with a Asus Z390 Prime, 9600K, 32GB RAM, SSD, 2080Ti and Windows 10Pro, Rift CV1. bu0836x and Scratch Built Pedals, Collective and Cyclic.

Link to comment
Share on other sites

Something else to consider you may not want to drive the LED that hard for 2 reasons typical high efficiency (modern) LED's produce a lot of light so you could use between 5 and 10ma of current per LED/PIN.

 

This is going to depend on the spec sheet for that LED. Most will list an optimal forward voltage, which is the voltage where you get the best brightness for power consumption ratio. I recommend using resistors that give you the optimal forward voltage; you can always lower the brightness using PWM, but you can't brighten them up without replacing the resistor.

Link to comment
Share on other sites

This is going to depend on the spec sheet for that LED. Most will list an optimal forward voltage, which is the voltage where you get the best brightness for power consumption ratio. I recommend using resistors that give you the optimal forward voltage; you can always lower the brightness using PWM, but you can't brighten them up without replacing the resistor.

 

Yes this is for a "typical LED" but there is no reason to run LED at full rated current it will actually last longer and will be less annoying especially those blue LEDs when night flying.

 

Interestingly V FWD doesn't change that much vs current typically 1.7ish V FWD drop it does climb a bit towards the high end of the FWD current.

 

Sure fine about PWM although that would require some ASM or c coding, I didn't assume that the op could do it.

 

 

In commercial projects I would use driver/data latch. ICs for interface it's just a better way to go but that's a moot point here.

 

As I said it was to give the op some options.

  • Like 1

Control is an illusion which usually shatters at the least expected moment.

Gazelle Mini-gun version is endorphins with rotors. See above.

 

Currently rolling with a Asus Z390 Prime, 9600K, 32GB RAM, SSD, 2080Ti and Windows 10Pro, Rift CV1. bu0836x and Scratch Built Pedals, Collective and Cyclic.

Link to comment
Share on other sites

Thanks for all the info gents, it's really appreciated and I've learnt a lot!

 

I will wire the LEDs directly to the arduino rather than using a relay or mosfet.

Will also test out some different resistors to control the brightness of the lights.

 

PS: PWM brightness control would be great, but I don't know how to implement that with DCS BIOS, although I understand the concept of PWM brightness control.

Link to comment
Share on other sites

Just had a quick look and this DCS-bios looks interesting.

 

info here. ;)

Control is an illusion which usually shatters at the least expected moment.

Gazelle Mini-gun version is endorphins with rotors. See above.

 

Currently rolling with a Asus Z390 Prime, 9600K, 32GB RAM, SSD, 2080Ti and Windows 10Pro, Rift CV1. bu0836x and Scratch Built Pedals, Collective and Cyclic.

Link to comment
Share on other sites

PWM control is built into the Arduino, though only for certain pins. It depends on which Arduino you're using, but for the Uno, the PWM pins are 3, 5, 6, 9, 10, and 11:

 

https://i.stack.imgur.com/dVkQU.jpg

 

Since you have 8 LEDs, this isn't enough to PWM control all of them. You might want to look into one of the other Arduino models that have more PWM pins.

 

To make use of the PWM pins to control LED brightness, you'll need to use analogWrite:

 

https://www.arduino.cc/en/Reference/AnalogWrite

 

The DCS BIOS Arduino library uses digitalWrite:

 

https://github.com/dcs-bios/dcs-bios-arduino-library/blob/master/src/internal/Leds.h

 

You should be able to just copy-paste that code and change digitalWrite to analogWrite:

 

#include "Arduino.h"
#include "ExportStreamListener.h"

namespace DcsBios {
 class PwmLED : public Int16Buffer {
   private:
     unsigned int mask;
     unsigned char pin;
     unsigned int dutyCycle;
   public:
     PwmLED(unsigned int address, unsigned int mask, char pin, unsigned int dutyCycle) : Int16Buffer(address), mask(mask), pin(pin), dutyCycle(dutyCycle) {
       pinMode(pin, OUTPUT);
     }

     virtual void loop() {
       if (hasUpdatedData()) {
         if (getData() & mask) {
           analogWrite(pin, dutyCycle);
         } else {
           analogWrite(pin, 0);
         }
       }
     }
   };
}

 

Note that I didn't test this code myself. If it seems too complicated you can fall back to trying different resistor values, but if you're going to build a cockpit, it's very helpful to learn some basic Arduino coding because it opens up a lot of possibilities. For example, imagine turning a brightness dial in the cockpit and have it change the brightness of your switch LEDs.


Edited by Ranma13
Link to comment
Share on other sites

PWM control is built into the Arduino, though only for certain pins. It depends on which Arduino you're using, but for the Uno, the PWM pins are 3, 5, 6, 9, 10, and 11:

 

https://i.stack.imgur.com/dVkQU.jpg

 

Since you have 8 LEDs, this isn't enough to PWM control all of them. You might want to look into one of the other Arduino models that have more PWM pins.

 

To make use of the PWM pins to control LED brightness, you'll need to use analogWrite:

 

https://www.arduino.cc/en/Reference/AnalogWrite

 

The DCS BIOS Arduino library uses digitalWrite:

 

https://github.com/dcs-bios/dcs-bios-arduino-library/blob/master/src/internal/Leds.h

 

You should be able to just copy-paste that code and change digitalWrite to analogWrite:

 

#include "Arduino.h"
#include "ExportStreamListener.h"

namespace DcsBios {
 class PwmLED : public Int16Buffer {
   private:
     unsigned int mask;
     unsigned char pin;
     unsigned int dutyCycle;
   public:
     PwmLED(unsigned int address, unsigned int mask, char pin, unsigned int dutyCycle) : Int16Buffer(address), mask(mask), pin(pin), dutyCycle(dutyCycle) {
       pinMode(pin, OUTPUT);
     }

     virtual void loop() {
       if (hasUpdatedData()) {
         if (getData() & mask) {
           analogWrite(pin, dutyCycle);
         } else {
           analogWrite(pin, 0);
         }
       }
     }
   };
}

 

Note that I didn't test this code myself. If it seems too complicated you can fall back to trying different resistor values, but if you're going to build a cockpit, it's very helpful to learn some basic Arduino coding because it opens up a lot of possibilities. For example, imagine turning a brightness dial in the cockpit and have it change the brightness of your switch LEDs.

 

Nice. :thumbup:

Control is an illusion which usually shatters at the least expected moment.

Gazelle Mini-gun version is endorphins with rotors. See above.

 

Currently rolling with a Asus Z390 Prime, 9600K, 32GB RAM, SSD, 2080Ti and Windows 10Pro, Rift CV1. bu0836x and Scratch Built Pedals, Collective and Cyclic.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...