Skip navigation

Arduino Magstripe Library

  • 2013-02-07 – 4:39 am
  • Posted in Hackerspaces
  • Comments (2)

So recently I’ve been playing around a lot with Arduinos.  Specifically I’ve been trying to get a cheap little magstripe reader identified as a V3B-K.

spacer spacer

 

Googling for the ID I found a few data sheets, but none gave the actual pin out by colour and purpose.  Thankfully a friend provided the decoding:

  • Green = Ground
  • Yellow = +5V DC
  • Orange = Data ready
  • Red = Clock
  • Brown = Data value

…and some code dug up from the web, originally credited to Stephen King.  No additional components were required to connect the magstripe reader to the arduino… I just plugged green into the ground, Yellow to 5V, Orange, Red and Brown to pins 4, 3 and 2 as per the comments in the source code I received.

The magstripe worked, but was not completely reliable. Swiping a card very, or jigging it around while reading would cause the arduino to start reading the wrong card value until the Arduino was reset, or simply make it hang. In addition, the code I had was all in a single sketch file and not very pretty.

I decided the fix this, and to move the code into a nice easy-to-use library.  The problem turned out to be a buffer overflow.  Simple bounds checking solved the problem.

The library code can be found in my Arduino Github Repository.  *edit* Also, Doxygen generated library documentation *edit*

Example usage with a watchdog timer to add extra robustness:

#include <Magstripe.h>
#include <Arduino.h>
#include <avr/wdt.h>    // watchdog timer

void setup()
{
  Serial.begin(9600); 

  // arguments are data-read, clock and data pin 
  msInit(4,3,2);
}

void loop()
{
  if (msReadCard() == MS_READ_OK) {
    Serial.print("Read card data: ");
    Serial.println(msFetchLastCard());
  }

}

Lasercut coat of arms

  • 2012-11-10 – 4:46 pm
  • Posted in Uncategorized
  • Leave a Comment

Here are a few pics from my latest laser project: a coat of arms for my new house.  The four designs on the escutcheon relate to the house in some way or other.

 

A short explanation of the design: the supporters are in honour of the house cat, Ella Deathstar. The four designs on the escutcheon are:

  • A bicycle (the house is full of environmentally minded cyclists)
  • A volcano (the house number is 16, and 16 is the atomic number for Sulphur.  Also, volcanos are amazing)
  • A tree (atomic mass of oxygen is ~16, and trees are cool, and the design works)
  • A chess pawn (there are 16 chess pawns in a game of chess, and housemate Phil is a chess fan)

The motto reads: Ita erat quando hic adveni, which means “It was like that when I got here”, which is pretty fitting for the house  :-)

The process was fairly straight forward:

  1. Research the number 16 for interesting relevant things which could be represented with a nice image
  2. Collect, create , vectorize artwork – I used the threshold feature of GIMP, and then imported bitmaps into Inkscape and used the trace bitmap feature to create a vector, followed by some manual tweaking
  3. Do some test cuts to make sure designs would work well in wood, and to see what they looked like.  I made these into drinks coasters
  4. Arrange the full coat of arms – creation of the escutcheon parts, scroll, motto and overall positioning of the various parts
  5. Cut it on the laser.  I used a single A4-ish piece of 3mm laser ply, and took the outline and cut a piece of laser MDF for the backing
  6. Careful sanding.
  7. Work out which pieces should take which colors.  I did some test stains on ply scraps first to find the right stains
  8. Stain those bits
  9. Glue to backing

It took me quite a long time to settle on the figures for the escutcheon. Turns out the number 16 doesn’t have all that many things associated with it which were suitable for the character of the house and it’s occupants. I pondered an Atari logo (in honour of the 16-bit era and the Atari ST), but a corporate logo seemed wrong somehow.  I like the tree design the best. When pulling out the cut from the ply it looks amazing. It makes a super drinks coaster.

Once the design was settled, it took a total of about an hour and a half to cut the wood (including file prep, setting up the laser and so on), and about six hours in total labour to sand, stain and glue the work, plus a fair bit of stain and glue drying time.

Lasercut pendulum clock prototype

  • 2012-09-27 – 11:12 am
  • Posted in Art, Hackerspaces
  • Leave a Comment

