Wednesday, 31 August 2011

Holy moley - look at these PCBs

Well just as we'd got some piezos into our little drum kits, there was a ding-dong on the door of Nerd Towers, and a DHL parcel arrived. It was the double-sided PCBs from PCBCart! Like spoilt kids at Christmas, we immediately forgot about what we were doing and ripped apart the latest present to arrive. Impressive looking stuff...

Black solder mask, hot-air-solder-levelled (HASL) contacts and lovely white silkscreen on the front:

Here's one in place on an actual miniature guitar:

We've got some tiny quarter-pitch cable soldered onto one of the PCBs already - now we just need to mount a miniature USB socket onto a board so we can try the actual device out and make sure everything works as it should!

Miniature drums again

Just when it looked like we were all set to finally complete a miniature synth, our piezos arrived in the post - so naturally we dropped everything and set to work on our miniature drum kit again!

Here it is, looking more and more like a real drumkit every day...

At first, we made little acrylic circles for the tops and bottoms of each drum (see where the base of the snare drum meets the stand, for example) and covered these in shiny chrome sticker paper. Then we found some 3.5mm chrome door strip (for pimping up your car) on eBay and decided that gave a much nicer finish (see tom toms and floor drum for example).

The chrome sticker came in handy for finishing off the hi-hat, so it didn't go to waste!
Hopefully we'll get a final drumkit prototype working some time tonight....

Monday, 29 August 2011

Minature instruments again - synth redesign

Some more electronics goodies arrived in the post this weekend, so while the idea of making an X-Y CNC type framework is still very exciting, it's time to turn back to our miniature instruments idea. In in particular, we've been looking at our miniature synth.

Although we got a working keyboard up and running relatively quickly, when it comes to boxing it all up and putting it inside a nice neat enclosure, things have taken a turn for the worse. Using the existing key layout as a guide, we put together some designs for three different types of synth:
  • Mini-moog
  • Roland style keyboard
  • Yamaha keytar

The problem is, the actual keys part of a synthesizer keyboard are only a small part of the overall instrument. So while the keys look fine on their own, put them, inside an enclosure, and the whole thing looks enormous - especially when compared to the guitar and drums

Cutting out prototypes from cardboard is a much cheaper way to try out new ideas, without spending a fortune on laser cutting acrylic which could very well turn out to be useless!

So we've had to re-scale the keyboard part of our synth.
At first, we just scaled the plastic keys to about 80%, printed them out and tried to see how they'd fit in with the rest of the range. Of course, this didn't work - because the PCB will pretty much decide how big (or small) our keyboard can be. We've redesigned the PCB so that the pushbuttons for the keys are as close together as possible, and then used that as the basis for the new keys layout.

All in all, the final synth design is about 75% smaller than the first attempt.
But more importantly, it's a little more in-keeping with the rest of the instruments in the range.

Wednesday, 24 August 2011

Lexmark X73 all-in-one printer scanner

I got one of these off eBay today.
I'd been scouring Freecycle for a while and any time a scanner or a printer came up, put in a reply begging for it - sometimes even explaining that it was going to be fully recycled into something more interesting and infinitely more useful (although perhaps that's why no-one ever got back to me) - but nothing came up.
So I put a bid on this Lexmark X73 and won it. For an amazing 50p!

It was a bit cumbersome, travelling across Brighton & Hove with it (and a sort-of-working monitor I also got for 50p but that's for another post) under one arm, mounting and dismounting a variety of buses, but worth it in the end.

It took less than 45 minutes to reduce an all-in-one printer/scanner to this pile of recyling/rubbish...

...and this pile of rather useful looking parts:

Here's what I managed to salvage -
a) 0.1" and 0.05" pitch ribbon connectors
b) two-wire motor
c) rods and rails
d) cogs/gears/pulleys
e) four wire stepper motor
f) 5mm pitch belt
g) 2.5mm pitch belt
h) six wire stepper motor
i) my dismantling tools (not included!)

And of course, a fairly beefy power supply - 30VDC 1A output
Given that this power supply came with the printer/scanner, we can safely assume it's good enough to power all motors together - there's only one way to know for sure, but it's getting late (it took nearly three hours to get across the city and back again on the buses this evening, so I didn't get started 'til 10pm) so it'll have to wait 'til the morning now.....

Tuesday, 23 August 2011

Stepper motor forwards and reverse

A quick video showing the stepper motor going in both forwards and reverse directions.

