2011-03-25

I Seeeeee Youuuuu

So, first steps. I picked up a few PIR Motion sensors. These are a specific kind, there are a few other kinds, but they should have datasheets. You might recognise the bulbous white shape of them from those motion-sensing light switches. They're about a fiver each and fun to play with.

The comments section on Sparkfun had a very good tutorial on basic use, but also explains the basic principles of its operation. It has 3 pins -- DC, Ground and Alarm.

Science Bit

The alarm pin is what's called an Open Collector, which means it's either connected to ground, or to 'nothing'. To better understand this, let's assume you don't know what a transistor is (I know I sure didn't a few weeks ago).

Speaking simplistically, a transistor is a component where you can vary one voltage based on a much smaller voltage. In this way you can amplify a voltage pretty easily.

Here's a diagram!


Usually transistors are tiny and embedded or are tiny and on a breadboard, but let's assume for a moment that it's a box with 3 wires coming out of it. They're called collector, emitter and base. Emitter is always connected to ground, and provides the reference voltage, or definition of 'zero'. Base is a small voltage in relation to ground, and the voltage applied to the base controls how much voltage is allowed flow between the emitter and the collector. The difference between the voltage on the base, and the voltage allowed through the collector is called the 'gain'.

However! The voltage on the collector doesn't come from nowhere. It has to be supplied, and the voltage 'allowed' to flow is defined by the voltage on the base. So, if you apply 3.3v to the base, and 9v to the collector (the voltage marked 'Vcc' on the diagram there), you get a certain voltage that's actually 'allowed' through the transistor, and can be used in other applications by connecting them before the resistor (At 'Vout' on the diagram).

The zig-zaggy thing there on the diagram is a resistor. We put it across the larger Vcc voltage to lower it a bit, since transistors are usually only rated to take a certain voltage. The function of Vcc and the resistor is to 'pull up' the voltage across the emitter and collector. This is why the resistor there is often called a 'pull-up resistor'.

Transistors are handy for switches when you want to control a large voltage using a small voltage. They're also useful if you want to take a tiny voltage you get from a signal somewhere and amplify it.

Anyway, why this is relevant is that an 'Open Collector' is the collector from a transistor that's available as a signal. However, instead of usual 'binary' signals that might produce a 'True' voltage or a 'False' lack of voltage, it's either connected to ground, or not. Whether or not it is connected to ground depends on the base voltage. My guess is that the PIR sensor circuitry provides the 'base' voltage and lets us use any Vcc voltage we want, in order to 'pull up' the output.

So, if you go look at the circuit diagram and build instructions in the tutorial mentioned above, it works just so. The one modification I made here is that as well as pulling up the voltage, instead of connecting back to the LED on the Arduino board, I connected up to a big old Piezo Buzzer I got in Maplin.

The finished build looked like this:


So, the end result is that when you wave your hand in front of the PIR, the buzzer makes an annoying noise. Success!

Next up would be making things a bit smaller -- There are smaller, cheaper Arduino boards you can get, and I'll do a build soon that's a little easier to get into a project box and lug around with you.

2011-03-20

Aaaand..sleep.

I've been back from the states for a week or so now, and really have been meaning to get back to the electronics stuff. However, jetlag jetlagged me, and oncall oncalled me. I have played a bit with the PIR motion sensors I got, and with XBee, which I have to summon the mental wherewithal to write up and document.

Hoping to get back to it this week, in between the million other things happening, both work and non-work. The slowly spreading damp patch coming from the cieling of one of the rooms of my house would be #1 right now :-)

2011-03-10

Step 2: The Plan

Okay, I was talking last about my idea(s) for an electronics project, and I think I have enough of it thought about to sketch it out. I'll also point out where I got some of the specific parts for the project itself, in case you want to follow along at home (please don't, I don't know what I'm doing).



Those who are familiar with my escapades will know I'm into Airsoft, which is kind of like a bunch of grown men playing army with pellet guns. I've got a reasonable amount of kit, and have travelled quite a bit to various events and venues both Irish and abroad.

One of the venues I've been to a good few times is Sennybridge FIBUA Village in Wales. It's a Ministry of Defence training village that the British army uses to take pasty-faced youths and turn them into wet pasty-faced youths who want to go home. On a few weekends in the year, though, they open it up to pasty-faced middle-aged escapists to play 24-hour overnight Airsoft games. I've been to five of these so far, and I've another one coming up in April.

So, to the idea. One of the features of the game, of course, is being a sneaky git. It's the sort of game where World War I tactics of running line abreast at the enemy is unlikely to work. Sennybridge is comprised mainly of 2-3 storey buildings, which usually have between 1 and 3 entries. Usually you and a squad of 8 guys will take and hold the building until told otherwise. Sometimes this'll be at night, and you have to keep an eye open for people trying to take the building from you.



