Categories
Maker Programming

Electronic check-in at the Taipei Hackerspace

One issue we have frequently at the Taipei Hackerspace is that people don’t know when we are open. Our  basic rule is simple: whenever a keyholder member is in the Hackerspace, anyone/everyone can come. In practice people never really know if anyone’s there.

They could give a call to the space, or even send an email to the mailing list, while the people I know usually end up asking me directly – hey, anyone’s at the space at the moment? Since I don’t always know the answer, the search was on for a better – maybe more technological or hackish solution: let’s build an electronic check-in/out system that will show the current status on out website, so people can check right there.

I had the following idea in the back of my mind for a few weeks and even got the hardware acquired, but one of our co-founder had to call me out by name on the mailing list, a few days ago to swing into action. So now here it is, kinda working, ready for real usage.

The main idea is that in Taipei pretty much everyone has an EasyCard, an 13.56MHz RFID card that is used for all public transport in the city and a lot more. The RC522 card-antenna module seems to be able to read the card pretty well, and all I need to get off it is the the ID number which is pretty straightforward (after digging the Arduino forums for source code).

The project in a nutshell is:

  • Use Arduino Mega with an RC522 board to get the ID number of a given EasyCard
  • Use witches to get whether the person is checking in or out
  • Use LEDs to provide some feedback and basic user interface for the hardware
  • Node.js server to communicate with the Arduino, interface the check-in/out database, and provide API and realtime access to the data
  • Create a bit of interface on the website to display the check-in status

Now let me dig into the different parts in detail.

RFID

The RC522 module has 8 pins, and Arduino can use the SPI library to communicate with it. I used Arduino Mega ADK, because the SPI pins are conveniently accessible, unlike e.g. the Leonardo, for which I would have had to make some new cables or headers. The RC522(pin number)->Mega(pin number) connections are done such that:

  • SA(1) -> SS(53)
  • SCK(2) -> SCK(52)
  • MOSI(3) -> MOSI(51)
  • MISO(4) -> MISO(50)
  • (5) not connected
  • GND(6) -> GND
  • RST(8) -> (any digital pin)
  • +3.3V(8) -> +3.3V
Photo of the electronics
RFID-RC522, with blank card and pins

The source code to talk to the card is from a blog, and originally from a tech shop in China, I guess (based on the big bunch of Simplified Chinese comments).

Switches and Visual Feedback

I wanted to make as simple interface for the card reader as possible. Added this pair of switches and LEDs (the D1 being green, and D2 being red). After the Arduino received a card ID from the reader, the LEDs are blinked to prompt people to press either the Check In or Check Out buttons. If they press either of them, the corresponding LED is blinked very brightly for a bit, and the card ID and check-in/out event is sent to the connected computer via serial connection

The (very basic) circuit for the check-in/out buttons and visual feedback LEDs
The (very basic) circuit for the check-in/out buttons and visual feedback LEDs. “Pins” refer to the Arduino pins used in the current version

If no button press occurs within 10 seconds or so, the reading is discarded and the card reader goes back to listening mode.

Webserver

Node.js is very useful to make quick web services, and its library support is not too bad at all, although it’s not all smooth sailing: their documentation is often scarce at best. Nevertheless it was the fastest one to get things up and running, since I have used before almost all required components.

The server communicates with Arduino via the serialport library. I’m more used to Python’s pyserial, though in this case it was very handy that serialport can emit read events, thus the server can just wait until there’s something to read and run some functions on the incoming data. In my experience, serialport wouldn’t be good for every cornercase I came across in serial-land, but in this setup works beautifully.

I chose SQLite3 to store the data, using the sqlite3 library. There are a bunch of others, had to look around which one is still being developed. This particular library is not too bad, though I found myself fighting the lack of documentation and asynchronicity quite a bit. The resulting code is pretty ugly I’m sure, in some places inefficient because I didn’t know how to get to the result I wanted in a less roundabout way, still it seems to work and that is what matters for a prototype.

