Reading data from ~200 LDRs.

Hello everyone,

I'm a total beginner, but I'll try to make it concise.

I plan to make an action-film style lasergrid (there's more to the concept, but irrelevant here) with about 150-240 lasers.

What I need:

  • A way to use ~200 LDRs with the least amount of Arduino controllers possible (only 1 is highly preferrable). They need to send data (boolean) once when the contact with a laser is disrupted.
  • If by any means possible, I'd like to determine which LDR sent a signal
  • Latency is not critical, a signal / change in signal can be delayed a few dozen ms.

What I know:

  • I figured out how this works for a single laser / ldr combo, but I noticed I'd run out of analog pins really quickly.
  • I found out there is something called "muxing", which seems to me like a form of converting multiple signals into one long signal, which then can be interpreted at another point back into multiple signals.

If I did this, could I still find out which LDR sent a signal? If yes, I have no idea how to do this or what I'd need, and if this would be feasible at my scale. If yes, could you tell me the general approach? If not, could you point me to other possibilites?

Thank you for your time. If you need any further information, please ask!

Sounds a bit ambitious this , especially on the build cost side and your level of experience.
To get experience why not first build with say 6 lasers and see how you get on , then expand .
You will have enough I/O for that ( you could use digitals just for beam break and adapt analogs as digitals too) .
You could save on laser and sensors using some mirrors.
Have a look at used disc gear - might be something you could use there - moving laser ?

If you just want an ON/OFF indication there is no need to use analog inputs. With a suitable choice of resistor (for the voltage divider) you can get a HIGH or LOW signal.

...R

@hammy

Thanks for your input! Budget is taken care of, so that shouldn't be an issue. Building with 6 lasers I'd do without any muxing or anything, but I'm afraid I'd fail as soon as I have more lasers than pins available, hence my question about muxing.

Saving on lasers isn't possible, since getting a signal from breaking the lasers is integral part of the concept (art project).

@Robin2

Thanks for your answer! Even with digital input instead of analog, there are only 54 pins (I have 1 Arduino Mega to work with so far). Is there a way to use multiple resistors per pin?

Thanks for your time :slight_smile:

You could do a multiplexing scheme as illustrated below for a 9 element (3 x 3) matrix.

The concept is that one column, say Col0, would be pulled high by a GPIO output pin while the other columns are pulled low. The row values would be read by analog inputs (one input per row) to get the state of each LDR in the column. Then the next column input would be pulled high with the rest low and so forth.

The diodes prevent current from backfeeding through LDRs in unselected columns. R10, R11, R12 form the voltage divider between the LDR of the selected column and their respective rows.

A 15 x 15 matrix would give 225 nodes with 30 IO pins.

MrMark:
The row values would be read by analog inputs (one input per row) to get the state of each LDR in the column.

I think that should also work for digital inputs - there are more of them and they are much faster. And analog pins can also be used as digital pins.

And the digitalWriteFast library is very much faster than the normal digitalWrite / digitalRead

...R

What's the minimum time for a valid beam break, i.e. how quickly must all 200 sensors be checked?

Also consider what shall happen on detection of one or more beam breaks, how fast reactions are required. How much time is spent in reacting?

Using multiple controllers is not an option if speed is a requirement, because the transmission of every single change will take much longer than testing a couple of inputs.

How far are the sensors away from each other, what's the total lenght of all cables between the sensors and the controller? Are motors or other devices around which pollute the electric environment? In a real environment a 6 sensor model does not scale up easily to 200 sensors.

A way to use ~200 LDRs with the least amount of Arduino controllers possible (only 1 is highly preferrable). They need to send data (boolean) once when the contact with a laser is disrupted.

LDRs are VERY slow to react. You'd be better off using phototransistors, which are orders of magnitude faster.

PaulS:
LDRs are VERY slow to react. You'd be better off using phototransistors, which are orders of magnitude faster.

True.

But could a 16MHz Arduino operate fast enough to monitor 200 LDRs, never mind 200 fast phototransistors?

...R

Reading ports or port extenders return the states of 8 inputs at once, which can be compared to their last state in one more instruction. Similarly in a sensor matrix an entire row or column can be read at once. That's the easy part of the job. But then comes the part where the system has to show some reaction, and for that part a couple of sub-controllers may be helpful.

Robin2:
But could a 16MHz Arduino operate fast enough to monitor 200 LDRs, never mind 200 fast phototransistors?

Smart wiring to 4 complete 8-bit ports on a Mega would allow you to scan a matrix really really fast. Probably tens of thousands of times a second.

@MrMark

Thank you for the multiplexing scheme! This is super handy. I'm a bit unsure now about the number of LDRs (and lasers) used since people point out problems. Still, the scheme will come very handy, if only for a theoretical "expansion" of the project.

@DrDiettrich
Upon breaking a beam, a boolean signal should be send, as fast as possible. I realize LDRs are a bit slow on that side as pointed out by PaulS. I was aiming for a reaction within maybe a 100ms? It's not critical though. What's realistic? I'm free with placing the sensor, I thought maybe ~30cm between sensors? Cable length is indetermined, but nothing beyond 10m. Is that way too much?

As for the part of the system reacting, the reaction will be audio only. Like changing intensity and frequency of a few pitches, or a few high pitches on beam break. IF this is too much for the arduino to handle concurrently, I could bring a PC into the mix and run everything while connected to the PC, controlling the raction with the PC, to take off load. I'd rather not, but it's a possibility.

@PaulS
Thanks for the warning... would using phototransistors change anything in schematics or is it still just "point laser -> change in resistance"?

@wvmarie
That sounds amazing and also went totally over my head. :confused:

I'm not ready to give up on the amount of LDRs (or phototransistors) just yet, but now that I know I can use digital pins as well (which is obvious now that I think about it), 50 lasers would not the worst as a starting point. Because it does indeed seem like I'm a bit in over my head with multiplexing and matrices. :^)