Schematic shows PORTD connected to two ULN2803A darlington array ICs. For simplicity we've used one IC per motor, but each IC can in theory support two motors at a time - the 16-pin ULN2003A has only 7 available darlingtons, these 18-pin ULN2803A chips have eight). Pin selection is a bit messy - we'll probably move these around for the final version when it comes to putting everything down on a PCB, for easier routing.

The jog buttons (RB7 + RB6) allow the user to manually move the stepper motor in either direction. Alternatively, you can send a move "request" to the microcontroller, which consists of number of steps to move (a two-byte value) and direction (forwards/reverse)

The noise in the video is not rowing neighbours, as suggested by some viewers, but a Radio4 play and my partner on a sewing machine in the other room!

In the video we're using a 1.8 degree stepper motor.
That means 360/1.8 = 200 steps for one complete rotation. We're driving the motor in "half-step" mode (for increased precision when connected to a belt-drive) so 400 steps are required for a full rotation. The video shows a value of 1 (high byte) and 144 (low byte) being entered - this is the same as (1*256)+144 = 400

The motor responds by completing one full complete rotation.

Monday, 22 August 2011

Driving a stepper motor directly from a PIC

Much has been written about driving stepper motors. Some sites say it's easy. Some people say it's hard. Some people say you have to get the timing and the sequence right, some people say it's more hassle than it's worth and you should just buy a stepper driver board!

We've spent just a few hours today playing about with our (quite beefy) stepper motor (borrowed from Matt at until we can buy/salvage some 1.8 degree steppers) and found it's quite straight forward - provided you follow each step slowly and carefully.

The first thing to do is understand how the stepper motor works.

We're just going to stick to the common 4-phase stepper motor. It has four coils and we need to energise each coil in a particular sequence, in order to get the shaft to turn.

For the sake of simplicity, we'll only use one form of stepping (you can use whole-step, half-step and micro-stepping for different levels of precision). For whole stepping, you energise one coil at a time. With micro-stepping, you vary the amount of current going into one or two coils at a time. We're going to make all our movements using half-stepping, which means activating one or two coils at any one time.

To get the above stepper to move anti-clockwise, we need to energise:
  • coil 1 only
  • coils 1+2
  • coil 2 only
  • coils 2+3
  • coil 3 only
  • coils 3+4
  • coil 4 only
  • coils 4+1

As you can see, it takes 8 pulse combinations then we're back at the start. This sort of makes sense, since we have four coils, and we're using half-stepping (twice as many steps needed as for whole-stepping).

Now we know how a stepper motor works, we need to identify each wire in our bunch of six coloured wires. Sadly, there's no common colour chart to refer to - different manufacturers use different coloured wires so don't just blindly follow this set-up: find out how your own stepper is wired using this technique

Create a chart listing all six colours of your stepper motor in rows and columns.
With a multi-meter, measure the resistance between each coloured wire and the five other wires. Write down these values - each coloured wire should be connected to two other wires. It doesn't matter what these values are, what we're looking for is which values are twice the others.

Where you have the double-resistance values (in our case, black + green and red + blue) this is where you've just measured across two coils. These are the outer-most coil wires (in our example, black=A, green=C, red=D, blue=F)

Where you have single resistance values (in our case black + yellow, green + yellow and red + white, blue + white) you've just measured across a single coil so one of these pairs of wires must be the "one in the middle" - or common wire.
In our example, yellow is between black and green, so yellow=B and white=E

With this information, we're ready to wire everything up and make our motors move!

We've created a USB interface which allows us to send movement commands to the PIC 18F4550 microcontroller as well as a "jog" button. We can send a command to the PIC to say "move the motor through X number of steps", or we can "jog" the motor - i.e. make it rotate for as long as the button is pressed.

Here's a snippet of the Oshonsoft Basic code for controlling the single stepper motor:


     'every time we take an input pin high, pulse the stepper
     If PORTB.7 = 0 Then
           'jog the x axis motor
           jog_x = 1
           steps_to_move_x = 0
           Gosub stepmotor
           Gosub delay_after_pulse
           'update the X axis motor
           If steps_to_move_x > 0 Then
                 Gosub stepmotor
                 steps_to_move_x = steps_to_move_x - 1
                 Gosub delay_after_pulse
