I am slowly getting furstrated (again) by a problem. I have two laser emitters and two light sensors (LDR). Both light sensors are connedted the usual way (as shown in every arduino example). The only difference is that they are connected to digital pins 2 and 3 and I have falling interrupts configured for them. And after some testing I figured out that the sensors are randomly triggered by something. Most of the time my error handling code deals with them but sometimes it doesn't.
So here is the core of the problem. I figured out that the interferance is not random. If you plug in some electrical equipment (hair dryer, phone charger, turn on the light ...) anywhere in the house, both sensors get triggered. I tryed connecting the whole thing to a battery but it didn't help. Both sensors are connected to arduino via a m long UTP cable (actualy just one pair). The same goes for the laser emitters and +/- for the sensors. How can I get rid of this interferance?
Don't put analogue signals into a digital input, that is simply asking for trouble. You need to have a Schmitt trigger between the analogue signal and the digital input. It needs to have enough hysteresis so as not to oscillate and be very sensitive to pick up when the sensor output is close to the threshold.
I managed to lower the interferance by little. I put aluminum foil around the wire and connected it to the ground. Now it only reacts to changes in the room where it is. Thanks for the link about the decoupling.
The second point looks even more interesting. Because I have great deal of problems detecting the change when it is sunny outside. But I can't connect the whole thing to the analog input because I can't have interrupts on analog pins.
No secret stuff. I am actualy moving back to my old idea of a smart room/house. This system is part of "people counter". I want to count when someone gets in the room and when someone gets out. I have two laser emitters and a LDR and I simply check which of the sensors was triggered first. And I am getting stuck at the same point as before. A year ago (I think) i had an IR based system - I was using IR emitter and an IR diode. The whole thing worked quite nice with artifical light or when it was cloudy but sunlight was a no-go. And when I was ordering from dealextreme a few months ago I also bought cheap (2$) 5mW laser emitters. And the system is better than IR. But when it is realy sunny thw whole thing stops working too. So I have actualy two interferance problems - the first one being random triggering - almost solved by shielding the cable and error correcting code. And the other one actualy being sunlight which I can't figure out how to block.
I think that they are quite similar to the one you gave me.
I am currenty using lasers and I don't think that I'll be switching back to IR at any time soon. So I need something that would work with lasers.
I put black tube around the LDRs before I even tested them for the first time. While it does help, it still isn't enough. I also put a few layers of a special paper that is semi transparent. This improved the whole thing even better. But it still isn't enough. I will test the LDR on a analog pin tommorow to see how the values change when there is sunlight present. But I think that the voltage doesn't drop enough so that the interrupt isn't triggered.
Well I said it a little strange. Of course you can modulate lasers but how about modulating them in my system? It proabably wouldn't work because LDR still picks up the sunlight - and sice the lasers are low power, the LDR wouldn't pick the changes.
IR is a little different thing than the laser. You can make a simple IR passtrough (I think I spelled it wrong) filter from an old floppy disk. So you only get IR light on the sensor.
After a little more thinking I think that this could actualy work. But how to actualy do something like this? I need some example code on how to actualy modulate the laser and and read those modulated signals. Modulating the whole thing isn't hard but actualy reading those signals and figuring out if the signal was interuppted sounds like a very hard thing to do.
I know that you are suggesting I use one of those IR recievers and an IR diode. Which would probably work but since I don't have any of them I can't use them. The electronic store around here doesn't have them and I won't be ordering supplies from farnell for a few months.
So because of that I want to use the parts I do have. And those parts are laser modules and LDRs. These LDRs to be exact:
If I wanted to use IR, I can use some basic IR diodes or the vishay TSOP modules I linked a few posts before.
I think I posted a link to my lasers somewhere in this topic. It is a red visible laser (I think it is a laser diode). The distance isn't a problem - a little more than a m. I tryed lasers simply because I had them and I thought that it would solve my enviroment problems.
So you are saying that I can use my TSOP recievers? If this is possible then I could do that without any problems. But then we get back to the problem with modulating the IR emittersd with some HW I can find around. Possibly with the arduino itself?
I missed it. And yes I forgot tu put the link to the lasers.
What is this schematic called? I think that it resembles a schematic we did back in school - astable multivibrator if I am correct? If I am correct - what is the target frequency, so I can calculate the resistor and capacitor values? I think that there is a IC that has the same functions? I have a CD4060 and if I remember it could be used in application such as this.
For IR LEDs I would proabably use something like this since I have too much of them lying somewhere:
Hmmm you got me confused. The schematic above shows astable multivibrator. But you said bistable in your last post which is actualy not a oscillator but a flip-flop).
And if I am correct and it is astable multivibrator - I can proabably do it with 4011 (operational amplifier if I am correct). At least I have a schematic that shows it. If I go with the transistors - I need a formula to calculate the needed R and C values. Since I can't find them around my old papers. Also - how accurate must these resistor/capacitor values be?
Where did I get operational amplifier is beyond me. Proabably since I have too many papers in one folder and somehow got it in my head.
I think I will go with 4011 method. Because it is simple and with my schematic I only need 1 resistor and one capacitor - the same schematic as the first one but without 1Mohm resistor.
I bought my resistors/capacitors today and built my astable multivibrator. I think that it is working (judging by the IR LED lighting up ). But if I put this in front of my IR reciever I get nothing. Values stay at 0 (digital read the sensor). Do I need some more timing code?
I have a 22nF capacitor and by my calculations around 1.2k-ohm resistor. I tryed replacing the resitor with a 6k ohm potentiometer but couldn't get anything else than 0 from the reciever. I also tryed with 6k-ohm potentiometer and 1k-ohm resistor in parallel and another 1k-ohm resistor in series with that.
I spent a little more time with this but I can't get anywhere. Getting the right frequency isn't the easysest task. Would it be possible to generate the correct frequency with arduino but still leave it usable to do something else - like read the sensor? I know that arduino can generate the needed signal (IR remote libraries do it) but would it be possible to do it constantly and still be able to do something else the rest of the time.
EDIT: just had a strange idea - Tone function. It is used to create sonunds by inputing the desired frequency. Can it be used to control the IR diode?
I get ones until I put a hand in fron of the reciever - then I get 0 and it stays at 0 until I remove the hand and put it in front again. Which is actualy good.
Today I created a new PCB and mounted the components. And while the sensors do work I get to the good old IR problem. IR light isn't a point like a laser. So sometimes left sensor detects right IR diode and right sensor sometimes detects left laser diode. And because of that I get results that are unusable. I placed rubber tube around both recievers/emitters but the problem doesn't go away.