Thursday, June 30, 2011

Robo-Roundup #19

http://www.wired.com/images_blogs/photos/uncategorized/2008/12/21/blocks_image_1_1_2.jpg
Finally after vacation this is Robo-Roundup #19 and we are featuring some very cool robots!

1. A robot vacuum cleaner with "personality": http://spectrum.ieee.org/automaton/robotics/artificial-intelligence/how-to-give-robot-vacuums-a-personality

2. President, Barack Obama talks about robot revolution: http://spectrum.ieee.org/automaton/robotics/industrial-robots/obama-announces-major-robotics-initiative


3. New eco-friendly robot recycles cans for you: http://www.plasticpals.com/?p=28399


4. Meet this new small huminoid robot: http://www.plasticpals.com/?p=28413

Thanks for reading and be sure to visit the site tomorrow for a very interesting post!

Wednesday, June 29, 2011

Multiple touch sensitive inputs

In a previous post we talked about how to use a darlington transistor to create a touch sensitive switch.

For a device with multiple touch-sensitive inputs, it seems obvious that we repeat the single input for each pin we want to use as a touch sensor:



However, for each input our component count increases.
In the example above, we're using PORTB on the microcontroller, which has a built-in pull-up resistor on each input pin. If we need to use a different port, or want to use more than 8 inputs, we're going to have to add a pull-up resistor on each input pin. Also required - though not shown on the diagram above for the sake of simplicity - is a 1M pull-down resistor on the base pin of each darlington transistor.
So for each additional input, we're introducing three extra components.

It's worth noting, at this point, that for each touch sensitive input, we need two pads per input: one pad connected to the base pin on a transistor, and one pad connected to the 5V supply (the user touches and effectively creates a bridge between the 5V supply and the base input pin).

However, we can simplify our design massively by swapping the pads around:
instead of a fixed 5V supply and multiple darlington transistors, we can use a single transistor and multiple, variable 5V supplies. How to do this?
We turn each potential input pin to an OUTPUT and use this output to drive what would otherwise be a fixed 5V supply on the first pad. So each pair of pads that make up a touch-sensitive switch consist of an output pin (from the microcontroller) and a pin connected to the base of the darlington transistor.

a simple PIC/usb device with 16 touch sensitive inputs

Every touch contact would consist of a pair of pins/pads - one going to each of the numbered pads (PAD1, PAD2 etc) and the other a common input (COM_INPUT) so there would be a total of 16 COM_INPUT pads all tied together.

The pseudo-code would go something like this:
  • turn off all outputs
  • turn on output RA2 (PAD1)
  • has RA0 gone low? (yes=finger present across PAD1 + COM_INPUT)
  • turn off output RA2
  • allow time for input to return high
  • turn on output RA3 (PAD2)
  • has RA0 gone low? (yes=finger present across PAD2 + COM_INPUT)
  • turn off output RA2
  • allow time for input to return high
  • etc.

It depends on the type of darlington transistor you use (different transistors have different response/switching times) and the size of the pull-down resistor on the base pin, but in practice, with a 1M pull-down resistor, we found that 0.5ms (500us) worked well. Using this approach, we were able to poll all pins in under 10ms (0.5*16 = 8ms). At 100 times per second, this was more than responsive enough for our needs!

Until we can use the CNC again....

...the most exciting thing about getting a CNC machine working is the ability to quickly and easily drill our home-etched PCBs. But also, the ability to carve shapes and make enclosures for forthcoming projects is pretty cool too.

We've a few projects in the pipeline, which make use of some pretty simple but powerful underlying technology. After running a few workshops in and around Brighton and receiving a few emails from previous posts on other projects, we're going to document these in their entirety.

We'll be using the 18F2455 and 18F4550 PIC microcontrollers to create USB/HID devices. And we're also incorporating a simple touch-sensitive interface. At the minute, capacitive touch sensors are all the rage. What this basically means is that each touch pad connects to a microcontroller and when the user places their finger over the pad, a simple capacitor is created. The relative capacitance of the pad is compared over time and when the capacitance changes, the microcontroller can detect whether a finger has been placed near or removed from the pad.

The downside of capacitance touch sensing is the need for relatively large pads - or dedicated capacitive sensing hardware.

To keep our project simple - both in writing the firmware (capacitive sensing firmware can be quite convoluted and multiple readings averaged over time to smooth out any rogue analogue readings) and in sourcing the hardware - we're going to use an alternative approach:

A transistor is often used as an electronic switch, but it can also be used as an amplifier. A tiny current onto the base pin of an NPN transistor allows a much larger current to flow through the collector and emitter pins.



Whatever current is directed onto the base pin is amplified onto the collector pin.
By "feeding" the output from one transistor into the base pin of a second transistor, we can amplify the input signal many thousands of times over



In fact, by feeding one transistor into another, even the tiny amount of current that passes over the surface of your skin can be used as a switch. Such transistor pairs are available in a single package, known as a Darlington transistor.

Here's an example of how we can use a darlington transistor as a touch sensitive input device for a PIC microcontroller:

The schematic above uses a darlington transistor, such as a BC517 as a single discrete component. Although a darlington transistor is actually two transistors connected as shown above, we will draw it as a single transistor for simplicity.

