... and, ADVANCE APPROACH (flashing yellow) when the next next next block is occupied, in some territories...
As I noted in another thread, using PWM to lower your average output current to a range that meets the processor or output expander spec is fine, until you write a 'special' piece of code that erroneously sets all the PWM outputs to full on instead of off, for example. Sure, you might reach the power switch in time... or you might get away with it because the spec is conservative... or Murphy might just be napping, or looking the other way. Besides, those chips will take a beating, as evidenced every day on this forum, right?
Since the result for most of us would at worst be a toast Arduino, I suppose the risk is small, but in my books it's a poor design that deliberately builds in an out-of-spec performance that needs software mitigation to prevent damage. YMMV, yada, yada.
As for RR signaling, Get yourself a copy of the OPSIG's tome on operations. More than most care to chew on, but it's a fantastic read. Contact me if you're interested in more details.
Yes, but you can use PWM for more... my signalling implementation has ramp up/down to simulate the tungsten filament delay in the bulbs.
@anon57585045, I don't care about the use of PWM for LED dimming per se, I'm talking about the use of PWM to deliberately prevent excessive current on an output, depending on things like "well, I'll never set the output to more than 50% in software, so it's okay that if I set it to 100%, the pin will draw 50 mA" sort of thing, which was alluded to elsewhere.
I agree with you. I don't like to build hardware that can burn up if the software goes bananas.
why are you mentioning PWM? as a way to limit current?
wouldn't it you now need to specify a PWM value for each LED?
and there are a limited # of pwm pins
Uno, Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) |
---|---|---|
Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) |
Well, I set up one signal tower with my Uno board last night and this time it worked. Wrote the program to turn on each light for 10 seconds, turn it off and move on to the next light. Ran it for over an hour with no issues except one. Using USB power, which I assume is 5v and the signal having a 1K resistor common to all the leds, the green and yellow burned fairly bright while the red was visible from a distance but not really bright. My guess is the yellow and green are running on 2.2 volts while the red is 3.2 volts. Today I am going to change out the 1K common resistor and install separate resistors for each color so they all have the same brilliance. I have the time and a crap load of resistors! Just really glad it worked. Much easier than the transistor route, although I can see where I will need to use the transistor boards I made elsewhere when I need to use 12 volts for the loads instead of 5V. This weekend I will be installing all 8 signal devices and running the wiring to the Arduino Mega board which will be controlling all 8 signals using zone detectors to identify where the trains are on the tracks and turning on and off the correct signal lights.
Hi,
Get out your DMM, connect each of the coloured LEDs up to 5V supply with 1K in series with each LED.
THEN, measure the voltage across each of the coloured LEDs and write them down.
This is the only way you will know what the basic volt drop is for each coloured LED.
Then you can calculate properly what your series resistors should be to try and get equal luminance.
Thanks.. Tom..
i don't believe there is any correlation between voltage and brightness. different color LEDs operate at different voltages and have different efficiencies, and in general you can't expect the same brightness at the same current.
i've driven MR signal LEDs with 3.3V from an esp32. just find the right size resistor.
Only need to adjust one, the other 2 are good. Math tells me to use a 100 ohm resistor. I'll start there and see. 5V-3V/.02mA=100 ohms Was really surprised to measure 1K for the installed resistor for these lights. Way more than it needs. They must have calculated for 20 volts! Wait, I know, they were doing their calculations using Metric volts! LOL.
20mA is a maximum current value, for this application it's likely that would make most LED's look way too bright. It sounds like you have the right idea - try different values. Because luminous efficiency varies so much, voltage calculations don't mean much.
i have some older LEDs that operate above 50ma. but i agree todays LEDs seem bright at 5ma
just really need STOP
we started adding signals to the club layout. some thought they would be "purdy", but members are finding them usesful.
this signal lets you know it clear past the tunnel
and there's another signal on the other at the far end of the photo
This site has collected all the vintage ideas, and modernized many of them, they are simple DIY circuits, no MCUs:
http://www.circuitous.ca/CircuitIndex.html
It's been the best around for that, since well before year 2000. The maintainer has moved on, doesn't respond. I contributed to it, back in the day...
the rob paisley should be well known to the more electrically inclined MRer (but those are few). but the paisley site is about electronic circuits.
this thread hit on perhaps the biggest hardware issue with signals, dealing with LEDs targeted for various voltages, some common anode, other cathode. figuring out how to deal with them uniformly is part of the trick.
the logic for basic signals is pretty straight forward. handling their I/O and the inputs for those decision in a methodical way can significantly simplify the software.
distributing their processing seems essential unless you like lots of wires.
but even an rs-485 bus for communication between nodes is becoming obsolete as WiFi processes become prevalent
but even the use of TCP may be outmoded compared to broadcast UDP.
these are presumably the issues the OP will face shortly
the logic for basic signals is pretty straight forward
Yes, and it's worth noting that the ABS system itself originated in the 1920's when the only practical signalling was by wire, the logic was only (and remained until quite recently) relays.
Just as with code, a compartmentalization of hardware functions makes the system easier to design and maintain. Also, it helps limit the number of interconnections, as you infer.
After figuring out the wiring and logic that would work, next came the power limits of the board. Looked like I may have been overloading the board by running 8 lights at once (one light in each of 8 signals).
Well theory (math) is nice, and a good starting point, but reality is better.
The signals I am talking about are (model) railroad trackside warning signal devices that have a red, yellow and green light, and depending on which light is lit, tells the train's Engineer if it is safe to continue down the track.
Each of these signals are 2.1/2" in height and the LEDs use 30 gauge wires and a 1K resistor.
I connected the red LED on all 8 signal devices to my variable power supply, turned it on and lit all 8 red LEDs with 5 volts, and wow, all 8 only used .023 amps total.
I then disconnected 7 of them and a single red LED only used .002 - .003 amps. I connected the rest of the signals one at a time, and 2 signals used .006 amps, 3 signals used .009 amps, 4 signals used .011 amps, 5 signals used .014 amps, 6 signals used .017 amps, 7 signals used .020 amps and all 8 signals again only used .023 amps.
If this is the case, that is less than the max output from a single pin.
So, my plan is to connect the signals to the Arduino Mega 2560 one at a time, monitor the total current the Arduino in using after connecting each signal, and see just how much these signals are using.
Okay, but you will lose a lot of accuracy, since the LED current is much much less than the supply current. Why not just measure each LED current directly, while it is driven by the Mega?
You're just not sure how? Or?
Yes, I know how to do that, but why waste time measuring? I am not looking for matched current, looking for matched brilliance, and more variables there than just current. I have a lot of these nifty plastic snap-lock wire connectors, I put one on the end of each of the 4 wires (the common supply wire and the return from each LED) coming from the signal device, snap a resistor into the other side of the connector in the ground path for the 3 return wires, apply 5 volts to the supply wire, ground out the resistors and use my calibrated eyeballs to see how well the 3 lights match each other in brilliance. If I need to adjust one, simply snap out it's resistor, replace it with another, ground it and again use my calibrated eyes to see if I like the brilliance and matchup between the 3 bulbs. Takes seconds this way, no measuring, no math, just fast results.
These quick connectors are great, especially for mockup wiring, breadboards and even on the layout! Raise the lever, push in the wire, snap the lever down, locked in place. To change the wire, raise the lever, wire comes out, push in another, snap it in place and done. Works on #12 - #28 gauge wire and you can take a voltage reading in the hole.
You can even link them together for more wires if you need to.
They also make 1 in / 2 out, 3 out, 4 out and 5 out as well as 2 in 4 out, 6 out, 8 out connectors as well.
Got them on Amazon.
I thought there was an ongoing discussion about how much the CPU could safely supply... you, yourself, talked about a total current measurement. Measuring the individual pins is more relevant as far as MCU pin safety, and you can get the total by adding them up.
Also if there are multiple identical LED circuits, you only need to measure one of them. So maybe 2 measurements, one for each LED colour.
Do you know how? My response was to the last statement in reply #38.