Controlling 100 LEDs with a PC?

  • Thread starter kolleamm
  • Start date
  • Tags
    Leds pc
In summary: A work-around for the Multiplex brightness problem is to increase the LED current to compensate for the short ON time (duty cycle). Of course there are limits to this to keep the LEDs cool enough to survive. Generally, keep the average current in an LED well within its maximum rating. If the 1% duty cycle just does not meet your needs for brightness, it can be increased up to 10% with a few more ICs for...A work-around for the Multiplex brightness problem is to increase the LED current to compensate for the short ON time (duty cycle). Of course there are limits to this to keep the LEDs cool enough to survive. Generally, keep the average current in an LED well within its maximum rating
  • #1
kolleamm
477
44
I would like to turn on and off 100 external (non screen) LEDs through my PC.
I was thinking to assign each pin on my serial port an LED, because apparently you can control the power on serial port pins if I understand correctly.

The problem is that even if I do control each pin on a port, what if I have more LEDs than I have pins to control them?

For example how would one control 100 LEDs with 32 pins?
 
Technology news on Phys.org
  • #2
kolleamm said:
... apparently you can control the power on serial port pins if I understand correctly.
You do not understand serial ports at all. Check out what the 9 pins in a PC serial port do:
https://en.wikipedia.org/wiki/Serial_port
 
  • #3
phinds said:
You do not understand serial ports at all. Check out what the 9 pins in a PC serial port do:
https://en.wikipedia.org/wiki/Serial_port
Ah I see, so in that case it would communicate one bit at a time. Even then how would I create a circuit that cycles through each LED and turns it on or off?
Each LED would be like a variable that needs to maintain its value.
 
  • #4
You are going to need some kind of external circuit that is controlled by the pc and then itself controls the LEDs. There are various kinds around but I have no recommendation.
 
  • #5
kolleamm said:
I would like to turn on and off 100 external (non screen) LEDs through my PC.

phinds said:
You are going to need some kind of external circuit that is controlled by the pc and then itself controls the LEDs.

Two possible ways would be:
1) Communicate using the PC's USB port to a separate "USB interface board." The board would be treated as a peripheral device--via HID protocol.
2) Communicate to an Arduino (or equivalent).

There are a lot of variables here: how powerful are the LEDs, how many would you control at the same time, how many are on at the same time, ...
 
  • #6
SunThief said:
Two possible ways would be:
1) Communicate using the PC's USB port to a separate "USB interface board." The board would be treated as a peripheral device--via HID protocol.
2) Communicate to an Arduino (or equivalent).

There are a lot of variables here: how powerful are the LEDs, how many would you control at the same time, how many are on at the same time, ...
Basically the small current coming from the computer would activate a transistor, so the power supply would be separate.
The LEDs don't need to be updated at the same time, they can be updated iteratively, 0,1,2,3,4...

I know that I can achieve this with a pin for each LED's transistor but is that really the best solution?
 
  • #7
kolleamm said:
I know that I can achieve this with a pin for each LED's transistor but is that really the best solution?
Welll... it depends.

Usually high-count LED's are wired as a matrix.
To do that, think of your 100 LEDs as a 10×10 array.
Each row of LEDs has one of their pins connected to a bus.
Each column of LEDs has their other pin connected to a bus.
This allows you to uniquely address 100 LEDs using 20 wires; apply power and ground to a row and a column and one LED will turn on.
You sequentially energize the ON LEDs rapidly enough that your eye doesn't detect they are really switching on and off.
This approach is called Multiplexing.

The other approach is individual control of each LED, with a wire and usually with some memory element (a flip-flop or a storage register) for each LED.

The trade-offs are:
  • Multiplexing
    • requires continuous refreshing, i.e. it is a dynamic solution so a faster driver and controller is needed.
    • the perceived brightness is proportional to the current and to the duty cycle of each LED
    • only one LED is ON at a time so little power is needed
    • simpler wiring
    • fewer parts for the driver
  • Individual Control
    • can use a slower driver and controller since it is used only when a display change is needed
    • since the duty cycle is 100%, brightness is proportional only to LED current
    • high power needed to supply all the LEDs at once.
    • more wiring but easier to troubleshoot
    • more parts for the driver

    In any case, you are going to need more control lines than the typical computer has these days. That means some sort of additional electronics, whether it is a plugin card to a tower or rack computer, an external microcomputer with sufficient I/O, or a few ICs wired together on a breadboard.

    A work-around for the Multiplex brightness problem is to increase the LED current to compensate for the short ON time (duty cycle). Of course there are limits to this to keep the LEDs cool enough to survive. Generally, keep the average current in an LED well within its maximum rating. If the 1% duty cycle just does not meet your needs for brightness, it can be increased up to 10% with a few more ICs for the driver and some careful programming.

    Almost all displays larger than 16 elements use the Multiplexing approach, even the screen you are reading this on is multiplexed.

    If you could explain more about your project, perhaps we could help with some of the unstated trade-offs.

    Cheers,
    Tom

    p.s. An alternative to a 10×10 array is to use four 5×5 arrays which needs 14 wires instead of 20... but it is harder to think about!
 
  • Like