What would be nice is to be able to find out if someone's being a sneaky git and is sneaking up on you. So, something like a motion detection alert you can drop or conceal that'll let you know if it's time to watch those stairs.

Motion detection sensors are pretty easily obtainable, for less than a tenner. Sparkfun have one, and I'm sure there are other, possibly cheaper suppliers. After that it's about deciding what you do when you detect motion. So, I've ordered what I plan to do, in order of complexity (i.e. in order of likelihood to actually get done).

  1. Audible/Visible Motion Detector


  2. Pretty simple, really. If it detects motion, it makes an audible sound. You could also possibly switch it to 'night mode' where it makes a sound (so the person who set it off looks in that direction), and then it flashes a blinding white light, to screw up their night vision. I've picked up a X5 White LED PCB in Fry's that might do the job, if I can get enough power to it. Maplin also had a decent-sized buzzer, which you could make buzz with a couple of 555 timers. I like this idea because it could end up potentially costing less than 20 quid in parts, and I could make a few of them. It may not even require an Arduino (I know it doesn't strictly require an Arduino, but it may not require an Arduino even for an electronics leper like me).

    Incidentally, a great primer on 555 timers is in the Make: Electronics book, which I just read through on the train. They're tiny, cheap as chips (ho ho) and can be very powerful if applied correctly.

  3. Remote Motion Sensor


  4. A lot more complex, but potentially more effective. The sensor itself doesn't need to make a sound (although I could leave the flash in, since it has an effect). The sensor could alert me wirelessly and silently to it being tripped. I looked into a few options for this, including good old 802.11, but XBee seems to be interesting, and I've picked up a few XBee RF modems. Sparkfun and SK Pang have them, as well as Radionics.

    The sensor part could be quite similar to in Idea 1, except with a small antenna. I've also picked up some wearable LilyPad Arduino kit for the part attached to me. This can be powered from a couple of AAs or a small 3.7v LiPo (although probably AAs. I'm trying to limit my exposure to having lithium fires break out in my pockets). The alert could be audible, or could be via the LilyPad buzzer in a glove. So, someone sneaks into the building downstairs, and the back of my hand buzzes.



There are a few more ideas that came out of these, but this is the basic idea. Idea 1 is looking more likely, since I'm actually more likely to make it, the components are a lot cheaper (I'm entirely prepared for one or two of these to get stepped on, nicked or lost) and it's more likely to actually work reliably.

I've already done some exploratory work on XBee and motion detection, which I'll cover next. I've picked up a few PIR Motion Sensors and will document the fiddling next.

2011-03-07

And All the Hills are Rainbows

Various intricacies of how my job works these days means I work with people in a bunch of offices. They're not all in the states, but Mountain View and Irvine are two offices in California I do go to occasionally. When I was planning a trip to both late last year, I said I'd look at alternatives to flying for an hour (SFO->SNA). After doing some digging, I found the Coast Starlight, which is an Amtrak train that goes from Seattle to Los Angeles, and stops in Oakland and San Jose. It so happens Oakland is a short BART ride from SFO, so I said I'd give it a go.



