Electronics > Projects, Designs, and Technical Stuff
Borderlands style jewelry box research thread
Youkai:
Ok I read the description on the Reflective IR sensor Ian.M posted. So in that case I would mount it on the inside and when the lid was directly in front of the sensor it would see the reflection and get an "On" signal. Then when the lid cleared away leaving a gap of larger than 10mm it would be "off"?
My concern here is that I would have to have one of these sensors pointing up to see when the purple drawers from my diagrams cover them. Wouldn't that sensor be severely prone to sensing other sources of IR radiation (Incandescent bulbs, the sun through a window, etc) which would make it impossible to tell when I was getting the IR reflection and when I was getting some other IR source? I don't know if RGB LED produce any noticeable amount of IR light but it would be pointing straight at the LED inside the lid when the chest is open. Is this something Ian.M covered with his AC modulation talk? That kind of went over my head.
Ian.M:
I mostly covered the false signal issue. There are a couple of things I didn't mention like the brightness of the IR LED - it will typically be pretty bright relative to most ambient sources so unless the phototransistor is pointed at the sun, or is right under a halogen spotlight or a large fire in an open fireplace occupies its field of view, the LED illumination should be stronger. Good quality sensors have optical filters to pass only IR, so non-incandescent lighting typically doesn't effect them much. They can still be fooled by direct sunlight, intense heat sources, IR remote controls and camera flashes that use flash tubes.
Also, you'd typically have a highly reflective surface e.g aluminum foil tape where you want it detected, and matte black or nothing in range where you don't want detection to get a good contrast ratio.
On the modulation side of things, assuming an analog output sensor, if you PWM the LED with 50% duty cycle and sample the sensor twice within the PWM period, near the end of the on time and near the end of the off time, then the difference must be either due to the additional illumination of the LED or due to rapid fluctuations in the ambient light level, which if you average over a few PWM cycles, will cancel out.
Unfortunately an AVR based Arduino has an max. ADC sample rate of 9.615KHz (hardware limit base on clock speed) and in practice you'll be lucky to get close to half that unless you program in assembler, so that strategy isn't viable if you need to get the modulation frequency well above the likely range of LED lighting PWM frequencies. An alternative would be to do it in hardware with a synchronous detector driven by the same PWM as the LED. Another alternative would be simply be to leave the LED on until you detect something then toggle the LED on and off a few times and check the detected signal follows the LED.
However the smartest way to handle it is to put the sensor where its least likely to be affected by ambient light. Assuming your servos are in the base, simply get a narrow slot photo-interrupter
e.g: https://www.jameco.com/z/H21A3-Major-Brands-Photointerrupter-Transmissive-3-3mm-Phototransistor-4-Pin-Rail_320901.html
and have a vane or flag somewhere on the servo shaft, horn or linkage that moves through the slot. Because of the narrow slot and opaque body, its shielded against indirect ambient light, and if mounted in the base with an opaque cover over the mechanism, there wont be much ambient light anyway, so it shouldn't need modulation. Caution: many black plastics and paints are *NOT* opaque to I.R. Test before you build the mechanism!
Another option for sensors in the base would be 2mm dia subminiature Neodymium magnets in holes drilled in the moving parts and hall effect sensors. e.g.: https://www.adafruit.com/product/158
You probably wouldn't want to use them up in the lid or tray due to the risk of a magnetic clasp or other fastener on an item of jewellery ending up close enough to the sensor to 'jam' it, and you might even need a soft iron sheet between the mechanism and the box bottom for magnetic shielding.
Back to the CdS photoresistor (LDR) - there is no substitute for getting a couple and experimenting. Also get a can of freezer spray so you can easily chill it. If you mount it recessed in a small block of aluminum (drill a hole, then drill two tiny holes from the other side for its leads, which will need to be sleeved with insulation, and also drill another separate hole for the tip of a thermocouple. Use a little thermal grease on the back of the photocell and on the thermistor), you can easily characterise how its resistance varies with temperature.
If you want to look at its time response, hook it up with a 9V battery for bias and a 10K series resistor to a scope then shine a flashing LED at it, or put a disk with two 90 deg segments cut out (leaving a bow-tie shape) on a motor shaft and spin it just in front of the cell to interrupt the light to it.
Another issue with CdS LDRs is ageing. Typically the dark resistance decreases and the light resistance may also increase. Factors that may contribute to accelerated ageing may include UV, moisture and elevated temperatures. An order of magnitude reduction of sensitivity due to ageing is possible though generally the LDR will have been replaced as failed before it gets that bad.
Another quirk of CdS LDRs is their sensitivity to static charge. This isn't normally an issue if you use the type that has a clear plastic cover over the cell with an airgap, and avoid idiocies like dry polishing it with a silk cloth, but if you use the bare cell type that only has a thin plastic film over the CdS surface, one can get a significant resistance chance with only a modest charge buildup. See http://sparkbangbuzz.com/cds-fet/cds-fet.htm for this effect exploited to turn a CdS cell into a crude MOSFET equivalent.
Youkai:
Ok I like the narrow slot photo-interrupter idea. That seems like it's the same concept as what I was thinking but much more resistant to external interference. I'll order a couple of those and do some testing.
Youkai:
I'm getting ready to solder some wires onto my h21a3 phototransistor. Wanted to do some double checking to make sure I don't do anything stupid.
The data sheet (http://www.robotstorehk.com/h21a1.pdf) says the emitter has a max forward voltage of 1.7v and a current of 60mA. So with my 5v power source I need a 55ohm or greater resistor. The next standard resistor is 56ohms. I don't know if I have that one but I do have a pack of various resistors. So I should pick the smallest one I have that is > 55ohm correct?
I'm pretty sure it doesn't matter but just to triple check it doesn't matter if the resistor is on the cathode or the anode correct?
What about for the sensor? I don't see a max voltage in the data sheet. I don't think transistors need them really right? So just two wires off those terminals is fine?
Ian.M:
You don't want to push the max If limit if you want long term reliability and the datasheet you linked has 50mA max continuous If, not the 60mA you quoted.
Most of the datasheet specs are given with emitter LED If of 20mA or 30mA, so I'd use a 120R series resistor for a bit under 30mA If. If you need to save power you could go even higher resistance *IF* you use a large enough load resistor for the detector - the datasheet quotes 0.15mA Ic min. for If=5mA, which would be adequate to pull low against a 10K pullup. To get about 5mA If, a 680R series resistor should be satisfactory.
On the sensor side of things its a NPN transistor used as a switch so its emitter (pin 4) must be negative of its collector (pin 3). Its max current is limited by the If of the emitter LED - see datasheet, and you want it to fully saturate when on so the pullup or pulldown resistor should be chosen for about an order of magnitude lower Ic than the 'On-State Collector Current' (at Vce=5V) tabulated in the datasheet.
If you put the resistor in series with the LED anode, you can get away with a three wire sensor hookup: LED anode, detector collector, and a single ground wire to both the LED cathode and detector emitter.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version