Maker Pro
Maker Pro

Cheapest way to get data from multiple(100s) of sensors?

I think I may have cracked this! At least, I have something that seems to be working.

I have 2 shift registers, neither of them are used to read input from the sensors. I have grounded all of the sensing LED's to each other, and run them all down a single Analog input on the Arduino.

The IR LED's are just always on.

One shift register just always has one bit flipped to 1, but is set in the code to cycle through all of them, always only having one on, with a 1ms delay between each change. After each bit gets flipped, I do an analogRead(0) on the one analog input coming from the sensor rail. Since the shift register will only have one sensor on at a time, doing the analogRead will only get info from the sensor that had power running through it. It's a bit brute force, but so far it can get readings from each of 3 sensors i have hooked up thus far, very fast.

The other shift register simply manages the LEDs in a more straightforward way. just writing to the register which LEDs need to be on. Later I will change this to PWM so the sensor distance can dictate the brightness.

Anyone see a problem with this setup? It really fits the "cheapest" part of my question since i already have some of these components to prototype with. Obviously, I am planning to scale this out to upwards of 400 sensors, anything that would make the same setup at that scale not possible?
 
If I understand you, your circuit looks like this:

upload_2016-6-26_13-33-11.png

If so, there is a problem. The AN input will see 399 resistors to ground and 1 to V+, making the max voltage seen on the AN intput at V+ / 400.

You might be able to make this work with a P channel MOSFET tying each R to V+ and the gate connected to the SR outputs. That way they will be high impedance or V+, giving you the full range output.

Bob
 
Here's my quick and dirty representation.
The left register is the simpler LED manager.

The right register manages the powering of the IR Sensors, which all pass through to the Arduino analog input.

Having only one of those flipped on reads the analog measurement for that sensor. Does this make sense?

circuit.jpg
 
Did you look at my diagram? The ones that are off have a resistor connected to ground. That is 399 resistors connected to ground and 1 connected to V+, which reduces your signal by a factor of 400.

Bob
 
Did you look at my diagram? The ones that are off have a resistor connected to ground. That is 399 resistors connected to ground and 1 connected to V+, which reduces your signal by a factor of 400.

Bob

Yes, but mine aren't using those resistors, would that make a difference? Or is the signal just ok now given i am testing with just three of them? I figured that if the other sensors had 0 voltage/current going through them, that they wouldn't even be considered in the overall measurement. In my diagram, there would be only one of the sensors on the right shorting to the analog input, as the others would all be open.
 
You cannot get an analog output from the sensor without the resistor. Show us how you have it wired.

Bob
 
Steve,
It looks like you did read post #18,but it hasn't quit "sank in".
I think it would be the way to go and recommend you re-read it.

A breif explanation:
Assuming each Led is driven by 10mA .
Driving all 400 LEDs all the time will require 400x0.01A=4A which is a waste of energy and a potential heat problem.
If you use a matrix only Sqrt(400)=20 LEDs are driven at a time = a total of 0.2A.
To drive that current a ULN2803(open collector Darlington driver) is used.
So,
You drive a column of 20 LEDs at a time(by a single bit!) and at the same time enable only those 20 LEDs "receivers" ,which are fed to the analog input (A/D) of the Arduino via an analog mux.
switching/scanning the analog mux will read all those receivers levels(scan all 20 elements on the row selected) .

Note:the resistors values are approximately equivalent to LED current=10mA and IR Trs("receiver") at 1ma.
Calibration by measurements may be needed.

If you have any questions let me know.

Here is how to connect:

507060519_403_1_.jpg
 
So with this setup, is it possible to potentially have all the LED's lit up at once? Sorry if I haven't been understanding what you've been saying. I need to brush up (a lot) on reading circuit diagrams. I don't want to just run with a circuit someone hands me. I want to understand it. That's the fun part, figuring things out.

That being said, I have another question:
ir_sensor.png
Is the light-bluish-clear one the IR Led and the black one the sensor? I can't seem to find clarity on this but it's likely important. Also, how can I tell which is the anode and cathode or collector and emitter of these? The pins are the same length.

I will buy some of those parts you mention and attempt to hook it up like you say, since i appear to be missing something in what I was up to.

I appreciate your guys' help on this one.
 
Couple more questions:
  • I want to be able to control the value of each LED separately, like an LED cube. Will this also be possible in the setup or do i have to run 20 at a time on or off?
  • Where does the shift register attach in your diagram? Right at the drive row lines that go all the way across horizontally?
 

Harald Kapp

Moderator
Moderator
Is the light-bluish-clear one the IR Led and the black one the sensor? I can't seem to find clarity on this but it's likely important. Also, how can I tell which is the anode and cathode or collector and emitter of these? The pins are the same length.
The best source for this information is the datasheet. The orientation of the part is indicated by the asymmetric form of the plastic case.
 
1. Is it is possible to light all LEDs at once,but I explained why you shouldn't do that (too much current).

2. The answer to the identification of the IR LED and sensor is found in the TCR5000 data sheet,
In general,you should never use any device without reading and understanding it's datasheet.
The outer color of the LED isn't important at all,what maters is what the datasheet says.