or is it still just "point laser -> change in resistance"?

A transistor is either on or off. When there is light hitting it, it is on. No light, it is off. A phototransistor won't tell you how much light - only whether there was enough light to get it excited.

Multiplexing digital inputs is easier than multiplexing analog inputs, so that's another reason to use phototransistors.

wvmarle:
Smart wiring to 4 complete 8-bit ports on a Mega would allow you to scan a matrix really really fast. Probably tens of thousands of times a second.

I have been assuming all along that the OP expects his Arduino to do something with the data from each scan, and that is likely to bring the repetition rate down to the hundreds per second.

At the moment this is a typical XY Problem

...R

@PaulS
I see, thanks. Resistors seem the way to go then.

@Robin2
I read the article about the XY problem and now I feel bad for wasting your time. :frowning: However, I'm not sure how I could improve my question. I need a boolean signal when the beam is broken and if possible find out which beam broke. I did not think about the required reaction to this in terms of computing power, so that's on me.

The required reaction is something like "adjust sound intensity / frequency based on how many beams are broken. Also, play a sound when a beam breaks". I didn't think this was relevant. sorry

If there's anything else unclear, please tell me what you'd like to know!

Transistors are analog by nature, not digital. But that's not a problem here, because Arduino inputs have a hysteresis and can convert analog signals into digial ones. Transistors are faster than LDR, though.

The real problem sits at the effects side, which is not very clear right now. A single audio channel is not a problem, but 200 channels would require a very big system with a lot of hardware. Choose something in between...

Transistors are analog by nature, not digital.

Which transistor can you turn a little bit on? Mostly on? Almost all the way on?

PaulS:
Which transistor can you turn a little bit on? Mostly on? Almost all the way on?

Which not?

How can you explain opamps working based on digital-only transistors?

DrDiettrich:
The real problem sits at the effects side, which is not very clear right now. A single audio channel is not a problem, but 200 channels would require a very big system with a lot of hardware. Choose something in between...

There wouldn't be 200 channels running simultaneously. My idea is that a beam breaking stimulates playback, eg. turns up volume, modifies pitch etc. Maybe up to 4(?) channels playing back simulatenously, not more. If that's too demanding, even 2 or 1 channel would be fine. That should be doable computing power-wise, right?

Start with one audio channel and add more channels later. An (8 bit) Arduino can not play back recorded sound, except by an added mp3 player. One player per channel is not very handy, is it?

A RasPi may be a much better solution for that part of your project.

Did you already have a look at the Theremin organ, e.g. from the Arduino Starter Kit?