Last minute problem needs expert help, or maybe a microswitch

Got the circuit working yesterday, and here's the demo.

 

A problem

 

One problem, as the energy in the pull-string charger ekes away, the comparator circuit goes into confused mode, and the buzzer ALWAYS sounds, whichever LDR is covered. I don't know why this is, but I need to make some kind of change so that the default behaviour when the comparator logic dies is silence rather than a kind of death gurgle.

I worked out who JC, the uberguesser, was yesterday, (I should have known). He's a curiosity collective member. A half hour later, coincidentally he mailed me with a bunch of very useful suggestions on the circuit design. JC is a genuine electronics engineer, which could be very handy at this stage in proceedings.

Circuit Design

Been playing with Fritzing so that I can send JC the details of my problem. This is what the circuit looks like on the breadboard - mentally replace the battery pack with the pull-cord charger.

Breadboard diagram for #project5 created with Fritzing

This is the schematic, although it took a lot of messing with Fritzing to get it not to 'autoroute' the circuit so that it was unreadable.

Schematic for #project5 created with Fritzing

For completeness, the Fritzing project file is here. You can download the open source program Fritzing here.

Functional Principle

The basic design is to use two voltage dividers, one with fixed resistors, and one with resistors which are affected by light. Each voltage divider shares the total voltage across two resistances. You can measure the voltage in the middle of the resistances to see what share was given to each one. Voltages are shared in proportion to the resistances, so measuring the voltage share is a way of comparing the resistances.

One voltage divider has fixed resistances (and provides a reference voltage in the middle). The resistances were chosen so that the reference voltage is just a bit more than half (in the schematic, R1 is large and R2 is small). The other has variable resistances affected by the light falling on its two Light-Dependent Resistors (LDRs). If the light falling is exactly equal, the resistances should be equal, and you would expect the voltage share to be equal. The voltage in the middle will then be half of the supply voltage. If the light falling on one LDR is less, then its resistance increases, and the share of the voltage which it takes will be more. You should then find that the voltage in the middle is significantly more than half of the supply voltage (and exceeds the reference voltage).

A comparator is used to measure which voltage divider has a higher voltage. The upshot of this is that the comparator turns on when one LDR is covered (and pushes the voltage significantly away from a half share) and turns off when they are more or less equal. When one LDR is covered, this sounds the alarm.

The reason for having two LDRs is that one uncovered LDR gives a measure of the ambient light, so that it's possible to tell when the other has been covered, versus the whole room just being darkened (yes this will be deployed in a room!).

It's actually just as easy to do this whole project with just a microswitch, a buzzer and a pull-cord charger, but it'd not be as elegant a design, since the installer would have to position the microswitch in a way which is mechanically sound, whilst the LDRs could just hang down from their mounting point.



Follow developments in real time through the enigmaker twitter feed