Project doubt - Page 1
Forum section: electronics / beginners

author: DanielCL
author_rank: Newbie
timestamp: December 09, 2013, 05:16:36 pm
content: Hello EverybodyI'm new at this forum and I have a project development doubt. I'm using 42 photo resistors to receive light and if the light is below a reference value i will receive on an Arduino Uno a bit with a value of zero, if is above a reference value the Arduino Uno will receive a bit with value one. To do this a use a simple voltage comparator (0 or 5V output). The problem is receiving 42 signal.I thought about using some multiplexers, the comparators and 2, connected in series, parallel to serial shift register. With this I can receive 16 values with the multiplexers, then they will go to the comparator to put in zero or one, then to the shift register and finally to the Arduino where it will receive a 16 bit word.. When this is done, goes to the next 16 signal until all 42 signals are reed.The main goal with so many IC is to reduce the cost of the project.The question is: Am I doing it right or there is some easier and cheapest way to do this? If it was only 4 or 5 signal I could use the analog input on the Arduino and then to the programming, but it's 42 signals. About the Arduino Uno, I'm just using this uC because is the one I have available with me for now.Can I have some helpThanks very much

author: c4757p
author_rank: Super Contributor
timestamp: December 09, 2013, 05:22:46 pm
content: 6x 74HC4051 to mux the signals plus a seventh to mux the muxes. Six bits to select (bus together the first six muxes) then one comparator (you can use the one in the AVR, or the ADC for a variable threshold)

author: DanielCL
author_rank: Newbie
timestamp: December 09, 2013, 05:27:20 pm
content: Sorry, this may be a dumb question. How can I bus the 6 bits together?

author: c4757p
author_rank: Super Contributor
timestamp: December 09, 2013, 05:30:33 pm
content: Each 4051 has three digital inputs. The first six muxes should all share their bits, and then the seventh is separate. That way you select "second input of the primary muxes, fourth mux" for example.I could explain better with a sketch but I am on my phone... Maybe if you still don't get it someone else could jump in with a sketch (please?)Edit: OK, I did it. Sorry for the quality...

author: zapta
author_rank: Super Contributor
timestamp: December 09, 2013, 06:07:05 pm
content: Quote from: c4757p on December 09, 2013, 05:30:33 pmWhat will be connected to each of the 42 inputs, a photo cell + resistor? Is there a way to share the resistors somehow (e.g. switching the cells, not the voltage tap).BTW, using the MCU's ADC instead of an external comparator will allow to calibrate in software each of the cells, in case they have variations.

author: SeanB
author_rank: Super Contributor
timestamp: December 09, 2013, 06:39:01 pm
content: You can have a single resistor at the ADC input, but remember that then you will have an added resistance to the CDS cell, so it will be less accurate at high light levels ( lower resistance in bright light), but your calibration will take care of that, and it will only really be a problem in direct sunlight where the cell resistance is around the same as that of the switches and appear as a slight offset.

author: sacherjj
author_rank: Frequent Contributor
timestamp: December 09, 2013, 06:44:57 pm
content: Quote from: zapta on December 09, 2013, 06:07:05 pmResistors are cheap. The advantage of using a photo cell/resistor voltage divider prior to the Mux is that the on resistance of the mux stages (~120 ohm) is less of a factor, because the current through the divider network to the sampling is much less than through the divider. The importance of this is determined by the resistance range of the photo resistor.I agree that using MCU's ADC has some advantages.

author: DanielCL
author_rank: Newbie
timestamp: December 09, 2013, 06:56:48 pm
content: By the way, thank you very much for the help. You guys are awesome.There is no problem with sun light because the photo resistors will be in a box and only will receive red light from LEDs when the box is closed and each individual signal is important.In my first post I was thinking about using 4052 and 4053 mux, and a parallel to serial shfit register (4021 maybe), 2 of them to be a 16 bit word, so a can "read" all the 42 photo resistors in 4 times, i think.But looking to the schematic made by c4757p, i think that will be fast to. About the ADC from the uC, it's an option. I say option because I may use the analog input from the Arduino for something else ( my project isn't very well determined ). But i will consider that option.When I have the ciruit completed, I will post it here the schematic for you to comment.Thank's for the help