The last few times I’ve been geeking about at Nottinghack I’ve been playing around with the idea of making a pendulum clock. This came about because I once started, but never finished making a clock out of paper. The paper clock is a really nice project, but there is a lot of very fiddly cutting out of card with a craft knife and gluing together which is very fiddly and time consuming.

To my mind, the obvious solution to this tedious labour was to spend five times as much time and effort adapting the paper clock design so that it could be constructed from ply wood using the laser cutter at the space. Anyways. Pictures.

spacer

spacer

spacer

spacer

spacer

spacer

spacer

spacer

spacer

spacer

spacer

That’s as far as I’ve got so far. The escapement (spikey wheel and weird shaped bit at top) needs refinement – at the moment it does not provide enough of a push to the pendulum to keep it going for long. I think the problem is down to a few factors:

  1. Too much friction in pendulum & escapement rocker
  2. No enough force delivered to escapement wheel. The drive mass might need a wider spindle, and I could do with reducing the friction in the whole drive train. I think there is also some room for improvement in the gear configuration
  3. Escapement wheel teeth and rocker shape needs refinement. I did no serious kerf compensation when cutting these parts, and with the fine angle on the escapement wheel teeth it might make quite a difference.

There remain a few challenges before I have a working prototype – refinement of the escapement, devising an hour hand mechanism. The escapement poses the biggest challenge. Fun to be had in the coming clock-making sessions.

Oh, here’s a short video of it “working”:

MITx 6002x Finished

  • 2012-06-12 – 1:23 am
  • Posted in Hackerspaces, Misc
  • Comments (1)

Yesterday I completed the MITx 6002x course: Circuits and Electronics. It’s been several months of hard work. I’ve learned a lot and done my fair share of head-scratching along the way. Now that it’s over and done with I thought I’d write up some of my feelings on the course content and mechanisms.

Background

In October 2002 MIT joined with a few other universities in publishing course content publicly. The initiative entitled OpenCourseWare includes videos of lectures and other course materials published under a creative commons license. Since then many large institutions have joined in and there is now a plethora of high-quality higher education materials available for anyone with an Internet connection with sufficient interest to get stuck in.

2012 heralded the beginning of an ambitious new phase for open education. MIT and a few other universities started running interactive (graded) courses based on their regular syllabuses. Entitled MITx, the MIT offering started with the pilot course 6002x – Circuits and Electronics – an online version of the similarly named regular MIT course 6002. MITx extends the idea of OpenCourseWare, adding a lot of structure and functionality which was not previously available.

Something like 120,000 people signed up for 6002x.

Course Content

The course materials are released in weekly chunks. Lectures are delivered in sequences of short (typically 5-10 minute) videos interspersed with interactive question pages. The lecture videos are mostly whiteboard content with an audio track and closed-caption / subtitle like transcription scrolling by at the side. Question pages require answers to be entered which are typically numerical or text-formatted formulae. Marking of answers is done with the click of a button. For illustrative questions which are interspersed with lecture sequences there is also a “show answer” button. The marking engine works very well – just enough tolerance so it’s not annoyingly picky.

At the end of each week is a set of homework questions, and one of more “lab” assignments. Labs are exercises in a surprisingly sophisticated circuit simulator which runs in the browser. The homework questions and labs contribute to the final grade. From the release of a week’s material, the student has two weeks to finish the lab(s) and homework questions. After this deadline, any incomplete questions or labs are marked zero. Each week there is also a set of optional (ungraded) tutorial videos which are typically worked examples from the text book.

When questions are hard (as they sometimes are), support is available through the discussion forums, whose format will be familiar to anyone who has used on the of the many “Questions” like sites on the net. There is also a wiki and IRC channel.

There are two exams – a mid-term and final. These constitute the bulk of the marks for the course. The exams themselves are in the same format as the homework questions with the following small changes:

  1. Exams are available for several days – the final was available to be taken from June 6th until June 11th
  2. One started, the student has 24 hours to complete the exam
  3. No conferring /collaboration is allowed
  4. For each question (with groups of 2 to 10 answers), the “check” button only works three times.