I honestly am ambivalent about the TSA, and being groped and what-have-you. I realise there's no point in getting angry in Airports, because the people there are just trying to make a living. I'm also ambivalent about saving on flying (the plane goes whether I'm on it or not). I just like trains, and this one promised 12 hours or so of good geography and comfort. I got myself a 'roomette', which is apparently what you're allowed call a small cupboard with a seat in it, and it turned out to cost about $130, which is cheaper than some air fares SFO->SNA.

It also doesn't help that SNA is referred to in muttered tones as 'Disneyland Airport'. It's right beside Anaheim and the home of The Mouse, so it's usually packed with kids. The look on a co-worker's face when they called for people-who-need-extra-time-or-have-small-children, and half the airport marched onto the plane will stay with me always.



The train itself is good and comfy. Tea, coffee, juice on each sleeper carriage, and a bar and observation carriage which is decent for hanging out, and "has" "wi-fi" (said wi-fi could well have been using the train driver's 3G phone as an uplink, and meets the minimum federal requirement to be called 'wi-fi'). The food is/was reasonably decent, and some of the views are very pleasant.



12 hours is a bit of a hike, so it's not recommended if you have actual places to go, but it's miles more pleasant than the solid 4 hours or so of wangling door-to-door it'd take to fly, and also trains kick ass.

I'm in LA for the night, and continuing by train to Irvine tomorrow, where I will again endure the hilarity of having to rent a car to cross the road from my hotel to the office. Go California!

2011-03-02

Electronics Schwag (The Specifics)

A commenter asked me for more specifics on stuff to get when getting started with electronics, so since I've learned a little since then, here's my uninformed opinion.

Soldering Iron



Get a good one. I got a reasonably crap Draper one from Amazon, which was 25W. It's fine, but takes a while to heat up and can be a little while melting the solder, which is annoying when you're holding everything just-so and it's all perfect except the hot bit isn't hot enough. If I were doing this again I'd get a 40w one, and one with adjustable heat.

A lot of the soldering tutorials I've seen use a pointed tip on the soldering iron. I've found the chisel tip a lot easier. I can touch the tip against a solder point and heat the wire and contact a lot easier than using a pointed tip (which you don't use the point of anyway). I'd recommend you try both to see what works.

Solder



Lots of the online tutorials say "Don't use silver solder or lead-free solder, it's a pain in the ass to use". Well, thanks to RoHs, lead solder is at least very hard (if not impossible) to get in Europe. This crackpot here has a website talking about it, but you're probably wasting your time looking for lead solder in Ireland. I found it easy enough to solder with lead-free, but then again I've no frame of reference. I just picked up some 60/40 and 63/37 lead solder here in the bay area, so we'll see once I'm back.

People make a big deal about lead-free solder not being less dangerous than lead solder. All I know is that if you're burning a solid metal-looking object and smoke comes out, breathing it in is probably bad for you. Little pro tip there.

Wire Strippers



See this here, right?

stripper.jpg


Load of shite. Avoid like the plague. I wasn't able to adjust mine to strip the wire I got, and it just chomped ineffectually and was big and annoying.

Okay, now see this?

wire_stripper.jpg


Bog standard wire stripper, costs a fiver or less, is in pretty much every electronics set ever. That is because it's the only wire stripper you'll ever need. Some wire stripper inventor guy is using money to insulate his attic because of these babies, because they're great. Get one.

Wires



After talking about wire strippers, of course, I should let you know that stripping the ends off wires is for suckers. I picked up a Jump Wire Kit in Maplin in town, which has a bunch of varying lengths of wire, especially for breadboarding and the like. I also recommend this set of jumper wires from SK Pang, which are even neater (and cheaper!). For the first while you're probably not going to be soldering wires in place, so the jump wires are grand.

Breadboards



Breadboards are boards full of holes you stick wires into. If you're getting one, make sure to get one with a power rail going along each side, which are much nicer. It should look something like this:

halfbb.jpg


Get two or three so you don't have to dismantle something you're doing to re-use the breadboard.

Arduino Stuff and Components



The main Arduino stuff you want to pick up, barring any particular project in mind, is one or two (they're small and cheap) boards, the USB cable you need to talk to them, and some breadboards for fiddling around.

The board you want to get is the Uno, and you may want to avoid the SMD edition if you can. For a lot of stuff, it won't matter, but the main difference is you can't remove the microcontroller chip from the SMD version. There are reasons you may want to do this, which I'll cover in a later post. The SMD version was mainly produced due to a worldwide shortage of the Atmega328 chip in the larger removable form factor, so you're more than likely getting the non-SMD, but it probably doesn't make a difference. The SMD version apparently has other improvements for meganerds who want to fiddle with the firmware on the board.

This is the normal version with the microcontroller chip in a socket on the board:

uno.jpg


This is the SMD version, notice the tiny surface-mount chip. Same chip, different form factor. Notice the 6 extra pins near the USB port. Apparently you can do science with them:

unosmd.jpg


You might also look into getting 'shields' for the board, which are basically other boards that plug into the Uno. They're good for prototyping, but can be bigger than what you want when you want to shrink things down. You can get them for stuff like ethernet, XBee (mesh networking), and other kinds of wired or wireless comms.

I recommend getting one of the starter kits, the one from Adafruit is good, comes with everything you need. I also recommend getting a Proto Shield, which is a good starter soldering project. The Adafruit starter kit comes with one, and SparkFun do a different one that does roughly the same thing. While you're getting stuff, have a look around SK Pang, AdaFruit and SparkFun to see what they've got, there are a bunch of ready-made projects and widgets that'll give you ideas for projects. Personally, I picked up some LilyPad stuff for the project I dreamed up (details coming soon) and an RFID reader chip and breakout board for fiddling with RFID.

For more specialised stuff, there are smaller boards you can get, which end up cheaper than the Uno. The Pro Mini and FIO end up a fiver or so cheaper per board, and can be good if you have specific things in mind (I picked up a pair of FIOs, since they have an XBee socket onboard).

As components go, Maplin do 'lucky bags' of the likes of resistors, capacitors, etc. If you know exactly what you want, Radionics have a large catalogue and do next-day courier delivery in Dublin for a fiver.

Next Up



Next up I'll be talking about the project I've been thinking about, and the bits I've been gradually accumulating for it. I'll also show you the first few photos I have of my own tinkerings with RFID reading.