Friday, 27 July 2012

Weaving loom

While away on holiday recently (hence the lack of updates for a while) and with no internet access for a few days (can you believe there are places still where there's no such thing as 24-hour on-demand internet access?!) I found a simple but absorbing time-filler: a child's toy weaving loom

It's really simple to use, consisting of just a wooden frame, a needle and a dolly for raising/lowering alternate weft strings and some wool. Straight out of the box, you simply thread the weft (white) wool up and down the frame, then slide the dolly between the strings and separate them into the little notched grooves.

This causes each string to be raised and lowered alternately. By turning the dolly a quarter-turn backwards and forwards causes the strings to raise and lower. In this example we turn the dolly a quarter turn towards the left....

.... and the string nearest to us moves from the raised to the lowered position. This happens to every other weft string.

By passing the needle, loaded with coloured wool, between the strings then raising/lowering them between each pass, a simple weave pattern quickly starts to form:

Because the loom came with rather chunky, springy wool, rather than thinner cotton or embroidery silks, the weft strings (white vertical strings) disappear into the final weaved piece as the rows start to build up.

This simple loom is just crying out to be automated, but just exactly how we're not sure.
A stepper motor or servo would be ideal for turning the dolly to raise/lower the strings, and the needle could be passed back and forth using a combination of motorised arms and pulleys but we need to get familiar with the actual act of weaving before trying to build a machine to do the hard work. Adding second (and maybe even third) colours to make an image or pattern would also be pretty cool. Yet another project to add to our ever-increasing list of things started-but-not-yet-finished!

Thursday, 12 July 2012

How a shift register works

This was a quick-and-dirty project just to understand how our shift registers from Farnell work. The block diagram on the datasheet makes things pretty simple, but we still need to make sure we're toggling the right lines to "flush" the data into the device:

From this block diagram, we can see that any data clocked into the shift register is held in a buffer, and only transferred onto the output pins when the RCK line is toggled (in this case, according to the "truth table" from low to high)

So we built a quick usb device (for getting data quickly from our PC to the end device) using a PIC 18F255 microcontroller and used it to clock data in/out of the shift register. The PIC was connected to our SMT LED breakout board as follows:

PORTB.5 -> serial clock in (SCLK)
PORTB.4 -> register clock (RCLK)
PORTB.3 -> serial data in (SI)

The layout/PDF for the breakout board is here:
SOIC-to-DIP breakout With Leds (for shift register)

(don't forget that this is for SMT components, not through-hole, so the final etched board will be mirrored. That's why PIN1 is marked on the top right, not top left, and Vcc- pin16 - is top left. You'll need to use your imagination to "flip" this and get the pins in the right place!)

A shift register is quite easy to work with, but until you actually get your hands on one and make it work, it can be difficult to fully appreciate what's needed. A shift register can be used in a variety of ways, you can tie the clock lines together (to save pins) but that only adds to the complexity. You can daisy-chain the registers, by enabling the output line and have one SR feed the next in a chain and so on.

We're going to concentrate on simply getting serial data into the device, and displaying it on a sequence of LEDs. This project will form the basis for future projects by reducing the pin-count needed to individually control lots of separate LEDs. Having learned from the word clock in November, we're sticking to surface mount LEDs this time - no way are we going to be spending hours and hours drilling hundreds of holes again!

(this board was made up with solder paste and a cheap nasty "fire-starter" soldering iron from Farnell. Hence the scorched traces and missing pin header where the connect-to-ground jumper burned away and had to be fixed with a bit of spare wire!)

With the shift register hooked up to the PIC microcontroller, we dropped some simple code onto the PIC and wrote a quick VB app to send data to the PIC. The PIC simply takes a single byte value and sends it to the shift register in the following sequence:

Here's the Oshonsoft Basic code for our PIC:
Define CONFIG1L = 0x24
Define CONFIG1H = 0x0c
Define CONFIG2L = 0x38
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x03
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

UsbSetVendorId 0x1234
UsbSetProductId 0x1234
UsbSetVersionNumber 0x1122
UsbSetManufacturerString "Nerd Club"
UsbSetProductString "Generic USB HID Device"
UsbSetSerialNumberString "1111111111"
UsbOnIoInGosub input_report_before_sending
UsbOnIoOutGosub output_report_received
UsbOnFtInGosub feature_report_before_sending
UsbOnFtOutGosub feature_report_received

Dim i As Byte
Dim pattern As Byte

Symbol rclk = PORTB.4
Symbol sclk = PORTB.5
Symbol si = PORTB.3

i = 0
pattern = 255


     If i = 0 Then
          Gosub senddata
          i = 1
Goto loop


     'prepare the shift register "flush" pin
     Low rclk

     'send data to the shift register
     If pattern.0 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.1 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.2 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.3 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.4 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.5 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.6 = 1 Then High si Else Low si
     Gosub toggleserialclock

     If pattern.7 = 1 Then High si Else Low si
     Gosub toggleserialclock
     'flush the shift data onto the output pins
     High rclk


     Low sclk
     WaitUs 50
     High sclk



     pattern = UsbIoBuffer(0)
     Gosub senddata


The idea is that we'll send a byte value to our PIC controller board (via usb) which it will then clock into the shift register. It's important to note that we've only used six of the possible eight output pins on the shift register. So the first and last bits (mapped to pins 7 and 15 on the shift register) aren't actually connected to an LED. Any data value sent will be displayed as X 1 1 1 1 1 1 X

To see this in action, we can send the byte value 47 to the PIC.
In binary, this is represented by 0 0 1 0 1 1 1 1
Since our board is ignoring the first and last bits (why didn't we just connect them up to make explaining this a bit easier?!) this gives the LED lighting sequence X 0 1 0 1 1 1 X

Instead of just typing random numbers, converting to binary and comparing the results, we built a simple VB app to generate a byte value and send it to the PIC microcontroller:

Although focus isn't brilliant you should be able to see that by clicking the onscreen LEDs, the VB app is generating a byte value (from a binary representation of the LED states). This value is sent to the PIC, which turns the byte value back into a series of bits, which are then transmitted to the shift register, one bit at a time.

We set the value of the serial input line to match the value of the first "bit" in our byte value (either on/high or off/low) then toggle the serial clock line. This pushes the first bit into the shift register. When then set the serial line to match the second bit (either on/high or off/low) and toggle the serial clock line again. This pushes the first bit along Ishifts it) and pushes the second bit into the register.
After doing this eight times, our shift register contains the byte value we sent over a single serial data line. To get the value to display by lighting our LEDs, we need a low-to-high transistion on the RCLK pin. Until this pin goes high, the data sent to the shift register sits in the "top part" and doesn't actually affect the output pins. When the RCLK pin goes high, the value in the shift part of the register is "flushed" into the latching register which controls the output pins QA-QH (and the sequence of LEDs changes)

Btw - it turns out that we did indeed mount the shift registers the correct way around on our little breakout board, despite not finding a pin1 marker on the casing. If anyone else is using these 74HC595 SOIC shift registers, they should be mounted, rotated 90 degrees to the right and pin1 is the top-left-most pin as per the datasheet!

Wednesday, 11 July 2012

SOIC/SOP to DIP breakout board

We recently bought some shift registers from Farnell but being SMT they're not easy to use on a breadboard /prototyping system so we knocked up a simple breakout board for them. These boards should suffice for any SOIC device, to make it suitable for plugging into a breadboard.

Interestingly, the parts are listed as SOP-sized but in ExpressPCB there were no component layouts for SOP. We chose SOIC instead and the layout was a perfect match. So is SOP and SOIC the same layout? The jury's still out on that one.

In the meantime, here's our breakout board layout.
Don't forget to download and print from Adobe Acrobat Reader, not directly from Google Chrome!

Soic Breakout 16 Pin

Tuesday, 10 July 2012

Just one of those nights

Tonight was just one of those nights where nothing seemed to go right.
First off, our "quick-and-dirty" PCB took far longer than we'd hoped, given that it didn't print properly in the first place.

Then we tried adding a dial of numbers to our petanque score keeping device. NewlyDraw lets you print and "scan" (engrave) from a single file, so we added an engrave layer to our cutouts and set the laser going.
The etching looked lovely as the head whizzed backwards and forwards, but when it came to cutting, things didn't look quite right:

For whatever reason, the etching and the cutting just didn't line up (yet looked perfect onscreen!)
Undeterred, we decided to try out some paint-filling ideas to make the numbers really stand out. A few CNC forums suggest simply using acrylic paint to fill the engraving, and wipe off with a damp cloth. It didn't really work for us!

We tried wiping the etching both while the paint was still wet, and after it had dried. The results were noticably different, with wiping once dried giving a better result (but still not brilliant)

(Numbers 5 and 6 were filled, left to dry, then wiped clean. Then other numbers were wiped while the paint was still wet on the surface)

So neither the etching, cutting nor painting was much of a success.
Our earlier PCB making was only partially successful, but, determined to salvage something from tonight, we soldiered on to make a test board.

We bought some shift registers from Farnell last night (ordered 7pm last night, arrived 2pm this afternoon - amazing service!) for another large LED-based project. The breakout board was supposed to be a quick-and-dirty way of testing out how they worked. So we added some surface mount LEDs to pins 1-6 and mounted a 74HC595 register on the board.

The only trouble was, we can't find the "pin one" marker on the casing. Normally IC chips have a dot in one top left corner, to indicate which pin is pin one. But this time, we couldn't see one!

So we've just mounted one and hoped for the best.
Now we need to get it hooked up to a microcontroller and see if we can get those LEDs to light up. If they do, we know we've got it right. The problem comes if they don't.
Is it due to a dodgy connection, some badly written PIC code, mis-understanding how the shift register works, or has the IC been mounted the wrong way around?

There's only one way to find out - but it's almost midnight now and there's little time left to go digging about looking for that PIC programmer.....

Don't print PDFs from Google Chrome!

It's frustrating but for the second time, we've ended up with some etched circuit boards that are too small. The first time was back in November last year, when making our LED charlie-plexed matrix and we couldn't work out back then what had gone wrong.

Here's a quick rundown of how we etch our boards:
Firstly, draw the schematic in ExpressPCB then transfer the design onto their PCB layout software.

Then print the PCB layout but instead of sending it to a printer, direct it to CutePDF virtual printer. This creates a full-scale PDF file which can be uploaded, emailed and generally shared around the place.

That's how we create all our circuit boards, generating PDFs then emailing them to our machine that's connected to a big Xerox Phaser for printing onto press-n-peel.

 Tonight we wanted to knock up a quick SOIC-to-DIP breakout board. Then as an after-thought, we added some LEDs to one side of the board. As always, create PDF then email to the printer machine.

But this time, the circuit board came out about 90%-95% of full size. Notice how the pins "fan out" as they aren't properly lined up with the PCB. The holes on the board are closer together than the 0.1" pitch of the pin headers. Yet in the PDF file, the holes are exactly 0.1" apart.

Now the only difference we can see between our "normal" method of creating PCBs and what we did tonight is that instead of downloading the file to our library, opening with Adobe PDF reader and printing from there, we just clicked the link in the web-mail and the PDF opened in Google Chrome.

Which leads us to the conclusion that the PDF viewer in Google Chrome (or at least the printer support in it) is a bit flaky. In fact, we've never been impressed by Google Chrome's print preview (it used to get confused when the printer default layout was landscape) but in recent months it's got better. Or, perhaps after tonight, we can only conclude that it hasn't!

In short, always download your PDF layouts and print from Adobe's Acrobat Reader to make sure your circuit boards are printed at 100% scale.

Monday, 9 July 2012

Petanque score-keeping device

Many years ago, back on the old Nerd Club blog, we were playing about with Nokia phone screens and invented a digital score-keeping device. Originally it was a petanque score-keeper then morphed into two or three other things!

While over at the nerd cupboard last night, we were showing how the laser cutter works to a couple of friends from the local petanque club. Keen to demonstrate everything from design and drawing, importing into Newly Draw (the software that drives our LS3020 laser machine from HPC) and cutting, we came up with a simple, one-hour project: a petanque score-keeping device

It's basically two wheels spinning freely behind two cut-out windows. Each wheel still needs a sticker with the numbers 0 to 13 putting on it. We did think of engraving the numbers directly onto each wheel but they might not be easily readable when out on the terrain. 

The wheels will be held in place by a couple of tiny M3 bolts. Since the whole assembly will be glued together, there's no real need for a nut on the back (although reviewing the photos, that also means there was no need for us to cut a through-hole in the back of the device either!)

When made up, each device is about 8cm across and 3.5cm high. The perfect size for carrying around in your pocket, during a game of boules!

For anyone wanting to make one, here are the layout files:

Petanque score keeping device

MIDI bass ideas update

So far, we've bee concentrating on reading the neck of our MIDI bass, by running a resistor ladder up the fingerboard, and shorting one end to ground to read which string is pressing against which fret.

This video popped up on Google+ this morning - it's a follow-up to Jeri Ellsworth's C64 bass video taken at the MakerFaire earlier this year.

We haven't really invested a lot of time into reading when each string is actually plucked, but this video has a great idea in it - simply put a custom shaped piezo in contact between each string and the bridge. It's so simple, it's genius!

Saturday, 7 July 2012

Scalexercise - it works!

Here's Other Chris and Mike at BuildBrighton Hackspace, testing the Scalexercise racing cars for the Dublin Mini MakerFaire. A few tweaks here and there may be needed for the final version, but as a proof-of-concept, it's looking really exciting. Pedal faster and the car zooms around the track.

Tuesday, 3 July 2012

Scalexercise track at BuildBrighton

Down at the BuildBrighton hackspace, some exciting developments are coming along with the scalectrix/scalexercise project; not least of all the most amazing track layout ever seen.

Matt and Mike have long had an affinity with Kenex - it's great to see some "old technology" being brought back to life for something new and interesting!

Monday, 2 July 2012

CNC drilling maching platforms

After the problems we'd had with our laser cutter, we weren't sure if we'd manage to get these done tonight. But after finding (and solving) the problem, we were up and cutting again in no time.

We couldn't decide whether to use a smaller gear for our stepper motor (for precision) or a larger one (for speed). Since our steppers are 1/64 (64 steps per full revolution) we went for 16 teeth on our gears. The smaller gear has a tooth size of 2mm, the larger one is 4mm.

Here's the platform for our cnc drilling machine.
Note that the mounting holes for the rails are slightly off. This is because we accidentally moved the sheet when trying to find out why the laser cutter wasn't behaving properly. For the final version, we'll cut this again, but it'll do for a first-trial-run. 

The platform has a rack-style gear along the long edge. On one edge we made the tooth size 4mm, on the other 2mm. This means we can try our larger/smaller gears by simply fitting the appropriate head on the stepper and flipping this platform over.

At these tiny sizes, the slight "kerf" along the cut edge of the acrylic becomes noticable. Whichever way the kerf on the geared head is, we try to mount the platform the other way up, so that the gears mesh as closely as possible.

One full revolution of the stepper takes 64 steps. One full revolution causes 16 teeth to pass along the rack gear. By our calculations, this means that with a head with 16 teeth of 4mm, 4 steps are needed to travel 4mm - or one step is one mm. This should make moving the platform nice and quick, but whether or not this gives us the level of precision we require is still yet to be seen. If we need more precision, we can always fit the 2mm-tooth head, and this should get our precision to 0.5mm (one revolution = 64 steps = 16 teeth at 2mm = 32mm travel so one step = 0.5mm)

If it turns out we need more precision that this, we'll have to consider some kind of belt or threaded-rod type drive.

In the meantime, here's how the 2mm head and rack line up

While flipping the black piece over and replacing the small gear with a larger, 4mm-toothed head looks like this 

The rails will simply bolt onto the base piece of acrylic. We measured the spacing between the mounting holes on the rails and transferred these onto the plastic. We'll take a trip down to The Nut & Bolt Store in Hove tomorrow, and reinforce the join with plenty of hot glue

(note the slots cut into the base, running at ninety degrees to the rails. These are for a base "plinth" to be added, so allow the height of the base and sliding platform to be raised, so ensure a good mesh between the edge of the moving platform and the gear mounted on top of the stepper motor)

Here's how the final assembly would look when all glued and bolted together:

Laser cutter LS3020 performing badly

While making some test pieces for our CNC drilling machine, we had a few problems with the laser cutter. It was nothing serious, except the cutter seemed to be losing power when cutting anything more than a simple few circles. We slowed the speed down from 20mm/sec to 10mm/sec and ramped up the power dial from 15mA to 20mA but to no avail - even making two passes didn't slice through a 3mm acrylic sheet.

The first thing that came to mind was mis-aligned mirrors. Unless the laser beam is correctly focussed, cutting power is only a fraction of maximum. But re-aligning mirrors is a real pain to get right - so before we messed about with that, we thought we'd give the old "turn-it-off-and-turn-it-on-again" approach a go.

Whenever we start using our laser cutter, the first thing we do is check for air bubbles in the laser tube.
Cutting with an air bubble can cause the tube to overheat and eventually crack or rupture. This is one thing we're quite paranoid about, so we always make sure there are no bubbles in the tube before starting!

A quick inspection of the tube and we found the problem.
There was a massive air bubble in the tube. But how did that get there?
It seems that our run-silent aquarium pump (supplied with the cutter to provide cooling water) wasn't in fact running.

To avoid getting bubbles in our water, we keep both the pump and the return pipe from the cutter fully submerged in water. This is great when everything is working - but when the pump stops running, there's no immediate indicator that the water isn't getting pumped round the laser tube.

Overheating (or cooling water that's got too warm) is another cause for power loss with a laser cutter. And that's exactly what was happening here. The laser tube wasn't getting any cooling water, and so just getting hotter and hotter!

We left the cutter switched off for about half an hour, then got the water pump up and running again (we didn't do it straight away, in case quickly cooling the glass laser tube caused it to crack). After leaving it for a few minutes, and checking that there were no more air bubbles in the glass tube, we fired up the laser.

It was soon cutting 3mm acrylic at 20mm/sec as usual as if nothing had ever gone wrong!
So just a word of warning to anyone suffering from poor performance - check your tube! We were lucky this time - an overheating tube can easily crack if you continue cutting with it;
it looks like we caught ours just in time. But we know to check our water pump is working, as well as getting rid of any and all air bubbles in the tube from time to time.