Touching the two pads - however large or small they may be - causes the transistor to switch, forcing the current to flow from the input pin to ground. While this may seem counter-intuitive (normally you might expect voltage to flow into an input pin to indicate an input switch) the reason for this should become clear: on a lot of controllers (and had we put this input onto PORTB) you can use internal pull up resistors on the inputs, removing the need for the external resistor as shown in this example. If your controller does not have internal pull-ups, the resistor is there to stop the input pin "floating" when no finger is present on the contacts. The resistor should be quite a high value, say 100K.
Now, when the pads are touched, a tiny current flows from 5v on PAD1, over your finger, onto PAD2 and into the base of the darlington transistor. The transistor amplifies this current, creating a "switching effect" and causes the input pin to go low.
When the finger is removed off the pads, no more current flows into the base pin, the transistor closes the "switch" and no current can flow from the input pin to ground. The pull-up resistor causes the input pin to go high when the pads are not touched.

Although the above gives us a working touch-sensitive switch, we're not quite done. If you try the schematic out, you might find - depending on the type of darlington transistor used - that while the "on" trigger works (i.e. the input goes low immediately after touching the pads) the "off" time can be quite slow (i.e. the input pin remains low for a second or more after removing your finger from the pads).

The reason for this is that the darlington transistor can amplify even the tiniest little current - even residual electrical noise can be used as a trigger; it's a bit like leaving an input pin floating - the base pin of the transistor is so sensitive it can switch on and off almost at random. And like a floating input pin, it can remain active even when the input is removed.



The answer is to put a pull-down resistor on the base pin.
Now, when your finger is removed, any residual current on the base pin has a path to ground, and the switch closes. The size of the resistor determines the response time. If the resistor value is too low, it may stop the transistor switching on at all (the human body has an electric resistance of around 40k-100k so this base resistor needs to be much higher) but too high and the residual current on the base pin may take too long to be pulled to ground, resulting in slow response times. In practice, we found that a resistor with a 1M resistor on the base pin (R2), with a 100K pull-up resistor (R1) on the input pin worked well and gave reasonable response times.

Setting the scale on the CNC machine

So far we've managed to create our own g-code from ExpressPCB layout files and got our CNC machine moving to our own home-built g-codes. Now the last piece of the puzzle is to get our machine to move according to the g-code created from the ExpressPCB layout. Sounds simple?

It should be - but so far the CNC machine seems to be making up it's own scale! Sometimes a command of G0 X5 Y0 (move 5 "units" in the x-axis) causes the gantry to travel a few cm, and other times, it tries to travel further that the maximum distance available!

What we're aiming for is a CNC that moves in inches.
To calibrate our machine, we want to be able to draw dots at 0.1" intervals.
The idea being that after replacing the pen with a 1mm drill bit, we can make our own PCBs with a 0.1" pitch that fit perfectly into the breadboard prototyping boards.

Here's how we got on....

The first thing was to get the CNC machine to draw something, using a known scale.
Unfortunately we didn't know anything about the machine - we discovered that the stepper motors we 1.8 deg/step with micro stepping (they were originally painted over!) but without details on the lead screws, we had no idea how many steps per mm were required. So the plan was to draw a shape - or series of shapes - using g-codes to draw one unit lengths (e.g. GO X1 Y0 would draw a horizontal line in the x-axis, one "something" in length).



From here we measured our "one unit" using some digital calipers and found it to be 0.821 inches in length. We decided to use inches as units (since we know that breadboard and vero board uses 0.1" pitch, it made sense to stick to inches). So with our current Mach3 set-up showing 2000 steps per mm and knowing this produced a line 0.821 inches long, changed the steps per mm to (2000/0.821) = 2436.05

With this new setting, we drew a grid of dots, each 0.1 "units" apart.
We also, for comparison, drew grids using 2400 steps and 2500 steps per mm.





After drawing the grid, we compared the output to some 0.1" pitch vero board.
The grid drawn at 2436 was ok for a small area, but much beyond 10 holes, and the drawn dots and the actual dots on the vero board started to drift. This means we need a value either slightly higher or slightly lower than 2436 (actually, we expected this to be the case, which is why we'd already drawn extra grids at 2400 and 2500).

At 2500 the dots in the grid seemed to drift out of alignment quite quickly, after four or five dots:

(The angle of the photo reduces the effect of the drift, but it is very noticable when viewed from directly above)

At 2400 we seem to have a perfect match. The grid of dots remained perfectly in line along the full length of the vero-board.

The angle of this photo does not really make the perfect alignment obvious, but each of the dots stays in the exact centre of each hole on the vero board.

So it looks like we've finally got the CNC set up and working properly!
The real test will be when we pre-drill some copper board BEFORE etching.
In theory, the press-n-peel transfer and the drilled board will line up perfectly.
But since it's gone midnight now, and BuildBrighton is closing it's doors for another few days, that'll have to wait until next time........

Friday, June 24, 2011

My personal review of the hexbug original

A couple days ago I was at Brookstone and I came across a shelf of Hexbugs. I said to myself, "I already have the ant, I have played with the nano, the spider isn't here, and the inchworm looks boring." So with that being said, I decided to pick up the orange Hexbug original- orange corresponding with the color of SimpleBotics. So when I got home I turned it on, and let it go. Man, was it the neatest thing, and not only did it avoid objects, but it sensed sound. That meant that every time you clapped your hands or banged your feet on the ground, the bot would turn around. Overall I recommend it third best Hexbug, with nano second, and spider first. You can check out the video below to see my unboxing video that I uploaded on YouTube. Thanks for reading a please comment and or follow!