3
\$\begingroup\$

Is it possible to control a lot (let's assume 100) of TCRT5000 IR distance sensors with one Arduino? So just use one or a few pins but not 100?

I am relativly new to the Arduino/electronics area and I know about the I2C protocol which would allow that but the TCRT5000 does not support I2C as far as I know.

I have seen people using it but I am not sure how, maybe there is another chip required? Any recommodations where to start?

Datasheet TCRT5000

UPDATE

Wow, what an overwhelming response! Thank you all for all the time and effort you put into this. I will add more details here, sorry that I didn't include them in the first place.


CLARIFIED QUESTION

As it is not necessary to use the TCRT5000 and I think there might be better options I have to clarify more what I am trying to create:

I want to build the concept for a single tile in a board game which is able to:

  • Illuminate the tile in any colour - I already have a good solution by using a low cost addressable LED strip and control it via the Fast LED library
  • Detect if there is a piece on top of the tile - this is where I want(ed) to use the TCRT5000 for - and it is very cheap. But as there is already light in the tile maybe a photocell measuring the reflected light would be an option too.
  • Optionally detect what type of piece is on top of the tile - that is not required but it would open a few more doors in developing the software driving the game. Thought about low cost RFID or magnet detectors. I don't think it is possible to get this cost efficient enough.
  • It should be scalable - so preferably one tile would work independently.

The amount of tiles used in the game will be determined by the cost of a single tile, therefore it has to be as cost efficient as possible.

The cost efficiency if not for me - If I find good solutions for the concept I would like to publish it. And that is only possible if the game is affordable.


GAME TILE

One tile could look like this (not scaled properly, just a sketch) and contains a SD 5050 LED from a LED strip and a TCRT5000 to detect if there is anything on top of it.

Game Tile

The electronics will be covered by a frosted acrylic plate to diffuse the light and protect the components:

Game Tile frosted

Now the task is to detect a game piece on top of the tile:

Game Tile with piece

The piece is obviously not always perfectly centred as the player will just put it somewhere on top of it. But the tile has to be able to detect if there is anything or not.


HELP

As this starts to go way beyond the initial question and I realized how much I don't know about electronics yet I would like to ask for help with the project.

If anyone finds this idea interesting I would be happy to discuss more details about the project outside of StackOverflow.

As this is a private project I cannot really pay money but if we get to the stage where the game is published you will get a free copy of the game and at least one carton of beer ;)

Please write me at ledboardgame/gmail.com (replace the / with @) including your experience (just tinkering, evil mastermind, ...)

\$\endgroup\$
10
  • \$\begingroup\$ You could easily scan 100 of them in a 10 X 10 array, but that sensor isn't really a distance sensor unless you're using it in a go no-go sort of way. What are you trying to do? \$\endgroup\$
    – EM Fields
    Commented Aug 21, 2014 at 11:59
  • \$\begingroup\$ I want to build a board game which can detect for each tile if there is a piece on it or not. I am more than open for other suggestions... :) \$\endgroup\$
    – Marc
    Commented Aug 21, 2014 at 12:37
  • \$\begingroup\$ But it is basically an "object detected/not detected" switch I try to make. As I need 100 or more the single chip should be affordable and the TCRT5000 is. \$\endgroup\$
    – Marc
    Commented Aug 21, 2014 at 12:45
  • \$\begingroup\$ Are all tiles the same or do you need to differentiate between / identify individual tiles? e.g. each player's tiles or chess like pieces. \$\endgroup\$ Commented Aug 21, 2014 at 13:05
  • \$\begingroup\$ The tiles are all the same. The pieces are different and it would be a great bonus to identify them but that's not necessary. Yes it is like chess where the board always knows where all pieces are but not what kind of piece. \$\endgroup\$
    – Marc
    Commented Aug 21, 2014 at 13:14

6 Answers 6

4
\$\begingroup\$

Some answers have explained how to 'multiplex' the emitters and sensors. The scheme suggested here can use that, or not. For emitters there is no need if the sensors are well isolated from the emitters.