First I made a simple REST API to query the currently checked-in people, and later added (real-time) push updates via socket.io, to make it nicer. It’s brilliant that without any polling, all clients can be updated once someone signs in or out.

Since this code is running on a different computer than our main web server, had to play around with the Access-Control-Allow-Origin header, and adjusting the settings of our  router to make it accessible for the web correctly.

Tried to add a pretty-much self-contained script that the front-end can load, and it handles everything, just need an appropriate HTML span or div element to display the information.

Photo showing the circuit used for the check-in system
Hardware setup for checking in/out: Arduino Mega, RFID-RC522 circuit, and some switches and LEDs.

The result is pretty good, as long as the card-reader does not crash. Originally the results were displayed in a table, but wanted to make it more human, so here’s the format I ended up with:

Website screenshot showing two people checked in
Screenshot of the homepage with one particular check-in situation.

There can also be people with no name, they just show up something like “Right now there are three people checked in the Hackerspace: Greg, and two other people.”

It lives!

Here’s a quick demonstration video of how does it work:

So you can check out our website at http://tpehack.no-ip.biz/ for the live results, and drop in if you are in the neighbourhood if there’s anyone in the ‘space.

The whole source code is shared in a Github repository: the Arduino sketch, the server script, and any additional files. I’m sure there are a lot of things that could be improved about it.

Categories
Maker

Assembling my first 3D printer

After holding out for years, just recently made up my mind to buy a 3D printer. Before all the “affordable” models were US$2000+ or so, and even if I was really interested in them, I couldn’t make up my mind about such a big expenditure. The factors that changed my mind recently  were: hearing about Portabee, a sub-US$500 printer (that is as a kit); all the interesting things happening at Taipei Hackerspace where I wanted us to have an interesting new tool; and having acquired a brand new credit card (oops).

I ordered it in the beginning of may, from a Singaporean store called Romscraj, that seems to be somewhat affiliated with the original makers of the printer, and had better rate for shipping over here to Taiwan. (At the time of this writing, the store’s website is redirecting to a static image, though, I wonder what’s up).

The package had 3 weeks lead time. Now, having tried how long does it take to make a single print, and seeing how many self-printed parts the kit has, I’m much less surprised about that. The DHL delivery was pretty darn quick afterwards, apparently it helps to have a distribution centre over here.

Then one fine Friday noon about two weeks ago I got to open the box and unpack.

Contents of the box
Unpacking the parts of Portabee

Little packages for the different screw sizes (M3/M4/M5 and their nuts and washers), the electronics neatly packed, metal pieces that looked sturdy at first, the heated bed for the print, a bunch of tool, spools of printing materials (I ordered a few extra spools, one can never know).

I liked the included instant coffee, that felt like a nice touch, and that there were enough tools included for about 90% of the tasks I encountered later (for the screws, leveling mainly, that’s what a 3D printer assembly is mostly).

The rest of the contents of the box
More parts, mostly the printed sections and electronics

There was of course the big bag of printed parts, in nice green (still like that colour a lot, though the original website’s red prints are not bad either). Big bunch motors (or let’s count them: 5), and more electronics. It all made a happy pile, and I have also started to appreciate the task ahead of me.

I brought up their assembly manual on the screen, turned on some DJ Krush, and got to it.

Since this supposed to be a portable printer (the name alluded to that already), it has somewhat different design than the other ones I’ve seen.

Starting off with the base, it has already some fun alignment tasks and screw tightening. The latter is almost like an art: how much you tighten that you don’t break the (not totally, but still plenty) fragile plastic, but don’t let it loosen by itself either. This is something I’m still learning and I am convinced that it comes from experience, from the problems one finds doing it one way or another.

The base and the cross section assembly step
Assembly starting with the base

So far so good, making the base, then starting on the horizontal bars, and more motor mounts. All X, Y, and Z directions had these switches that would tell the controller that “please don’t come closer” and lets the machine find its home easily, and (more importantly) quite safely. The first puzzle I hit was that these switch circuits were soldered in a mirror arrangement, compared to the manual and instructions. The circuit board apparently lends itself to both directions, still it is mighty confusing. I wrote an email to the store I got my kit from, and they just told me what I have found in the manual later, that these switches can indeed be made in either direction.