author: SeanB
author_rank: Super Contributor
timestamp: December 09, 2013, 07:10:36 pm
content: If the light is from a LED then it is unlikely the CDS cell will go much below 10k resistance, when the switch will add about 0.2% of error, much less than the 20% tolerance or the individual cells.

author: DanielCL
author_rank: Newbie
timestamp: December 09, 2013, 07:32:14 pm
content: I want to eliminate as much as I can "parasite" light, the only light that will be there is red and the box will be all black. I think the error will minimal.I will have, too, some pots to control the intensity of the red leds so the variation of the value of the photo resistor will be the best that I can get from them.This project is to build a exposure box with some object detection, therefore the photo-resistors. It's a very archaic way to do it but, i think is the cheapest. In the first stage only measure the length of the object( x axis), in the future I will try to measure the width of the object too. Since the hardware is already there, i just have to put some code. This will have a stepper motor too, to move the photo resistors in the x axis.

author: sacherjj
author_rank: Frequent Contributor
timestamp: December 09, 2013, 07:58:13 pm
content: Ambient light will be an issue if it gets in. The typical way around this is modulated driver and demodulated detector. This is how IR remotes typically work. 40khz carrier, with a slower data signal. Then a high pass filter eliminates the "DC" bias caused by ambient light.If you wanted to go this route, you can just drive all LEDs at a certain frequency. Assuming they are far enough away that the photo resistors are not influenced by another channel's emitter, this would let you see changes in photo resistor values to indicate clear path.In a break environment, you would see no change for output toggles. Make would show changes, regardless of ambient light (up to the point where ambient light is saturating your photo resistor and LED doesn't affect the levels). This would not require calibration and make detection more robust.

author: dr.diesel
author_rank: Super Contributor
timestamp: December 09, 2013, 08:07:50 pm
content: Quote from: c4757p on December 09, 2013, 05:30:33 pmIn the car, AWESOME!What song was Track 5?

author: Maxlor
author_rank: Frequent Contributor
timestamp: December 09, 2013, 09:36:50 pm
content: Instead of using half a dozen MUX chips, maybe use a microcontroller with a lot of ADC channels? The ATTiny828 has a whopping 28 channels. Two of those would be cheaper, smaller and less complex than all those MUXes.

author: c4757p
author_rank: Super Contributor
timestamp: December 09, 2013, 10:09:19 pm
content: Quote from: dr.diesel on December 09, 2013, 08:07:50 pmI got to school early, so I had time to kill but no real place to go. I get surprisingly many things done in the parking lot.Hmm. I want to say A Lot Like Me by The Offspring but I'm not 100% sure what was in there anymore. IIRC it had been muted for a while.Quote from: Maxlor on December 09, 2013, 09:36:50 pmThat is a good idea. Might be more complex to manage overall for someone with less MCU experience than a single peripheral circuit operating off one, but it would certainly be cheaper.

author: DanielCL
author_rank: Newbie
timestamp: December 11, 2013, 01:20:55 am
content: I think I will go for the hardware approach, don't like very much to programAnd the IC aren't very expensive, around 0,35€ each. But I'm always open for opinions

author: Dave
author_rank: Super Contributor
timestamp: December 11, 2013, 03:02:53 am
content: Quote from: DanielCL on December 11, 2013, 01:20:55 amProgramming doesn't get much easier than Arduino. It might seem frightening at first, but the best way to get rid of that feeling is to dive right into it.It's really not that difficult once you get the feel of it.

author: sacherjj
author_rank: Frequent Contributor
timestamp: December 13, 2013, 03:48:10 pm
content: If you go with two Tiny MCUs, I would make two identical ADC circuits and a simple serial interface to a third MCU, or I2C interface. Serial allows you to debug half the ADC chain and then once working, duplicate it. Then just implement the sensors to whatever interface.But doing the muxing in hard ware is simpler to make happen.

author: tszaboo
author_rank: Super Contributor
timestamp: December 13, 2013, 04:11:29 pm
content: You need 6 8:1 analog multiplexer. connect them in a logical way, to recieve 7 signals with each. Connect each output to a comparator. make a R-2R resistor ladder with the outputs, and connect it to analog in. This way you only have 4 signals. 3 to set the mux, 1 analog in. program is simple, increase a counter, reset if 7 , read ADC, use only first 6 bits, repeat.