Likes Klystron, russ_watters, .Scott and 1 other person
  • #8
Tom.G said:
Welll... it depends.

Usually high-count LED's are wired as a matrix.
To do that, think of your 100 LEDs as a 10×10 array.
Each row of LEDs has one of their pins connected to a bus.
Each column of LEDs has their other pin connected to a bus.
This allows you to uniquely address 100 LEDs using 20 wires; apply power and ground to a row and a column and one LED will turn on.
You sequentially energize the ON LEDs rapidly enough that your eye doesn't detect they are really switching on and off.
This approach is called Multiplexing.

The other approach is individual control of each LED, with a wire and usually with some memory element (a flip-flop or a storage register) for each LED.

The trade-offs are:
  • Multiplexing
    • requires continuous refreshing, i.e. it is a dynamic solution so a faster driver and controller is needed.
    • the perceived brightness is proportional to the current and to the duty cycle of each LED
    • only one LED is ON at a time so little power is needed
    • simpler wiring
    • fewer parts for the driver
  • Individual Control
    • can use a slower driver and controller since it is used only when a display change is needed
    • since the duty cycle is 100%, brightness is proportional only to LED current
    • high power needed to supply all the LEDs at once.
    • more wiring but easier to troubleshoot
    • more parts for the driver

    In any case, you are going to need more control lines than the typical computer has these days. That means some sort of additional electronics, whether it is a plugin card to a tower or rack computer, an external microcomputer with sufficient I/O, or a few ICs wired together on a breadboard.

    A work-around for the Multiplex brightness problem is to increase the LED current to compensate for the short ON time (duty cycle). Of course there are limits to this to keep the LEDs cool enough to survive. Generally, keep the average current in an LED well within its maximum rating. If the 1% duty cycle just does not meet your needs for brightness, it can be increased up to 10% with a few more ICs for the driver and some careful programming.

    Almost all displays larger than 16 elements use the Multiplexing approach, even the screen you are reading this on is multiplexed.

    If you could explain more about your project, perhaps we could help with some of the unstated trade-offs.

    Cheers,
    Tom

    p.s. An alternative to a 10×10 array is to use four 5×5 arrays which needs 14 wires instead of 20... but it is harder to think about!
Thanks for the suggestions, I used LEDs as an example of an external device I would like to control, but since I need to be more specific, I would really like to control about 16 electromagnets, possibly more.

I'm not sure if multiplexing would work in this case since only one electromagnet could be on at a time, so some sort of individual control may be necessary.
Let me know what you think, thanks!
 
  • #9
Your PC has a serial port? How old is it?
 
  • #10
For a fast/cheap project I would pick an USB-SPI or USB-I2C cable and a bunch of addressable IO expander boards (with matching interface).
Some fiddling might be needed on the outputs to bring them up one by one to the requirements of the LEDs (or electromagnets or whatever).
 
  • #11
kolleamm said:
Thanks for the suggestions, I used LEDs as an example of an external device I would like to control, but since I need to be more specific, I would really like to control about 16 electromagnets, possibly more.

I'm not sure if multiplexing would work in this case since only one electromagnet could be on at a time, so some sort of individual control may be necessary.
Let me know what you think, thanks!
First, in a 4x4 with electromagnets, any combination within a single row could be on.
But there are problems. You don't want to connect your PC circuitry directly to an electromagnet. You need some circuitry in between that is more robust and able to withstand current spikes. But you can still set them up in a matrix. Each EM will likely require a cap and diode to keep the current flowing between refresh cycles.
 
  • #12
Do you want to build this gizmo - or buy one. There really are many ways to do this.
 
  • #13
Windadct said:
Do you want to build this gizmo - or buy one. There really are many ways to do this.
I would really like to just buy it and save time. The problem is I don't really know what to buy. I'm leaning towards a micro controller like PI3, but I want to be sure.
 
  • #14
A Pi3 will kind of work, but that is a little different than controlling with a PC - With a Pi you can make a standalone or PC connected system, but each element makes it more complicated.

