4

I am looking to add block detection to my model railroad. I need approx. 40 infrared sensors to power 40 LED's on my control panel. No signals or other logic required yet, just the LED indications -LED- on=occupied off=vacant. How many Uno boards would I need to do this? I may, in the future, look at integrating several two (or three) aspect signals down the track. I am an absolute novice here, never having used an Arduino, nor done any coding of any sort.

  • One Arduino with "I2C I/O exoanders" is enough. – MatsK Oct 8 '17 at 5:53
  • an infrared sensor would not be a good way of telling if an area is occupied or not, only that the occupation has changed at one snapshot in time. can you use super magnets and cheap hall sensors instead? look into reflective sensors and beam interupts as well. – dandavis Oct 8 '17 at 6:09
  • The IR sensors power the LED's in the control panel. The underside of the train reflects the IR beam and the current from the detector lights the LED. Once the train has passed, the beam is uninterrupted and therefore no signal is detected, no lighting of LED. I am looking at using TCRT5000 reflective optical sensor switch for Arduino - I just need to know how many I can attach to a board... – RioGrande89 Oct 8 '17 at 6:52
  • Ahh, I assumed PIR, my bad. it depends on the code, but i doubt you need interrupt-quality timing for trains. With polling, you get at least 16, maybe a couple more without any other hardware. Make sure you have enough juice to power them all. if you get into expanders or ADCs or shift registers, one uno can handle 40 – dandavis Oct 8 '17 at 7:01
  • Being an absolute novice, I have no idea what polling is, ADC or shift registers mean...Given the TCRT5000 has four pins, how many can I run off one board? Can I wire them in parallel, with 6 IR modules per section of track..? – RioGrande89 Oct 8 '17 at 7:28
3

You just want to know how many you can attach to an Arduino board or how many Arduino Uno boards you need, but it does not work like that.

Some sensors with a led require 5mA or 10mA or 20mA. The reflective optical sensors use a IR (InfraRed) led. The Arduino Uno 5V pin can probably not supply enough current for 40 leds. Therefor you might need a seperate power supply.
I think the TCRT5000 is typically set at 10mA.

The Arduino Mega 2560 and the Arduino Due have many pins. But with 40 TCRT5000 sensors, the total current is too close to the limit.

In such situation often extra hardware is added. You can use one Arduino Uno board, with extra hardware for multiple inputs or outputs.

An "expander" is a chip or a module that connects to the Arduino with a few wires, but has many input and/or output pins. For example a "expander" with I2C interface to the Arduino Uno as mentioned by @matsk. Although a I2C expander has a slow I2C interface, they are sometimes smart and can tell which pin has changed by reading a single byte.

"Shift registers" are chips with for example 8 input pins or 8 output pins. The data of the pins is shifted into the chip with a data and clock signal. There are many examples for that: ShiftOut with a 74HC595.

A analog "multiplexer" or "mux" is a chip that can connect one common pin to one of 8 pins. The signal can go both ways. Nick Gammon about a multiplexer.

A "ADC" is short for "Analog to Digital Converter". The Arduino Uno has an internal ADC, but also a external ADC can be used. They have often more than one analog input.

"Polling" is when an Arduino is reading many inputs continuously one by one. If for example it takes 5ms to read a sensor, then 40 sensors take 200ms. That means that every sensor is read once per 200ms. If a train would pass within that 200ms, then it might be not detected.
The opposite of polling is with interrupts. If an external event happens, it could trigger an interrupt and the Arduino can react right then at that very moment. However, 40 interrupts is not possible.

Conclusion:
The best way depends on your hardware and software skills, on the maximum interval that you want to read the sensors, on the sensors themself, and how far apart the sensors are, and if you want 40 wires to a Arduino board.
The best Arduino board also depends on what you want to do with the data and what else the Arduino has to do.
Some sensors have a analog output and some a digital output. It depends on your situation and the way the train is detected.
If possible, then I would choose a solution where all the hardware can be easily be replaced. If the sensor has digital outputs, then I would connect them to a Arduino Mega 2560 or Arduino Due.

  • That's great information, thank you for going to the trouble of explaining everything clearly for me! After doing a bit more research, it looks like it may be possible to achieve what I am looking for without having to use an Arduino at all - depends on how well the TCRT5000 works with a circuit I have found. This uses resistors and an LM358 opamp, resistors and a trim pot to adjust sensitivity. Once I receive my TCRT5000 modules I will wire up on a breadboard and see how it goes. – RioGrande89 Oct 8 '17 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.