You seem to be very cost conscious, as am I. The cheapest way to make a simple reflective sensor is with an InfraRed (IR) emitter and IR phototransistor. That pair will be well under 0.20GBP, which is much lower cost than the TCRT5000.

For example 940nm 5mm IR emitter 940nm 5mm IR phototransistor. Most distributers should have parts in this price range. To give some context, these would cost about £4.60 for 100 IR emitters, and £7.50 for 100 phototransistors. These are Farnell prices, which is one of the most expensive distributers. So you should be able to do much better.

You could drive the IR emitters with a chain of shift registers. Use 'Serial In Parallel Out' (SIPO) shift registers. They will take a serial data pattern to choose which emitters to drive. That would consume three or four pins (clock, data, enable, latch) for all 100 emitters. For example TLC5916

If the internal structure of the board shields IR phototransistors from IR emitters you could even drive many emitters simultaneously using each pin of a chip like the TLC5916 which would drive much more current than an Arduino pin. So you might be able to drive all of the emitters with a couple of TLC5916.

With a bit of experiment, you should be able to read all of the sensors using simple logic-level shift-registers too. Parallel In, Serial Out (PISO) shift-registers. The issue is not power, so cheaper parts are sufficient, for example a 74HC165 (which should be available for under $1). These can be 'chained' end to end, and even used with a multiplexing scheme.

Daylight, or electric lighting may interfere, and 'confuse' the IR sensors. One way to cope with that is to 'modulate' the IR LED/emitter. Using one LED+sensor as an example: switch the IR LED on, take a measurement from the sensor, switch the LED off, and take another. When the difference is very small, there is a lot of light interference, and very little reflected light, so the piece is unlikely on the square. When the difference is large, the piece is likely on the square because there is very little light interference, and the reflected light is strong.

Experiments might demonstrate that this is not an issue. However, having the flexibility to deal with this type of interference might become very important. So try to ensure it is practical to with IR LED/emitter on and off, until you have some real evidence to show it is not an issue.

\$\endgroup\$
6
  • \$\begingroup\$ Multiplexing can be done in more than one way. Emmiters (the LEDs) can be on all the time, but then you need to multiplex both collectors and emmiters of the phototransistors. Still it will be 2*sqrt(n) GPIOs with sqrt(n) times the power consumption. \$\endgroup\$
    – venny
    Commented Aug 21, 2014 at 16:30
  • \$\begingroup\$ For the cost-conscious hobbyist, TCRT5000 can be obtained for just over US$1 for 10 pieces. Besides the low price, I prefer the TCRT over discrete parts as it has a housing for the emitter and sensor, with a plastic "wall" isolating one from the other. \$\endgroup\$ Commented Aug 21, 2014 at 17:05
  • \$\begingroup\$ @AnindoGhosh - that is an impressive price. However, given that it is made from an IR emitter and phototransistor, I'd expect some searching on web sites e.g. Aliexpress will find those parts even more cheaply. I do agree on the plastic 'wall' isolation. \$\endgroup\$
    – gbulmer
    Commented Aug 21, 2014 at 17:10
  • \$\begingroup\$ @gbulmer Agreed on finding parts cheaper on Chinese bulk sources - that actually applies to TCRT5000 as well: I've been paying around $7 for TCRT5000 bulk packs of approximately 150 pieces each. \$\endgroup\$ Commented Aug 21, 2014 at 17:14
  • \$\begingroup\$ @venny - agreed, there are many ways to multiplex. I was assuming daylight, electric light might interfere, so I modulating the LEDs is a way to reduce that interference. Each pin of a TLC5916 can sink 120mA, so 3x a single Arduino pin and IIRC more than an entire 8-bit Arduino port (to stay within spec). For the distances involved, 10 mA/LED might be okay, so running all LEDs from one TLC5916 might be feasible. Phototransistors are only a few mA, so multiplexing the collectors is practical. But, sqrt(100)*2 phototransistors is still more pins than a single Arduino. So something is needed. \$\endgroup\$
    – gbulmer
    Commented Aug 21, 2014 at 17:25
4
\$\begingroup\$