OK - so you have 16 or more electromagnets, you just want to turn them on and off, correct?
Anything else?

Could you make a block diagram or something?
 
  • #15
Windadct said:
A Pi3 will kind of work, but that is a little different than controlling with a PC - With a Pi you can make a standalone or PC connected system, but each element makes it more complicated.

OK - so you have 16 or more electromagnets, you just want to turn them on and off, correct?
Anything else?

Could you make a block diagram or something?
Here is a diagram I made that may make things clearer.
 

Attachments

  • electromagnet circuit.jpg
    electromagnet circuit.jpg
    25.1 KB · Views: 380
  • #17
You might try looking into MIDI show controller (MSC) sequencers like those used for light shows and to trigger pyrotechnic displays.
 
  • Like
Likes Klystron
  • #18
A complete (product) like this seems to fit the bill... 24 Channel USB - I/O Module - This is powered by the USB, so see my note below about the ElectroMagnet load.

This can probably be done DIY for about $100. For PC control you can use a USB-GPIO ( General Purpose Input Output) Bridge. With at least 16 channels or Pins available.
Example from Sparkfun

You then need to find out what the power requirements are for the Electromagnets. And develop a simple driver circuit, or possibly a driver IC will work, since the outputs of the interface / controller probably can not support the load of the EMs.
 
  • Like
Likes kolleamm
  • #19
kolleamm said:
I would really like to control about 16 electromagnets, possibly more.
Have you chosen the electromagnets? How big are they? What king of wattage will they draw?
A part number would be useful.

For example, any of this page? :
https://buymagnets.com/shop/246/Electromagnets-and-Power-Supplies/Electromagnets/Round-Electromagnets-Flat-Faced/?_vsrefdom=GAW&kw=&gclid=EAIaIQobChMIjqLAibWm3AIVDHp-Ch3_lw45EAkYASABEgLUAfD_BwE
 
  • #20
Windadct said:
A complete (product) like this seems to fit the bill... 24 Channel USB - I/O Module - This is powered by the USB, so see my note below about the ElectroMagnet load.

This can probably be done DIY for about $100. For PC control you can use a USB-GPIO ( General Purpose Input Output) Bridge. With at least 16 channels or Pins available.
Example from Sparkfun

You then need to find out what the power requirements are for the Electromagnets. And develop a simple driver circuit, or possibly a driver IC will work, since the outputs of the interface / controller probably can not support the load of the EMs.
That first product from Amazon seems to be exactly what I'm looking for!
(Although I'm not sure it has an SDK, since I need to write code for it)
I have no problem in developing the driver circuit, all it really needs is a transistor between one of the wires leading to the electromagnet that will control the flow of current, and possibly some EM noise protection.
I'm guessing if I wanted to control even more electromagnets I could just extend my USB ports and plug in more of these devices.
Thanks a lot
 
Last edited:

1. How do I connect 100 LEDs to my PC?

To connect 100 LEDs to your PC, you will need to use a microcontroller such as an Arduino, Raspberry Pi, or PIC. The microcontroller will act as an interface between the PC and the LEDs, allowing you to control them through the PC's software.

2. What software do I need to control 100 LEDs with my PC?

You will need to use a programming language such as Python, Java, or C++ to write the code for controlling the LEDs. The microcontroller will also come with its own software or integrated development environment (IDE) that you can use to upload your code to the microcontroller.

3. How do I code the LEDs to turn on and off in a specific pattern?

To code the LEDs to turn on and off in a specific pattern, you will need to use a loop in your programming language. For example, in Python, you can use a for loop to iterate through each LED and turn it on or off based on your desired pattern.

4. Can I use different colors for the LEDs?

Yes, you can use different colors for the LEDs by using RGB LEDs or by connecting different colored LEDs to your microcontroller. You can then use your programming language to control the brightness and color of each individual LED.

5. Is it possible to control the LEDs remotely?

Yes, it is possible to control the LEDs remotely by using a wireless communication module such as Bluetooth or Wi-Fi. You will need to write code to establish a connection between the microcontroller and the remote device, and then you can control the LEDs through the remote device's software.

Similar threads

  • Programming and Computer Science
Replies
11
Views
844
  • Programming and Computer Science
Replies
2
Views
2K
  • Electrical Engineering
Replies
3
Views
1K
  • Computing and Technology
Replies
25
Views
9K
  • DIY Projects
Replies
9
Views
2K
  • Computing and Technology
Replies
3
Views
1K
Replies
8
Views
902
Replies
37
Views
3K
  • Electrical Engineering
Replies
12
Views
956
Replies
6
Views
2K
Back
Top