Multiplex IR LED's?

Can we do the same technique used in say this: - YouTube, but instead with IR emitters and detectors?

Well the title of the post is a bit wrong if you want to multiplex detectors. The principle is the same but the circuit is different. And you will only look at one detector at a time, so it will be no good for IR data like from a remote.

Grumpy_Mike:
Well the title of the post is a bit wrong if you want to multiplex detectors. The principle is the same but the circuit is different. And you will only look at one detector at a time, so it will be no good for IR data like from a remote.

Thats fine :), Im just looking to detect IR light emitting from the emitters not any data. Also could you please show me an example, it would be much appreciated :)?

This is an example of multiplexing many analogue inputs into the arduino:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html

Grumpy_Mike:
This is an example of multiplexing many analogue inputs into the arduino:-
MIDI Footsteps

Ok after reading that page I think I understand what to do, but am still confused. So I have questions regarding that:

  • Are you suggesting I use a 4051 and loop through all the sensor readings? After reading this: Arduino Playground - 4051 I feel it is probably a good idea
  • I never even new these extenders existed until now, so looking back on this: http://arduino.cc/forum/index.php/topic,98317.0.html Would it be suitable to use 2 4051's to control an 8x8 matrix of LED's or maybe even 2 4067's and I could have a 8x12 Matrix? :stuck_out_tongue:
  • Would these be suitable or fast enough to switch (I know the photodiodes probably dont but the LED's from the prev question do), I really dont know how to read the datasheet :frowning:
  • To my understanding, all I need to control these are 3 pins on the 4051s and 4 on the 4067s?
  • In your footsteps example, You have 3 pins on the 4051 going to ground, and 1 to the analog input, If I were to not use it as an input and rather an output, how would I do it? I have searched it and only found examples with confusing diagrams
  • I havnt been able to find many 4067s are there any other 16 channel multiplexers that are similar
  • If I have 3 4067s for a 8x12 matrix of LED's and 1 row of 12 photodiodes and 4 blank inputs reading on 1 input to the arduino, that uses 1 Analog in and only 12 Digital Pins right?
  • Last but not least, How do I incorporate the emitters then? Do I just hook them up in parralel with the arduino to the 12v adapter (making sure I lower their voltages) and then control them with a transistor or a simple relay to turn them on and off so theres no power wasted?

I also found this which is helpful if anyone else is reading this that has the same low knowledge as me :stuck_out_tongue: http://colab.lcc.gatech.edu/wp-content/uploads/2012/04/Analog-Mux-4051.pdf

You are the best and a genius if you can even answer one of these questions :wink:
Also That is a great link btw it is very helpful it opened me up to so many possiblities, Thankyou so much grumpy_mike XD XD XD XD XD XD XD XD XD XD

Are you suggesting I use a 4051 and loop through all the sensor readings?

Yes I think it will be the simplest option. You can cascade 4051s to get as many inputs as you like therefore you will need one 4051 for every 8 sensors.

Would these be suitable or fast enough to switch

Yes providing you are getting a good signal from the IR sensors. There is an associated serial resistance with the path through this device, this is different for different manufacturers so check the data sheet.

To my understanding, all I need to control these are 3 pins on the 4051s

The 3 pins select which one of the 8 wires is connected to the one wire. You can't say input and output because the is bidirectional it is just like a multiway switch controlled by the 3 select lines.

If I were to not use it as an input and rather an output, how would I do it?

See above the input is the output.

I havnt been able to find many 4067s are there any other 16 channel multiplexers that are similar

No in simple electronics like this the package size is the thing that determines the cost. As it is easy to use two 4051s these are mainly used in place of bigger multiplexers because of cost.
So far I have been talking about just expanding the inputs with a 4051.

You asked about a matrix, this is a bit more unusual. In fact I have never made a matrix of sensors.

If I have 3 4067s for a 8x12 matrix of LED's and 1 row of 12 photodiodes and 4 blank inputs reading on 1 input to the arduino,

Sorry I don't understand this, can you draw something. Look at Arduino Workshop to see how a matrix should be wired.

I have drawn up what I would try if I were to make a matrix of sensors but this is only my starting point and I must stress I have not made such a device so I don't know if it will work. It is attached.

Sensor Matrix.pdf (22.8 KB)

Grumpy_Mike:

Are you suggesting I use a 4051 and loop through all the sensor readings?

Yes I think it will be the simplest option. You can cascade 4051s to get as many inputs as you like therefore you will need one 4051 for every 8 sensors.

Would these be suitable or fast enough to switch

Yes providing you are getting a good signal from the IR sensors. There is an associated serial resistance with the path through this device, this is different for different manufacturers so check the data sheet.

To my understanding, all I need to control these are 3 pins on the 4051s

The 3 pins select which one of the 8 wires is connected to the one wire. You can't say input and output because the is bidirectional it is just like a multiway switch controlled by the 3 select lines.

If I were to not use it as an input and rather an output, how would I do it?

See above the input is the output.

I havnt been able to find many 4067s are there any other 16 channel multiplexers that are similar

No in simple electronics like this the package size is the thing that determines the cost. As it is easy to use two 4051s these are mainly used in place of bigger multiplexers because of cost.
So far I have been talking about just expanding the inputs with a 4051.

You asked about a matrix, this is a bit more unusual. In fact I have never made a matrix of sensors.

If I have 3 4067s for a 8x12 matrix of LED's and 1 row of 12 photodiodes and 4 blank inputs reading on 1 input to the arduino,

Sorry I don't understand this, can you draw something. Look at Arduino Workshop to see how a matrix should be wired.

I have drawn up what I would try if I were to make a matrix of sensors but this is only my starting point and I must stress I have not made such a device so I don't know if it will work. It is attached.

You are a legend, thankyou :slight_smile: I am getting real close to understanding what to do now :slight_smile:

This is the part I will be using, http://jaycar.com.au/productView.asp?ID=ZC4051&form=CAT2&SUBCATID=972#1 its a 4051 and I have drawn up a diagram to show an example of what I understand I can do with these :slight_smile:

To use this example, if I am correct, I would iterate through the inputs of the of the photodiodes that are connected to a 4051 to get the values which will be at A0, then to turn on my normal LED's, I will select the pins on the 4051 to turn on using the pins 1,2,3 and 5,6,7 on the arduino, then they will allow for the current to flow through the pins from 4 to 8. Allowing for 64 LEDs and 2 less pins used on the arduino than before.

P.S: Red means output and blue means input on arduino in diagram

Is this what you mean I should do? :slight_smile:

Close but not quite right. It is not what I sent you but you could try it like that.

There is no need to connect the top 4051 to an arduino output, just connect that directly to +5V.
The next one down can go to an arduino input but you will need a pull down resistor on that input and you would be best connecting it to an analogue input.

I am not sure what the bottom 4051 is doing, are those LEDs or sensors. If they are sensors then that is the other way to use the 4051. If they are LEDs then no.

Grumpy_Mike:
Close but not quite right. It is not what I sent you but you could try it like that.

There is no need to connect the top 4051 to an arduino output, just connect that directly to +5V.
The next one down can go to an arduino input but you will need a pull down resistor on that input and you would be best connecting it to an analogue input.

Im sorry, I dont understand what you mean, I have never used pull down resistors before and I dont understand what connecting the top 4051 to 5V does when used with a pulldown resistor?
What is the pulldown resistor for? Do I connect it to a button to switch the cuircut on and off or something?
Anyway, are these the modifications you mean?

Grumpy_Mike:
I am not sure what the bottom 4051 is doing, are those LEDs or sensors. If they are sensors then that is the other way to use the 4051. If they are LEDs then no.

Yes it is the sensors, sorry for my bad diagram, I had a free period at school and took the oppurtunity using paint :stuck_out_tongue:

Thanks again mikey :slight_smile:

You need to remove that switch and connect the pull down and pin 3 and the analogue input together.
Yes that is right with the 5V. The 4051 will supply 5V only to the row of sensors you have selected, the other rows will not be connected to anything and so will be floating.

I am not sure you have shown the sensors wired up the right way round, as you have it they look like LEDs which they are not.

Grumpy_Mike:
You need to remove that switch and connect the pull down and pin 3 and the analogue input together.

Why do we do this, wont the LED's be on all the time? I think im misunderstanding the use of this :stuck_out_tongue:

Grumpy_Mike:
Yes that is right with the 5V. The 4051 will supply 5V only to the row of sensors you have selected, the other rows will not be connected to anything and so will be floating.

It should only power 1 Led at a time though correct?

Grumpy_Mike:
I am not sure you have shown the sensors wired up the right way round, as you have it they look like LEDs which they are not.

Oh ok, I thought thats how you wire up photodiodes? I heard something about reverse voltage but I dont understand it, is it just placing it backwards?

Also I almost forgot how do I wire up the IR Emitters?

Thanks again mike :slight_smile:

Almost forgot :stuck_out_tongue:

bump

Yes that looks right.

wont the LED's be on all the time?

What LED? They are all sensors.

Also I almost forgot how do I wire up the IR Emitters?

Do you need to controll them? If not wire them up through a resistor to the power and ground.

Grumpy_Mike:
What LED? They are all sensors.

The top ones are supposed to be LED's and the bottom ones are sensors so that I can have a matrix of LED's lighting up when the sensors detect ir light(sorry for the confusion)

Grumpy_Mike:
Do you need to controll them? If not wire them up through a resistor to the power and ground.

I dont think I need to controll them, they can stay on the whole time the systems on and wont blow up will they? Also does that mean I should wire them parralel to the arduino and then parralel to each other or connect it to the arduino's ground and power (I dont think its this one im just checking :P)

Thanks Mike :slight_smile:

The top ones are supposed to be LED's and the bottom ones are sensors so that I can have a matrix of LED's lighting up when the sensors detect ir light

In that case scrap that circuit it will not work for LEDs.
Read:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
For basic information about a matrix.

Grumpy_Mike:

The top ones are supposed to be LED's and the bottom ones are sensors so that I can have a matrix of LED's lighting up when the sensors detect ir light

In that case scrap that circuit it will not work for LEDs.
Read:-
Arduino Workshop
For basic information about a matrix.

Why wouldnt it? Cant I just rapidly iterate through each of the leds and turn them on

Cant I just rapidly iterate through each of the leds and turn them on

Not really the refresh rate and the on / off ratio would be rubbish. With an on off ratio of 64 : 1 the LEDs would be too dim. The 4051 has too much internal resistance to compensate for this by boosting the current and all the current has to come from the arduino pins. So while it would function it would be rubbish.

Grumpy_Mike:

Cant I just rapidly iterate through each of the leds and turn them on

Not really the refresh rate and the on / off ratio would be rubbish. With an on off ratio of 64 : 1 the LEDs would be too dim. The 4051 has too much internal resistance to compensate for this by boosting the current and all the current has to come from the arduino pins. So while it would function it would be rubbish.

Ahh I see

So instead of using the 4051 you suggest I use something from the 74LS series or use a shift register?
After reading your article thoroughly it seems the 74LS seems like you choice you suggest, but you also mention shift registers, and since I'm looking to reduce the output pins as much as I can, that looks like a better Idea as your article says I only need 3 pins which is amazing, I have to go to school now but I have one question before I go :stuck_out_tongue:
Do shift registers take inputs or should I just use the 4051 for the inputs since the sensors dont need to refresh as fast as the LED's, or even, should I use a 74LS series incase?

Do shift registers take inputs

There are shift registers that output parallel data from a serial input and other types that output serial data from parallel inputs.
But these are digital inputs, for your sensors you need an analogue input so go with the 4051.