With the exam being open-book, running for 24 hours and providing the ability to check answers immediately makes it somewhat easier than it might be in a more traditional environment. The ability to check answers a few times is necessitated by the slightly clunky method of entering algebraic expressions where an answer requires them – it’s very easy to make a typo, get a parenthesis in the wrong place or mess up the case of an identifier.

However, even with this flexibility, it’s no cakewalk. The teaching staff stated that they expect the final exam to take about 3 hours, but for me it was longer. Way longer. I struggled for 12 solid hours before I felt I’d done enough!

My 6002x Experience

When I heard about this course, my mental to-do list already included an item to “learn more about electronics”. Last year I got myself an Arduino board, and although I am comfortable coding for it, I don’t know very well how to attach hardware to it to make my embedded programs reach into the physical world and do stuff. The course seemed to be a pretty good starting point to explore electronics and I was interested in participating in the pilot.

Overall I think the course was excellent. The website works amazingly well. Props to the coders who put it together. The content is also excellent. Professor Anant Agarwal, who presents the majority of the material in the course is an engaging and entertaining teacher. The topics covered were pretty much what I’d hoped for.

At times it was challenging and for me personally some of the mathematics was a struggle. This is not to say that the course uses very difficult techniques – the level is something like UK A-level / US high-school. There’s a bit of calculus and some imaginary numbers to contend with but nothing which an undergraduate in an engineering discipline shouldn’t be able to handle. I found it hard going because I hadn’t re-arranged an equation in the last 15 years and it turns out that if I don’t practice such things, I utterly forget them.

One word of caution – the course takes a lot of time. It is suggested to set aside 10 hours a week for 6002x, but for me it was more like 15-20 (partly because I had to re-learn chunks of A-level maths as I went, but also because I’m old and slow – my brain just doesn’t absorb material as fast as it used to). About two thirds the way through I was ready to give up because of the time it was taking. At a couple of points all that kept me going was sheer bloody-mindedness and a refusal to give up. Now that it’s over I have to admit it’s something of a relief. I’m pleased with myself for sticking it out, and I’ve learned a lot of things which I hope will prove useful for making fun little gizmos.

If you’re interested in taking this course or a similar one, I recommend to find / create a local study group. An excellent place to do that would be your local hackerspace. I didn’t know anyone locally who was doing the course, and I really missed having someone to call up and whine at when I got stuck. The discussion forums alleviated the problem somewhat, but it would have been very nice to have a local group of people to encourage each other and study with.

Is 6002x For Hackers?

Being online, 6002x is entirely theoretical. If you’re looking to get your hands dirty and start melting solder 6002x is probably not for you (although there is a great soldering techniques tutorial at the end of the course which is a kind of “bonus material” item).

However, if you want to develop some fundamental electronic engineering knowledge as a basis for understanding your projects better, and perhaps even to help you start to design your own projects, 6002x is a good course. I gather that in future there will be other MITx EE offerings which will go into specific topics in more depth. 6002x is enjoyable if you’re academically minded – solving electronic circuits is pretty good fun if you like logic problems. It’s also a very good way to brush up on your mathematics. Also, if you don’t do 6002x you will probably never find out about the device called the “expodweeb”.

More Info

  • The weekly class plan includes subject titles.
  • Since 6002x started running, MIT make a joint announcement with Harvard that they intend to use the MITx platform for a joint effort which they are calling EdX. It looks like they will be offering a wide range of courses in a format similar to 6002x. So what are you waiting for? Get learning!

Cloe’s Dental X-ray Pendants

  • 2012-05-27 – 2:00 am
  • Posted in Uncategorized
  • Leave a Comment

Neat and completely unique jewelry made by the lovely Cloe.

Valentine Baking

  • 2012-02-14 – 9:23 am
  • Posted in Uncategorized
  • Comments (4)

spacer

spacer

spacer

Crumpet Making Algorithm (US units)

  • 2012-01-12 – 11:00 pm
  • Posted in Uncategorized
  • Leave a Comment

Outputs approximately ten crumpets.

Required Resources

9/8 cups lukewarm water
1 cup unbleached white bread flour
3/4 cup unbleached all purpose flour
2 tablespoons gluten flour
3/4 teaspoon cream of tartar
1 teaspoon active dry yeast
1/2 teaspoon sugar
3/4 teaspoon salt
1/2 teaspoon baking soda
1/3 cup lukewarm milk
Cooking lube (spray oil works well good)