Assembling the stop trigger part
One of the stop triggers

Not a big deal in the end, though I had to change a few things around and mount them differently. When the white connector is not in the way in the original design, it can be very much in the mirrored one if I don’t move it somewhere else. It was especially a problem with the X-movement (the table back and forth). Just a bit of awareness and adjustment is fine.

Got to some of the motors already. There were two different types, one with the cogs on top (2 pieces), and another without (the other 3). So far so good, those are easy to distinguish. On the other hand, I should have read the manual better (first mistake), or actually took a look at the motors (compounded mistake), in either case I would have been certain which one goes where. As it was, I kinda guessed, and while the guess worked out relatively fine, I just had to exchange one pair of motors in the end (because of the insufficient length of cabling for one). Just a bit of extra assembly in that case, but could have been worse if I had to exchange other ones.

Base motor assembly
Base motor assembly

Some of the rods were actually slightly differently sized as in the manual, and it was hard to see sometimes when they were insisting accurate measurements of some parts, down to a millimeter, that how things are going to fit together further along the assembly. For example the “250mm rod” I received was more like 265, thus they didn’t really put the kit together to the same accuracy as the original design.

The extruder head had its own separate manual, and I’m not surprised. The most sensitive part of the whole thing, but all in all it is not too bad. The manual in general does a good job, but in this case I did find some deficiencies in their graphics, not really knowing where to lead the cables for a good assembly. The cooling fan had a funny case of being oriented by the location of its sticker – while the one I had didn’t have such a sticker really, so I had to guess a bit which way does its wind blow (spoiler: I was wrong, had to reverse it later).

Extruder assembled
Extruder head assembly

Mounting it all on the top it starts to feel more solid and sturdy. Had some funs trying to insert the printing material first in the alignment stage, I am sure it gets easier in practice.

The cogwheels to drive the plastic
Cogwheel extruder assembly

For the rest of the parts I had to find a good file (the tool “file”) to make some of the holes larger, where the printing was too tight. The tool street is just next to the Hackerspace, though, so it wasn’t a big deal and was back in business in no time. Still the tight parts ment that once some of them were on, there wasn’t really any way to take them off, short of braking them.

In the end, after about 10 hours of assembly (distributed in two days), I got the whole thing up. When I realized that it took this much, the ~US$150 extra for an assembled kit starts to look much more attractive. Still, I like that I did it myself, because now when it breaks (as it so does it will break a lot) I will know more or less what to fix.

The printer put together
Completed assembly

After the hardware setup and testing, had to figure out the software to breathe some life into it. Given that I’m a Linux user, maybe I should have done it earlier, preferably before actually ordering it, otherwise I’ll end up the same way as I did with Galago – having a tool but not having a way to use it.

Fortunately the manual was very helpful, and pointed me to Cura and Pronterface to use. Strangely, Cura didn’t install well onto the Hackerspace’s Xubuntu, but it worked pretty darn well on my laptop’s ArchLinux, so used that afterwards.

One part of the software control that should put people on the edge at first for sure (and probably for a while) that it’s actually a pretty high temperature tool. The base is around 60°C, the printhead goes up to 185-225°C (depending on the material). The fan on the extruder supposed to be very important, and that can only be enabled manually in Pronterface, by sending the command “M106” to the printer. It can be tricky since sometimes the printer has to be plugged in and out to respond to commands again if I switch programs, and that would make the fan not run for a while. Might not be a big problem, but will not know until something breaks.

Another problem is the temperature stability, and in the safety point of view, even before the print quality is taken into account. The temperature is stabilized by feeding back a temperature measurement of some glass bead thermistors. So far so good, that’s similar thing to all the other temperature stabilization I had in the laser physics labs before. The part that you don’t want, though, is to have the thermistor separated from the thing it measures. Then the heating would just go up and up, since the electronics thinks it is not hot enough, while it just measures the air somewhere else. Not the mother of thermal runaways, but would still make me a sad bunny.