Goto loop

     If stepdir = 0 Then
           step_pos = step_pos + 1
           If step_pos > 7 Then step_pos = 0
           If step_pos = 0 Then
                 step_pos = 7
                 step_pos = step_pos - 1
     Gosub energizecoil


     'our test stepper is wired with
     'red-white-blue and green-yellow-black connected
     '(white is common, yellow is common) so we need to drive them
     'in the pattern red, black, blue, green
     'to turn in one direction and red, green, blue, black to
     'turn in the opposite direction

     Select Case step_pos
           Case 0
           Low x_coil4pin
           High x_coil1pin

           Case 1
           High x_coil1pin
           High x_coil2pin
           Case 2
           Low x_coil1pin
           High x_coil2pin
           Case 3
           High x_coil2pin
           High x_coil3pin
           Case 4
           Low x_coil2pin
           High x_coil3pin

           Case 5
           High x_coil3pin
           High x_coil4pin
           Case 6
           Low x_coil3pin
           High x_coil4pin
           Case 7
           High x_coil4pin
           High x_coil1pin


     If stepper_delay_us > 0 Then
           WaitUs stepper_delay_us
           WaitMs stepper_delay_ms

We've split the current position of the motor into 8 segments (numbered 0-7) so we always know which is the next combination of coils to energise to continue rotation. So wherever the motor stops, it can start again from exactly the same position - we don't have to return to a "known rest-state" as we should always know the next step in the sequence.

To move the motor, we can either hold down the jog button, or set a value in the two-byte variable called steps_to_move_x (this motor will form the basis of our x-axis). If this variable contains a value, we energise the necessary coils, move onto the next coil "state" and reduce the value in steps_to_move_x by one.
When this value reaches zero, we can send a message back to the PC to say we've arrived at our destination. This way, the PC can use a "fire-and-forget" messaging system: it tells the device how far it wants each motor on each axis to move, then gets on with other work. It doesn't have to keep asking for an update report, the device will inform the PC when the task has been performed (the PC fires off the request, then can forget about it!)

Here's a quick video demonstrating single-axis rotation using a 4-phase stepper motor. You can press (and hold) a button to "jog" the motor along, or send a value to the microcontroller, to tell it to move through a specific number of steps.

Sorry about the bad light! This was taken in the early hours of the morning (when most of the coolest development gets done) and it seems the camera doesn't like our artificial light)

Moving in the X and Y axis

Using a ULN2003A darlington array (sometimes called a relay driver when used for switching things on and off) we're working on building our own stepper motor control board.

This isn't quite as crazy as it sounds and there are a few reasons for doing this.
First off, we're making a pick-and-place type machine, so drawing complicated shapes and arcs isn't important. It's not going to be g-code compatible (at least to begin with) so we can use our own protocols and data formats. And it'll be PIC-based, so we can use the USB interface, rather than the usual parallel port.

All we're going to worry about for now is moving in two axes (eventually we'll have three when we introduce the up/down head movement). Traditional CNC machines time their stepper movement, so that when a co-ordinate is sent, both motors are powered to arrive at the correct X and Y co-ordinates the same time.

Our plan is to send values to the controller board, indicating how far in each axis we want the motors to move. The controller board translates these into "steps required per axis" and then sets counter values.

For example, if we're using half-step control, with 1.8 degree motors so that 400 pulses are required for a single rotation, one pulse should create a 0.25mm movement (see previous post for explanation)

We can send data to the control board, saying we want to move 10mm in the X and 25mm in the Y axis. This translates as 40 pulses on the X motor, 100 pulses on the Y motor. So we set the x counter to 40 and Y counter to 100.
Now, on the controller board, we send a pulse to every motor that has a counter value greater than zero, and decrease those counters by one. When all counters have a value zero, we send a report back to the host PC to say we've arrived at our destination.

The resulting movement would be similar to the diagram below:

What now? More CNC goodness!

The whole miniature instruments project grinds to a halt, while we wait for the postie to bring us a whole load of goodies to finish them off.
The drums need piezos for the underside of the drumheads (to send a strike signal back to the microcontroller when each drum is hit), the guitars are awaiting double-sided PCBs for the guitar neck, and the synth needs a miniature rotary pot and some LEDs.

So while we're waiting for all these bits and bobs to arrive from a variety of sources (mainly Farnell and eBay) we're starting to think about production. While it's easy enough to get things made cheaply overseas, we're a bit nervous about committing thousands of pounds to get hundreds of miniature instruments made. That's money that would be better spent on tools and equipment for other projects! Also, by committing to having loads of the same thing made, the options for customising them is greatly reduced. By manufacturing the little instruments ourselves, we can offer a full customisation service - and keep initial costs down (even if it means the cost to manufacture each one increases).