Apparatus

Griddle or frying pan with a nice flat bottom
Crumpet rings, diameter ~3.5″ (or Rosti rings or similar)
Two forks with narrow inter-tine distance
Wire cooling rack

Method

Batter Prep:

Warm 9/8 cup of water in a jug to about 110 F. Add one teaspoon dried yeast and 1/2 teaspoon sugar, stand in a warm place for ~10 minutes until a frothy head has formed.

Into a large mixing bowl, sift: 1 cup unbleached white bread flour, 3/4 cup unbleached all purpose flour, 2 tablespoons of gluten flour and 3/4 teaspoon cream of tartar.

Pour the yeast mixture into the flour and beat for four minutes. The result should be a thick, smooth batter.

Cover the bowl with a teatowel and let it stand in a warm spot until the batter rises and then falls, (about 1 hour).

Add 3/4 teaspoon salt and beat the batter for about 1 minute. Then cover the bowl and let stand in a warm spot for 15 to 20 minutes, so the batter can rest.

Dissolve 1/2 teaspoon baking soda in 1/3 cup lukewarm milk, and then gently stir into the batter.

GO TO Test Crumpet.

Test Crumpet:

Grease up a crumpet ring and the frying pan and put over a moderate heat for a few miutes. The temperature should be just before the smoke point for cooking spray.

Pour ~1/3″ depth of batter into the crumpet ring. If the temerature is correct it should sizzle just a little.

If the batter if too thin it will run ooze out from under the crumpet ring. If this happens, GO TO “Thicken The Batter”.

As the batter cooks, bubbles should form and rise to the surface. As the batter firms, the bubbles form the holes in the crumpet. The batter will firm from the outside of the crumpet towards the middle, which should take between three and five minutes. When the middle is firm, use the forks to remove the crumpet ring, and turn the crumpet over. If holes did not form properly, the batter might be too thick. GO TO “Thin The Batter”.

Cook the inverted crumpet until the holey side is chestnut brown, and then place on a cooking rack. GO TO “Cook Batch”.

Thicken The Batter:

Work a little all-purpose flour in to the batter, then GO TO “Test Crumpet”.

Thin The Batter:

Add a tablespoon of lukewarm water to the batter and gently mix. GO TO “Test Crumpet”.

Cook Batch:

Grease up all the crumpet rings you have / can fit in your pan. Heat and then pour 1.3″ depth batter into each ring. Cook until firm in the centre, invert and cook until chestnut brown. Place on cooling rack.

IF (batter not exhausted) GO TO Cook Batch ELSE GO TO Eat Crumpets.

Eat Crumpets:

This recipe creates moist, doughy crumpets. Before eating, the should be well toasted and liberally buttered.

Optimal toasting is done under the grill (broil mode of oven) on a medium temperature: cook underside first until it’s slightly crispy to the touch, invert and toast the top until it browns a little.

Alternatively, crumpets may be toasted in an electric toaster, toasted twice for a short-ish time with a minute or two’s cool-down time between toastings. This will help reduce the moisture content of the crumpet. If it’s still all doughy in the middle, more toasting is required.

When toasted, apply a big slab of salted butter. Let this soak into the holes in the crumpet, and try not to think of that glorious saturated deliciousness clogging up your arteries.

Insert into primary facehole.

Credits

Adapted from this recipe.

Crumpet Mania

  • 2012-01-11 – 2:32 am
  • Posted in Uncategorized
  • Leave a Comment

Taking the crumpet where no crumpet has been before…

spacer

This

  • 2012-01-10 – 5:41 am
  • Posted in Uncategorized
  • Leave a Comment

spacer

New tool: tabulate

  • 2012-01-07 – 11:51 pm
  • Posted in Uncategorized
  • Comments (2)

New Stuff tools program: tabulate. Very simple program, and not yet efficient (all input must fit in memory). Still it’s useful for messing around on the command line.

spacer

"tabulate" in action

*edit* Stuff tools (including tabulate) are now available on github.

*edit* I thought there must be some way to do this with an existing command line tool, and so there is as @krazylegz pointed out:

column -t

However, tabulate still has some use, with the addition of the –comment option which lets the tabulation ignore lines which match some regular expression. spacer