The thermistor here is mounted like on this picture, with a piece of silicon washer behind the brass screw.

The little pieces of the head
Extruder head with heater and thermistor

The problem is that as soon as I try to secure the thing with the screw, the turning almost inevitably throws the bead out. Even when it stays in, the increased temperature popped it out a few times that I had to initiate an emergency shut-down.

The screw hole is actually a through hole, so if I can figure out a good thermal contact inside, it would worth dropping a screw altogether and run the bead through the whole the next time.

Now, ready to print, try it first with a relatively simple model, a Make robot. Takes a few minutes to heat up and stabilize the temperature, but it’s pretty automatic.

The 3D printer software window
Cura, the software for printing

Everything is prepared, and even if it’s a bit of a mess, it made sense. Got a nice heavy flat wooden chopping block as a base. Looks pretty flat and almost 2cm thick, should be sturdy enough. It is also from the neighbouring tool street, there’s a pretty good kitchenware store I frequent.

Complete assembly with plastic source
Ready to print, just a bit of a mess

After the heating up time, everything kicks off pretty quickly. The head runs over to the middle of the board and start laying down the structure. I was actually quite surprised that it worked for the first time, but that’s just my own (non-) trust of assembling abilities. The structure felt relatively sturdy, with the exception of one of the Z-screws that lifts and lowers the head is wobbling visibly, though so far I cannot see how much effect that will have on the print quality (might need to take that one out and balance it back again.

The printer head beginning to do its work
First try, on the road to print

Well, the first finished piece is nothing to be really proud of. I actually rescaled it to 50% so it finished quicker, and also I wasn’t sure how high I could print. It is a total mess but still kinda recognizable.

Finished robot print
The finished print

No problem, however, this just means that I will have to adjust the parameters of the printer to find the right values for half a dozen to a dozen variables. Head traveling speed while printing and while not, pullback distance and pullback speed, flow rate, head temperature, these sort of things. Looking at the default settings in Cura is not really helpful, on the contrary, they are for a well calibrated Ultimaker, that feels more sturdy, eg. the recommended printing speed is almost 4 times the one in the Portabee wiki. Some experimenting times ahead.

Comparison to the original model
Comparison to the original model

Or actually it would have been experimenting times ahead, if a few hours later I haven’t had broken the printer. The main extruder motor’s cogwheel was pretty much shaved clean by the large cogwheel, thus disabling the whole extruder. This is not that much of a surprise upon closer inspection: while the large cogwheel is totally solid, the small one’s cogs are just one layer of “plastic wiggle”, barely touching the actual cog centre. I will have to print a new one, most likely making the design sturdier, and maybe even printing it in a different material.

Also, the clips that hold the table on the horizontal bars broke too, too think for the pressure they had to endure by the clipping. That needs some better solution as well.

For the time being, the printer is taking a rest, and I can reflect on “so what have we learned“.

Lessons learned

If I were to order a bunch of 3D printers, maybe I would get an assembled version. In Portabee’s case, the difference is about $150, which divided by the 10 hours of assembly time is not a bad deal. On the other hand, in retrospect the assembly was interesting and definitely required exercise to be able to fix whatever goes wrong. And feels more like the “hackerspace way”, if there’s such a thing.

It felt like as if some of the design choices were mere wishful thinking, and don’t work that well, even if at first look they are pretty clever. For example many of the hex nuts are held in place by depressions in the shape of the nut. It works well for M4 and larger, for M3 it works “usually”, and I wouldn’t really rely on it, unless the printer doing the piece is very well set up. Same verdict of “so-so” for the heater block thermistor’s assembly, the print table’s clip on, the electronics board holder. There are plenty to learn though about mechanical design through the choices, like the Z-lift screws, the translation belts, some of the smaller stuff.

Maybe the biggest lesson is to read the manual beforehand. I remember one of my friends actually asking me when I have started, “Greg, have you read the manual?” “Oh, I’ll just follow it up as I go along” was my line back (more or less). Not a good idea. No matter how good the manual looks, there are always non-obvious differences that had to be fixed, and unless one knows the outcome, it’s hard to make the required trade-offs.

I have tried some prints I got off Thingiverse while the machine was still working, and it seems to me that many of them don’t work well when rescaled, while they still should. Feels like I want to get out some 3D modeling software and make some alternate designs, filling some holes here, making things sturdier there. Google Sketchup is the most popular one I keep hearing about, though that does not really work for me in Linux. Fortunately I found that FreeCAD, that I have used for other projects and wanted to find more use for as well, can very nicely prepare the required files as well. And it’s scripted in Python, paving the way for some algorithmic design ideas.

Categories
Life Maker

Monocle and the one idea

I’m always looking for new and interesting magazines that I can read. I do believe there’s still future for printed journalism, even if most of the things I read now is online (Hacker News, myriads of blogs on Google Reader, links shared on Facebook and Twitter…). During my time at the university, a perfect weekend program was having brunch in the Common Room and checking out the latest issue of The Economist. My interests are mostly in analysis, world affairs, getting insights from people with much more experience, but not shoved down on my throat like many dailies seem to do but giving me space to make up my mind myself.

Monocle Issue 40 cover
Cover of Monocle Issue 40

Recently I was checking out Monocle in my local Eslite Bookstore, it was wrapped up since it’s not one of the cheapest (NT$520, almost twice the cover price elsewhere). The cover promises to have ABCDE: Affairs, Business, Culture, Design and Edits – which is all good and could be very interesting. I checked out on the web a little bit what did others write about it, and it is all good. With all the accolades, about their worldwide reach (apparently they have offices all around the globe), that they do their own photography because they want the best, with all the enthusiasm by the staff… I actually felt that this might be the real life embodiment of the Millennium magazine. That’s certainly a lot to live up to, isn’t it?

So, last week I bought it. First impression: I was pretty underwhelmed. The features are thin on content, most the content feels like an IKEA catalogue and how can I relate to something that advertises £190 polo shirts? I wasn’t that excited about it anymore, and it certainly wasn’t the Millennium.

Nevertheless, I took it out every now and again, reading more of it and things did change. I think I was wrong to hype it up for myself, should have judged it on its on merits. And on that, the writers are certainly clever. Maybe their bread is focusing on short observations but making many of them. The topics are actually worthy. The photography is indeed top-notch. The designs they show are really cool (and living in Taiwan, where I’m quite spoiled with good design, that is tough). In the end, I’d say it is a good magazine. Maybe not for me, or not every single issue, but if I’ve found in a library I’m sure I’d check it out. If design was my business I’d subscribe.

The One Idea

Nevertheless, there was idea that stuck with me (and maybe that’s one reason I’ve started to change my mind about the Monocle), which came from a rather short editorial titled “What Ireland can learn from Finland”. The writer argues, that Ireland’s crisis is pretty much inevitable, since no economy can survive on only the service industry. They should instead start to make things again, rolling up the sleeves and creating something tangible.

After reading this I felt a bit shocked. Looking at the things I’m doing, how I’m reading the hymns for software developers and Web 2.0 startups every day, how I’m positioning myself to become a better programmer. And despite doing all that, I do remember now, that I wanted to make things – and I haven’t. It feels like a wake-up call, that there are things that I value more but I forgot about.

This got me thinking: instead of being an awesome programmer (good luck with that), I really should think out how can I leverage my maker background (every experimental physicist is a maker) and programmer ambitions to create something new. Don’t give up either (I couldn’t) but find what unique combination of skills I might have. I really feel this is what would bring the much desired sense of achievement.

Got me thinking that I have all the issues from Make: in the last two years or so, but never actually did anything. That I planned to set up a hacker space in Taipei, but never got beyond asking my friends who would be interested in it. That I admired and saved so many things on Instructables but always had it linger on my Next-Action List.

“If not now, when? If not you, who?”

Now just stay tuned as I try to follow through. :)