What we'd love to have/make is a pick-n-place machine for putting all those fiddly little SMT components in place on the PCB. If the same machine could also drop blobs of solder paste in the right place too, all the better.

We've already had a play with CNC machinery and on the face of it, creating and controlling a CNC machine shouldn't be too great a problem. Unlike a CNC router, we don't have to move large, heavy, cutting heads, or worry too much about external/twisting stresses on the machine joints.

Thanks to the guys at Oomlout, we've got pretty much all we need as far as servos and control gear goes. Stepper motors can be salvaged from old printers and scanners (we will be re-subscribing to the Freecycle mailing list to see what comes up!). We're considering a belt-drive rather than a threaded-rod for driving each axis. Lead-screws are great for low-speed, high-precision work, where high torque and large stresses and strains are used. Belt-driven control means faster rates of movement.

Although this is still in the early stages, here's what we've come up with:
Firstly, we're going to use stepper motors for controlling each axis. This is a no-brainer! BUT - CNC software (Mach3, MasterCAM, RouteOut etc) is notoriously difficult to get started with. So while using a Mach3-compatible control board (there are loads on eBay) means we can have something up and running very quickly, the finished product is then dependent on Mach3 (or similar software) which needs lots of parameters setting to configure correctly. Great if you're into that sort of thing, buy we'd just like to make a device you can plug in and drive!
The other issue with most CNC homebrew software is that it requires a "real" parallel port. Something our little laptops don't have! And we'd like everyone at nerd club to be able to use the machine, without having to have a dedicated CNC controller PC.

All this means that we're looking at creating our own (PIC-based, USB driven) stepper motor control board, as well as our own custom controller software. Because we don't want to draw fancy shapes, circles and arcs - we just want to control an x and y axis - we're pretty confident that our own custom drivers should be feasible. For this project, ease of use (and ease of understanding) is key to everything!

We're already familiar with the ULN2003A darlington array chips, so we'll use those to actually drive each stepper motor.

Now a belt-driven approach is a pretty new concept at Nerd Towers, so we're deliberately choosing values and ratios that make things easy to understand. They may not be the most efficient, or "best" choice for a particular purpose, but because we're building the driver board and driving software ourselves, it needs to be easy to understand (and easy to debug when things go wrong - as they invariably will!)

We're using 1.8 degree stepper motors.
This means it takes 200 steps to perform a single rotation (360 / 1.8 = 200).
We're also going to be using 5mm pitch belt (because it's easy to get hold of)

So if we have 5mm pitch belt, and use a gear/cog with 20 teeth, this means that in one rotation (200 steps) we can move our belt (5x20) 100mm. Which gives our CNC type machine 200 steps to move 100mm - or 1 step moves (100/200) = 0.5mm.
This is pretty good precision. If we drive the motors in "half-step" mode, we can get this precision down to 0.25mm

Many belt-driven CNC machines (laser cutters for example) can acheive precision of 0.1mm, using micro-stepping. While that level of precison would be a nice aim, our core driving principle is "easy-to-understand" so we'll accept slightly less precision for a much simpler machine! After all, a quarter of a millimetre is pretty precise when it comes to dropping SMT components onto a PCB.

Sunday, 21 August 2011

Drumkit starting to look like a drumkit