3. Same goes for pins length .
If you orient the device as shown ,everything is clear,
which is LED ,which is sensor,which is Anode/Cathode and Collector/Emitter

TCR5000.jpg

4. Yes,the shift register is attached at the Row Drive lines,
to activate only one row at a time you simply shift a single "1" through it.

5. Lighting the visible RGB LEDs is a different story all together.
In general a multiplexing scheme is possible and even more recommended,since you would have 3x400=1200 LEDs to drive).
Being able to drive each LED with variable current is more complicated (each element needs 3 "analog level" drives, not a single "digital level" one like in the IR led case).
You should need to define your requirements for that.

6. If you have questions about the IR-LED/sensor scheme ask till you fully understand it.;)
 
1. Is it is possible to light all LEDs at once,but I explained why you shouldn't do that (too much current).

2. The answer to the identification of the IR LED and sensor is found in the TCR5000 data sheet,
In general,you should never use any device without reading and understanding it's datasheet.
The outer color of the LED isn't important at all,what maters is what the datasheet says.

3. Same goes for pins length .
If you orient the device as shown ,everything is clear,
which is LED ,which is sensor,which is Anode/Cathode and Collector/Emitter

View attachment 27626

4. Yes,the shift register is attached at the Row Drive lines,
to activate only one row at a time you simply shift a single "1" through it.

5. Lighting the visible RGB LEDs is a different story all together.
In general a multiplexing scheme is possible and even more recommended,since you would have 3x400=1200 LEDs to drive).
Being able to drive each LED with variable current is more complicated (each element needs 3 "analog level" drives, not a single "digital level" one like in the IR led case).
You should need to define your requirements for that.

6. If you have questions about the IR-LED/sensor scheme ask till you fully understand it.;)

1. Sorry, I was asking about lighting all of the RGB LED's all at once, then realized you're matrix is referring to the IR LED's only.

2. I read the datasheet but I hadn't looked up the circuit diagram symbols. I haven't committed them to memory yet. I think I am all set there, but the LEDs DO spin inside the casing so for at least a couple of them it's going to be more difficult to know which is which on the wires.

3. ^^

4. Would I put another shift register across the column reads, in order to single out which column I am reading in order to get one sensor value?

5. For the variable colors in the LEDs, I was thinking I can use PWM for this, is that possible through the same shift registers I am using for the sensors? I was going to mess around with this library for the arduino as a possibility for this: http://www.elcojacobs.com/shiftpwm/

6. Again, thanks for hanging in there. It takes a while for some of these concepts to stick to my brain, but when they do, I never forget them.
 
You are going to need analog multiplexers to read the sensors. You cannot simply turn one of them on and wire them together for the reasons I have already stated.

Bob
 
You are going to need analog multiplexers to read the sensors. You cannot simply turn one of them on and wire them together for the reasons I have already stated.

Bob
So from @dorke 's diagram, you are saying I would need a different Shift Register IC to read the analog values from those sensors? I shouldn't need a different shift register for the drive rows, since that's just power on/off for the row. Can you recommend an analog multiplexer IC for this purpose?
 
So from @dorke 's diagram, you are saying I would need a different Shift Register IC to read the analog values from those sensors? I shouldn't need a different shift register for the drive rows, since that's just power on/off for the row. Can you recommend an analog multiplexer IC for this purpose?

Look at post #18 it explains how to read the columns with MUXs .

You need 5 control bits to select from the 20 columns (can be done with a shift register or directly).

For the 8 --> 1 you can use the CD4051B or similar.
For the 4 --> 1 you can use the CD4053B or similar.
 
Multiplexers come in 8x1 typically, which means they can select 1 out of 8 analog inputs and send it to the output. Three inputs are used to tell it which one is selected.

So you would have 50 chips to connect the 400 sensors, giving you 50 outputs.

Then you would have 7 chips to select one of the 50 outputs from the first set, giving you 7 outputs.

And finally, there would be 1 chip to select one of the 7 from the second tier.

But there is a way you could do it with your shift register idea and a MOSFET for each sensor as well. The circuit would look like this, (with 400 in place of the 3 shown here.)

upload_2016-6-29_16-48-14.png

D1, Q1 is the first reflective sensor + LED D2, Q2 the second etc.

M1... will connect ground for each of these. The gate is driven by 1 of the bits out of a 400 bit shift register. Notice that it will enable both the LED and the sensor at the same time! Only one of the 400 should be on at any given time. This allows you to use 1 resistor for all the sensors and 1 for all the LEDs.


Bob
 
@dorke So post #18 has "sunk in" a lot more now.

Couple questions:
Will one ULN2803 run the load for up to 8 of the rows? Or is it one per row?

What types of circuit protections/diodes and or capacitor smoothing would you add to this if any?
 
A single ULN2803 is an 8 bit driver,you can drive 8 rows with one device.
for 20 rows 3 ULN2803s are needed.
No need for circuit protection.
Capacitors may be added on the 5v to GND line.
Say a 22uF/10V tantalum + a 0.1uF ceramic one at each Row,
but it is not absolutely needed.
I would try it out first with a small matrix,say 2x2 or 3x3.then enlarge it.
 
Last edited:
Top