Take a look at this simple matrix circuit. It requires only sqrt(n)*2 GPIOs. Scanning through 'rows' is done by turning the IR LEDs on and off. Only one 'row' is lit at a time, which also saves power.

It shows 9 sensors in 3x3 matrix connected to 6 GPIOs.

cir

External transistors are needed because with larger number of LEDs, the current draw gets significant. Either N-MOSFET or NPN will do. G[0..2] is input for switching LEDs, C[0..2] is output from phototransistors. Light=logic low, no light=logic high.

Edit: as @gbulmer pointed out, it is important to cancel out any ambient light. To do this, circuit has to be slightly modified - emitters of phototransistors E[0..2] are switched between low (photocurrent, either from leds or ambient, can flow) and tri-state (no photocurrent). LEDs may be switched all at once or in groups as in previuos circuit. Outputs C[0..2] are read by ADC, first with LEDs off and then with LEDs on.

cir2

\$\endgroup\$
2
  • \$\begingroup\$ Oops, the gate pull-downs should have been around 150k, not 150R. \$\endgroup\$
    – venny
    Commented Aug 21, 2014 at 14:17
  • \$\begingroup\$ If you wanted to be really clever, I think you could do it with 4*sqrt(sqrt(n)) GPIOs if you multiplex both the LEDs and transistors in a 4D grid. \$\endgroup\$ Commented Jan 5, 2017 at 3:39
1
\$\begingroup\$

Below is a 10 X 10 array which I think is about as simple as it gets with only 5 I/Os needed to your MCU, and here's an LTspice schematic if you want to play with the circuit.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ I see a problem here. If ambient light is able to cause photocurrent greater than 1/10 of logic decision level, it will cause false positives. \$\endgroup\$
    – venny
    Commented Aug 23, 2014 at 13:56
  • \$\begingroup\$ That's not an electronic design problem, per se, it's an opto-mechanical problem and has little to do with my circuit. In any case, though, if the logic decision level is sitting at 2.5 volts and ambient light causes a .25 volt offset from either rail, how is that going to cause a false positive? \$\endgroup\$
    – EM Fields
    Commented Aug 23, 2014 at 14:12
  • \$\begingroup\$ The pull-up resistors are 10k, so threshold current is 0.25 mA. And if e.g. U91-U100 are not in complete darkness and conduct 0.025 mA each, it will be interpreted as logic low. \$\endgroup\$
    – venny
    Commented Aug 23, 2014 at 14:25
  • \$\begingroup\$ Yup, you're right, and that's why adequate care should be taken when doing the opto-mechanical design in order to make sure that inordinately small-valued pullups aren't required. \$\endgroup\$
    – EM Fields
    Commented Aug 23, 2014 at 14:58
0
\$\begingroup\$

You are probably better off selecting a smarter device.

I'm sure there are IR sensors that have I2C (or similar) on them, some of which would satisfy your requirements. But on the other hand, do you really need a 100 of them? Such massive rats-nests often create reliability issues, especially if connected via wires and/or breadboard.

How about moving one of these mechanically instead?

\$\endgroup\$
1
  • \$\begingroup\$ Thank you very much for your answer. I think about using the TCRT5000 because it is very cheap and therefore affordable if used 100 times. Moving them would not work as I have to detect multiple objects (board game with piece detection). \$\endgroup\$
    – Marc
    Commented Aug 21, 2014 at 12:40
0
\$\begingroup\$

Everything is possible :)

Dzarda's answer would be the easiest and probably the best one, but if its out of question, this would be another possibility:

Build a "state machine" with transistors that controls which sensor you are reading data from. For example, using a single analog input for reading sensor data and 7 digital outputs for driving state machine that connects a certain sensor to the input at the time. With 7 IOs you could control 2^7-1=123 sensors. This only requires somewhat complex additional state machine circuitry alongside your arduino.

\$\endgroup\$
0
\$\begingroup\$

gbulmer suggested reading the output using shift registers. It may be possible to connect all the detector outputs together, then shift one bit in to the IR emitter control register and shift it along the whole line. That way you would effectively get serial data out and eliminate the output registers. I'm not very experienced, so I don't know if this would work, but it would be interesting to look into.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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