Not had much time this weekend to do much work on the new drumkit (let alone finish off the miniature synth which, although working, still doesn't have a shell for it!) but did manage an hour or so to cut out the rest of the drum rims and a neato stand for the snare drum.

The floor tom also has legs attached and the drum body stands off the floor now, but it's the snare stand that we're particularly pleased with!

Coming up with a working crash/ride cymbal is proving quite tricky (although we've got the designs for the stand down now!) And of course, we need a nice solid way to mount the tom-toms on top of the bass drum. Most real drumkits have a central column with two pieces coming off it (a bit like a letter T)...

... whereas some have two distinctly different mounts, one for each tom:

Whichever method we use, we'll have to have some sort of hollow tubing, to stuff the wires up to keep them out of sight! So with that in mind, two separate stands might actually be easier to work with (joining two hollow tubes at right angles, while keeping the route clear for wiring sounds tricky to us!)

But already it's late - that'll have to stay as a problem for the morning.

Miniature playable drumkit from scratch

Having already got an existing drumkit (bought from eBay) working as a miniature playable digital drum machine, we decided to have a go at making a new kit from scratch.

Examining (ok, destroying) the original kit we bought, it simply looks to be made from a few different sized bits of plastic tubing, with clear acetate for drum skins. So far, so easy. We'll be using some thin HIPS (high-impact polystyrene) in white for our skins (there's no real point trying to stick with transparent skins, since it allows the underside of the piezo, that we use to detect drum hits, to show through).

So a trip to Wickes for some plastic pipe, and a quick cutting session on the laser cutter later....

The drum "skin" sits nicely on top of the drum "body" (plastic pipe). But the join is a bit obvious. We need a way to disguise the nasty join. Car automotive chrome strips work nicely...

... until you turn the drum around to reveal the super-glued join (regular glue isn't strong enough to stop the chrome band from un-coiling from around the drum body)

So we tried a different approach - laser cutting some circles to create a 2mm "rim" around the top and bottom of each drum body. The idea being that it creates a recess for the drum skin to sit inside (hiding the nasty join between skin and body) and we can then just place a band of shiny metallic vinyl sticker around each rim to give the illusion of a metal/chrome band

The rim acrylic is 3mm thick, which allows 1.5mm on the body, and 1.5mm to stand proud. The skin HIPS is 1mm thick, so after fitting, the rim should stand slightly proud of the skin

Note how after placing the rim acrylic on the body, a slight recess is created, to accept the (white) drum skin and hide any nasty joins.

We left the backing on some of the rims, just so they would be easier to identify in these photos!

The "plastic circles" approach seems to work quite well, but until we get some chrome banding on, we won't know for sure whether it's a viable option. But it's certainly quick and easy enough to do!

This is the basis for our hi-hat stand.
We've used some off-cut disks from the centre of the rim circles to prove the concept, but for the final design, we're hoping to use something that looks a little more like a real pair of hi-hat cymbals.

As before, the backing has been left on the black acrylic, just to make it easier to see the component parts

The stand is made from two "planes" which create a 3D shape using the traditional "slotted cross" arrangement.

The two "cymbals" need to be separated by some rubber, or perhaps some anti-static packing foam or similar, allowing them to be struck together, just like a real hi-hat would. In the photo below, you can see that there is a gap between the top disk (representing the top cymbal in this example) and the top of the plastic arms used to hold it in place. This gap would be taken up with the introduction of some little rubber stand-offs between the two "cymbals".

This is the layout for the drum rims from a sheet of acrylic.
We tried to reduce the total amount of waste. Cutting out circles with hollow centres is always going to create waste, so where possible we tried to fit one rim inside another. The grey areas below show the parts of the acrylic that will probably end up being wasted - so it's not quite as bad as it could have been!

Friday, 19 August 2011

Understanding synth playback values

A few people have asked how do we read back the values from the key presses on the synth. It's a relatively simple bit-masking process, but at first appears complicated.

The first thing to do is refer to the map of keypress values (above).
Because our inputs are active low as well as recording the value generated when each button is pressed, we've also written down the inverse of this value.

Say, for example, we press the first button on the PCB.
This returns the value 191.
We take the inverse of the value. Strictly speaking, what this means is we convert the value to binary, which gives us 10111111.
The inverse of this is 01000000.
You can get the same result by subtracting the initial value from 255.
So in this case, 255-191=64 (which is 01000000 in binary)

Because each key on the synth activates a unique bit in the binary sequence, any number of keys can be pressed at any one time.
If we press the low C key (first key to the left) and the Eb key (fourth from the left, including "black notes") the PC returns the value 189.

Converting 189 to binary and inverting (or subtracting from 255) and we get 66, which is represented by 01000010

As you can see from the previous example, both binary sequences begin 01.... so whenever the second bit in the binary sequence is one, we know that the low C key has been pressed.

By identifying the values for all the keys, we can plot which bit in each binary sequence represents which key-press on the keyboard. In our PC app, we'll monitor the last known value of these binary sequences to the current one and this will allow us to work out which key has just been pressed (and equally, which key or keys have just been released). With this information, we can trigger and stop sounds playing, to recreate a genuine playable synth.

See - it's nearly working already ;-)

Why the need for plotting all the values? It has been suggested that we should make the first pushbutton go to PORTB.0 (bit 0), the second button go to B.1 (bit 1) and so on, to simplify reading the data back. In fact, this is exactly what we did in the prototype. The beauty of breadboard prototypes is that you can have wires leading everywhere, looping over each other, winding in and out of other wires.
When you come to create a PCB, however, layout is critical. So our push buttons are actually laid out 17,16,1,2,7,8 and so on. While this doesn't make sense to the casuall observer, it's much easier to use a rigid layout pattern, and make allowances for it in firmware/code, than it is to stick rigidly to a set firmware/pinout and try to force your PCB layout to match it!

[edit - 10pm same day]
Here's a short video showing the custom software (note how it detects when the instrument has been plugged in and changes the interface - we really like that subtle little touch!) and a working demonstration of the synth

I need to remember to close the windows when shooting demo videos like this! And maybe turn the telly down a bit too. And, of course, make sure the volume is up on the PC before starting!

You can see on the video that the synth not only supports "key down" type events - i.e. triggers a sample when a key is pressed - but also raises "key up" events too - stopping a sound when you lift your finger off a key, just like a real synth! Chords are played to demonstrate that the miniature synth is truly polyphonic: multiple keys can play at once. I dread to think what it would sound like, but in theory you can press (and the PC will respond to) all 17 keys at the same time. Better than some early casio keyboards even!

Thursday, 18 August 2011

Working miniature synth (nearly)

Despite looking like a complicated instrument, the synth was actually one of the easiest to manufacture and to code the firmware for. In fact, it only took a few hours this afternoon to get a "working" miniature synthesizer!
As ever, the first thing to do was create a PCB with a working PIC microcontroller for the USB/HID interface

The acrylic keys sit over a large, single-piece, PCB.
There are 17 pushbuttons, arranged so that each one sits under the front-most edge of each individual key.

These pushbuttons are routed to the digital input pins on our old friend the 18F2455 PIC microcontroller.

After all our fancy routing and re-naming buttons, pins and ports, we forgot to connect the ground pin of the USB socket to the ground trace on the board! D'oh.

Since we discovered hot air soldering, and how surface mount components can be just as quick and easy as (and sometimes quicker and easier than) through hole components (no pesky drilling) we've decided to stick with the surface mount version of this chip, rather than the earlier favoured through-hole version.

That's all there is to this synth really - we've allowed for a rotary dial/potentiometer on one of the analogue pins, and perhaps a separate pushbutton to switch sustain on and off. But really, it's just a simple PCB with a load of buttons.

We decided to use the PIC's internal pull-up resistors on PORTB, which means that all input pins are high and when a button is pressed, the input goes low. Likewise, we wired the remaining buttons up the same way (high with no input, low when the button is pressed) which means that for 17 keys, we only used 9 pull-up resistors instead of needing one for each button.

The remaining 9 inputs were spread across PORTA and PORTC.
This makes reading the data back a little difficult but not impossible. We use three different byte-sized buffers, to report back the status of every button over USB. PortA is bit-masked by reading the value off the port, and OR-ing with the input pins not used (in our case, only RA1-RA5 are used, so we OR the value on PORTA with 1+64+128 = 193) This is because RA0 is the analogue input (2^0=1) and RA6(2^6=64) and RA7(2^7=128) are not used, so we will always report these bits as high (not pressed) irrspective of their state.

By doing this, we should get a unique combination of numbers on the three buffer bytes, for every combination of key presses. This allows up to 17 keys to be pressed and recognised - a truly polyphonic synthesizer!

To find out which buttons returned which values, we knocked up a simple VB app which reads the first three bytes back from the USB device and displays them on screen.

This photo shows how pressing the first "key" on the keyboard results in byte3 taking the value 191. We went through every single key, pressing each one in turn, and wrote down each of the three byte buffer values. This map of values will form the basis of our playback code.

Because the input pins are high when inactive and low when active (when the button is pressed) we can invert the key buffer values (subtract from 255) to work out which key (or combination of keys) is pressed. When two or more keys are pressed, their values are simply OR-ed together.

For example, if a key with the inverse value 64 is pressed together with one having an inverse value of 4, together with one having the inverse value 1 (when playing a chord or triad, for example), the keyboard input buffer value will simply be 64+4+1=69

By taking the values from each of the three byte buffers, and using simple logic queries (AND/OR) we can easily identify exactly which combination of keys has been pressed at any one time.

Google+ Me+ Plus-Minus

Just a quick post for anyone else still having problems with the Google Plus extension Plus/Minus (sometimes called Me+) for Google Chrome. This brilliant little plug-in lets you collapse already read posts and filter your stream by members of your different circles. I'm surprised that Google hadn't already thought of it when they launched Google+
(what do you mean you don't use Google+ ???)

Anyway, it stopped working yesterday.
I just thought it was my laptop getting crabby from not being shut down properly for a week or so (I always just put it into standby and drop the lid on it between sessions) so rebooted. But still it didn't work.

It turns out that the Google bods have been busy at work, re-writing great chunks of their code, so the plug-in no longer matches the new "improved" DOM model.

Luckily, the answer is simple.
The PlusMinus plug-in creates a little icon in your URL bar.
Right-click on this and select "manage plug ins"

From the list of installed plug-ins, find the PlusMinus entry and expand the developer tab. Then just jab "update" and restart Google Chrome. All should be working again!

Tuesday, 16 August 2011

Miniature playable synth

While waiting for the boards from PCBCart to arrive, we decided to look at other miniature instruments for the range.

Of course we'll need a miniature drum kit, for laying down the beats, and a bass guitar for laying down the grooves, will be more-or-less the same as a guitar (same functionality, maybe a bigger beefier shape). We've already made up a simple drumkit prototype, using some piezos and an existing miniature drumkit bought off eBay.

the gold coloured disks mounted under each drum skin are piezo tranducers, connected to digital inputs on the PIC microcontroller

What we need now is to manufacture the 'kit from scratch, now we've proved that the concept works. That can wait until we're visiting the local hardware store and can investigate the diameter of different plastic tubing! Another instrument we've yet to have a go at is a miniature synthesizer. There's a debate about which style to do first - a Moog, a Roland or a Yamaha Keytar?

At the minute it's not important - we're focussing on the functionality; the enclosure can be designed later! Here are some photos of the early synth development....

Rather than mess about with hinges and moving parts, we've just made the keyboard out of a series of "sprues", connected to a thick bar along the top. The idea is that there should be enough flex in the acrylic to allow the user to press the acrylic keys onto a series of soft-touch tactile push-buttons mounted onto a PCB underneath. These key presses will simply be digital inputs, allowing true polyphonic sound to be achieved.

Our miniature synth will have 17 keys, starting at middle C.
Why seventeen keys and not any other number? I wish I could say it was because of the number of available inputs or some other technical reason, but the truth is we all watched classic 80s synth clips on YouTube and after seeing how to play Axel F decided that 17 was the minimum number of keys required!

Whether the 18F2455 will have enough inputs for what we're trying to do (there will be other buttons such as pedal sustain, LED outputs and so on) or whether we'll need to move up to the bigger 40-pin 18F4550 still remains to be seen.......

Monday, 15 August 2011

PCBCart order is in

We've found making consistently good double-sided PCBs quite difficult of late, especially when we're working with tiny 0.20mm traces (normally we don't go lower than 0.5mm to ensure a good trace even if the etching goes a bit awry).

Having designed the PCBs for both guitar body and neck, we spent some time looking at different providers and suppliers. There are plenty of people on eBay offering PCB manufacture and we've already been in touch with

Matt from BuildBrighton suggested PCBCart and in the time it's taken other PCB manufacturers to respond to an initial request for information, these guys have built gerber files from a simple design, debugged it, confirmed and organised all the silk-screening and solder-masking and submitted the plans for manufacture.

Their response times are amazing.
I was given the task of investigating PCBCart. I posted my order to them at about midnight and went to bed. The next morning there was an email from PCBCart asking to confirm a few things - after I emailed, I got a reply within minutes (not hours or days like other fab-houses) and in less than 30 minutes and a flurry of emails, the boards were ready for production!

I was really impressed with their service and how quickly and keen they were to get everything sorted out. After filling the online quote/order form out (they even accept PayPal) and paying a rather reasonable £140 for 200 pieces, our boards are in production and we hope to have them in about 12 days. If the quality of the manufacture matches their customer support, we should have some fantastic PCBs in less than two weeks - it's taken longer than that for some of the other manufacturers to respond to our initial query.

Hopefully that will be the last piece of the miniature guitar puzzle in place and we can start assembling them for real!

Sunday, 14 August 2011

More laser cutting magic

In a desperate attempt to prove to a friend that our laser cutter (see, no longer the spanky new laser cutter - how long did that take?) is more than just a big "boy's toy" I had to find something useful to make with it.

Unfortunately, a kit of parts for a CNC pick-and-place machine (our next major project) is seen only as yet another "boy's toy" and doesn't count. Neither does anything involving gears, cogs, or PCB enclosures. Clocks only just count, but we've already made one of those, so need to come up with something else. Something that appeals to non-nerdy people.....

Here's what I came up with.
Funky vibrant herb markers.

No seriously, a range of herb markers in bright funky colours.
Not only do they brighten up the garden (useful if you're a crap gardener and all your flowers die off early) and serve a useful function (telling you what should be in place of that patch of bare soil) they're frost resistant and easy-wipe clean. The perfect "gardening solution".

The problem, of course, in designing the entire set of six in one laser cutting dxf file, is I've now got a spare five sets in various colours. And a whole load of little tiny acrylic letters! Look out for "funky vibrant herb markers" on eBay soon!

Saturday, 13 August 2011

Soldering 0.025" pitch cable

Our miniature guitar project uses a double-sided PCB for the fretboard which needs to be connected to the main board using a ribbon cable. We've tried "regular" IDE cable, but had trouble with the multi-stranded cores (they spread during soldering and can bridge with the wires/pads next to them).

Also, using 0.5" pitch IDE cable, the base of the neck-PCB needs to be quite wide to accommodate all the pads. Then we discovered some 0.025" pitch, solid core ribbon cable which seems perfect for the job.

Except, of course, that it's an absolute nightmare to work with.
Just look at how small this strip of 8-way cable is!

Although we have managed to make some workable guitars, each one took a loooong time to complete, and wouldn't be suitable for making on a regular basis. We've pretty much got assembling of the SMT boards down to quite a quick and simple method, using the solder-paste-and-hot-gun approach of assembly. Although fiddly, it's much quicker than using through-hole components.

We're still looking for a quick and simple way to connect our guitar's "body" and "neck" PCBs together. If there's any way we can quickly and repeatably solder this tiny cable to the PCB edge connectors, the electronic design will be complete, and we can put an order in with either or maybe PCBCart

We made up some test boards, to practice using different techniques for soldering the ribbon cable to the edge connectors. These boards don't actually do anything but allow us to practice connecting ribbon cables

With previous attempts at soldering this tiny pitch cable, we've had problems with it moving around as the solder paste melts and pulls the cable cores onto the traces. Holding or taping the cable to the bench causes it to lift up at the end touching the PCB which makes soldering particularly different. So before soldering, we prepare each ribbon cable:

the tiny bit of cable that will be connected to the board is trapped under a spare piece of PCB/copper clad board

After stripping and trapping one end of the ribbon cable, the remainder is bent vertically upwards and pinched between a second board to make a sharp crease...

...then bent along a second piece of board, away from the trapped end

The result is a "kink" in the cable, which allows it to lie flat along the bench, while the exposed fingers of wire sit perfectly along the PCB edge

Those horrible dirty fingernails are because they've been scraping solder paste off the kitchen table before anyone else noticed!

Using a small soldering iron we managed to solder an example bit of ribbon cable by applying solder paste onto the board and heating it with the soldering iron tip. The result was a technique that worked, but was very fiddly and difficult to do well. The solder paste bridged across the traces and was difficult to remove. Touching the soldering iron between the traces did remove the bridging, but in a lot of cases, also disturbed the other cores and bent them so they went out of alignment with the traces on the board.

So we prepared the board to try the hot air gun method of soldering

This was less successful than the first attempt!
The hot air caused the cable casing to melt. As the plastic melted, it caused the cable to buckle and lift off the PCB edge. With a bit of re-working, we got this bit of ribbon cable connected, but it too was tricky to achieve.

The final method of soldering was the "traditional" approach and worked the best of all (the latest cable is the one on the right with hardly any solder visible). This involved tinning the solid-core strands, placing them onto the PCB traces, then lightly touching each with a soldering iron tip. In this case, a larger tip works well as it joins two or three cores at a time.

The end result is a cable that is attached with very little excess solder and no chance of bridging. Soldering is as simple as holding the tip in place for a second or two. It's by far the easiest method so far for connecting the ribbon cable to the PCB.

The only downside is the preparation of the ribbon cable and tinning the individual strands. Using even a small soldering iron tip, this was fiddly and it took a few goes to get all strands tinned without any bridging between cores.

One solution may be to use a "solder pot" for tinning the wires.

Videos on YouTube suggest this may be the case:

So now we've got a solder pot on order from It'll be a few weeks before it arrives, but with a bit of luck, we'll be able to quickly tin/solder all 13 cores with a single dip - the plan being to batch-prepare a load of ribbon connectors and tin them all in one sitting. The solder takes about 10 minutes to heat up to a usable temperature so we don't want to be doing this for just one cable at a time!