Showing posts with label low battery circuit. Show all posts
Showing posts with label low battery circuit. Show all posts

Wednesday, 17 June 2015

Laser-based motion detector

One of the upsides to creating projects for other people, such as the swear jar, is that it often leads to conversation about other ideas, and becomes a great source of other projects.
A lunchtime conversation with a colleague yielded the idea of a laser tripwire, which could be used around the office to trigger practical jokes, use as a 'boss switch' etc.
The idea of laser tripwires is a bit of an old spy-movie cliche, and for practical use a passive IR sensor would be both easier and more useful, but there's a certain novelty aspect to using a laser that I couldn't resist.

In addition, I've set a couple of additional challenges for myself:
  • I'm making this a 'speed-run' build, because I'm getting frustrated at the amount of time it's taking for me to complete projects at the moment.
  • Only use items I already have lying around. My junk bin is full of half-assembled boards and off-cuts of other projects, and I'd like to get rid of them, so what better way than to actually make use of them.
Apologies for this post being text-heavy. The full writeup is below, or if you're impatient, here's a short demo of the tripwire working.


Day 1 (Monday Evening)
I found an old laser pen as the base, the metal case of it makes it difficult to get into, but I managed to hook in a couple of wires to the battery compartment (it runs on 3v). As I couldn't reach the power button to wire across it, I opted for a low-tech tape solution to just hold the button down. Unfortunately this wasn't strong enough, so I wedged the laser pointer in a copper pipe t-junction that was in the junk bin.

For the receiver of the tripwire, I'm using a small light-dependent resistor (LDR) module. Back when I started with electronics, I created simple screw-terminal breakout boards of various components to aid rapid prototyping - there's 3 terminals, Vcc, LDR output, and ground (via a 10K resistor). To help filter light, I found a red Tic-Tac box, which should filter out most ambient light, but allow the lasers light to shine through.

To threshold the LDR output, I created another low-battery circuit as I've used before in the pedal-keyboard project. This allows for the sensitivity of the receiver to be adjusted, and a digital output to be triggered once the threshold is crossed. I found part of a board which contained the transistors that this circuit would need, and just required some jumping of wires. The resistors were recycled from junk-bin ones which had their legs snapped off.

After applying copious amounts of hot glue to hold it all together in an old business card box, the receiver circuit did work for a brief period, before one of the wires snapped. Hopefully tomorrow I'll only need to re-solder a those wires to finish that circuit, then I can move onto setting up the laser and reflector.

Rough diagram of how this thing should work...

 Day 2 (Tuesday Evening)
Fixed the snapped wire from yesterday, & tested the receiver circuit. The next stage is to make it do something useful. I found an old wireless doorbell which I can repurpose.
The transmitter PCB
Transmitter button & receiver PCB


The receiver can trigger the 'button' part of the bell, which will then notify the 'bell' which I'll convert into a handheld device to notify the user of the detector being activated.

The transmitter being tested before putting together.


Days 3 & 4 (Sat and Sun)
Wired in a relay to control the transmitter, and worked on how to power the circuit. As space is limited, I've used a 9V battery, running through a TS7805 
 regulator to provide 5V to power the detector circuit, and 2 diodes in series to drop the power to approx 3V for the laser pen. The doorbell transmitter runs of 12V, but for convenience I've opted to just power that from it's own battery, as they have quite a long life anyway.

Also rewired the doorbell receiver to a vibration motor from an old Playstation controller, and wired a AA battery holder in place of the original D cell ones. This should result in a pocket-size receiver that vibrates when the laser beam is broken.

The receiver - battery pack on reverse.

A fortnight later....

Day 5 (Sat)
Some bad planning on my part meant that the output signal from the laser receiver was the inverse of what was needed - so effectively the doorbell component was triggered whenever the laser wasn't broken. Not very useful.

Created a not-gate with a simple transistor and wired that in place, however the resulting current was not enough to trigger the relay, so I added another transistor to amplify the not-gates output.

In the end, the whole project took about 3 weeks, but only about 6 days where I was actually working on it. It's a complete bodge, and hideously impractical, but was a nice challenge and works surprisingly better than expected.

The finished product, receiver (left) and laser detector (right)



Monday, 11 August 2014

Analog pedal to USB keyboard


A lot of my electronics junk box consists of old videogame peripherals, which are often tricky to re-purpose because of proprietary connectors, peripherals, etc.

These pedals, for example, connect to a Playstation steering wheel by a fairly normal 9-pin serial connector, but the wiring isn't standard. Even if it were, most modern PCs no longer have serial ports, so a serial to USB adapter would be needed, and a software solution to make the input useful.

What I'm really after is a drop-in system, that can provide input as if it were a regular keyboard or mouse. The easy way out would be to use a microcontroller to emulate one of those devices, but I want to avoid throwing one at every problem, so I'm going to opt for only using discrete components and a scavenged keyboard PCB.

I'm going to re-purpose this keyboard PCB from the phone scanner project that I did a while ago.

The pedals themselves are essentially just a couple of potentiometers, so in it's simplest form, the contacts for a key could be wired to the pedal. This would mean that as the pedal is pressed, it will reach a point where the resistance is low enough for the signal to pass, however this is quite a simplistic option.


It also seems a shame not to make some use of the fine control of the analog input, so what I have in mind is a two-stage trigger type system - so that a light press of the pedal completes one key, and a complete press sends a second key. For example, a light press could be 'Ctrl', and the full press 'X', to create a pedal for the standard Cut shortcut.

So what's needed is to find a way to create a threshold for when to close the keyboard circuit and trigger the buttons. In order to so this, we can use a low battery circuit, such as the one shown here.

Rather than wait for the power to drop though, we will be using the pedals' potentiometer in place of R4 in the diagram. As the voltage will remain the same, using the pedal to change the low voltage level will change the sensitivity of the circuit, so that when pressed, the LED is triggered. We will also replace the LED in that circuit with an optocoupler, connected to the keyboard matrix for the key that we want.

To create the second stage of the trigger, another copy of the circuit is created, but using a higher value resistor in place of R3, and sharing the same R4 (the pedal). This one will trigger when the pedal is pressed further.
The circuit, with a test potentiometer in place (the upside-down PCB just contains some screw terminals for attaching the potentiometer - see right) Each pair of leads on the left go to the respective terminals on the keyboard PCB (below)
The screw terminal on the underside (on a separate PCB as I scavenged it from the junk box)

The keyboard PCB. The old IDE cable is there to make it easier to patch together the key matrices - In the picture above the leads from the pedal circuit board are connected.


Finally, power is added to the pedals from the keyboards USB connector - see left. This is sufficient to power both the keyboard and the pedal circuit


I have currently only done this for the right-hand pedal, but the same process could just as easily be done for the left (perhaps for other modifier keys - one shift, one ctrl etc).


A test of the pedal in various applications showed it to work, and has proved its usefulness for tedious key combinations in games (such as toggle run/slide etc)