Friday, January 20, 2012

Heavy Metal Grinder

Got my hands a bit dirty and started to regrain the second hand metal rails I've salvaged from an old pinball table. The results were actually a lot better than I expected, although not finished yet - take a look...

1) Tools of the trade - sanding block, various sanding papers of varying coarseness.
What's not seen in this picture is the Scotch 3M rotating brush that I used for the heavy scratches.

2) A piece of metal rail before any work has been done.

3) Here we got a comparison shot between an untouched piece and another
piece that has been worked on for about a minute. We're already seeing quite a difference!

4) The "finished" piece after a couple of minutes of grinding.
Note that this was the one with the heavy scratching in the pictures above.
Huge difference!

I never expected the results to come so easy, so fast.
I will not do any more work right now since the parts must be cut, bent and modified to become a part of my machine. In that process it's more than likely new scratching will occur, so I'll do the final sanding and buffing after that.

The piece above has had two rather coarse treatments. Before installing they will receive at least two more + buffing so they get that brand new look!

This guy has a page with a really good guide on polishing metal. Unfortunately most of the page is in Swedish besides the linked one, but -
If you look at the results it's easy to see why regraining is well worth the effort!

Tuesday, January 17, 2012


This is the box of wonder I received today from "ADV Idé & Design" here in Gothenburg, Sweden.  Sideart, translite, playfield, front, playfield whitemask, speaker art etc. All in glorious 300 DPI, so the quality of the printing is EXCELLENT! (In fact, Stern should learn a thing or two about printing art from these guys...)

A quick peek inside reveals the whitemask for the playfield. Since the playfield is transparent and does not contain any white color, the playfield needs to be painted white first. Imagine masking each of these individually...  Now it's just a matter of taping it down, paint and remove - ready for the playfield art!

A small teaser of the middle right section of the playfield. Looks incredible! Can't wait to see it all lit up in colors etc! The playfield print is made on a transparent film that has been laminated for extra protection before the clear coating. Obviously the white in the pictures is transparent or cutout, and will show the insert color shining through.

Another great thing about this company is their cutcontour printing - After the artwork was designed I simply had to create an additional layer where the cutting should occur. Smooth, perfect edges with minimal work. This allows me to get that nice bit of visible wood on the edges of the holes that professional tables has. Very nice!

Thursday, January 12, 2012

Oh those gags

That awesome moment when you realize...
...the programmers have done a lazy job converting the SD card library from one platform to another.

It needs a rewrite.

Tuesday, January 10, 2012

DMD programming + SD card reading

I've had issues with the SD card causing the display to either flicker or annoyingly change brightness while streaming files, and yesterday I found a solution for this.

The problems were several:

1) I called SD.begin() every read.
Once during setup is sufficient. Shaved of 10 ms per read leading to overall speed boost.
Calling SD.begin() so often also caused stability problems that could make the SD card stop working all of a sudden for apparently no reason.

The only reason I did this was because I believed it necessary since I share the SPI port between the display and the SD card reader. And since the display needs a begin-call before showing anything at all I believed the same goes for the SD card reader. Shame on me and RTFM!

2) Uneven brightness.
This was rectified by calculating the worst case scenario and simply delaying processing until at least that time has passed. I.e during no loading a delay of 12 ms was present. During loading I delayed from 0.9 ms to 5 ms. I.e delay 12 000 microseconds minus the amount of microseconds passed since loading started. This is to ensure that a solid framerate is used so that each frame has a certain time-slot to live in.

Of course, in a future update I will be processing other data instead of just wastes cycles during that wait time. That's the beauty of a micro processing unit - you can rely on the time it takes to process things to be constant since there's no OS or other processes that hog the resources. There's of course a bit of interrupts etc that fire every now and then, but then we're talking microsecond differences at most.

Using these two tricks I've managed to squeeze out 40 solid frames per second that doesn't flicker or change intensity/brightness when streaming. Streaming becomes seamless and invisible, which is the way it should be.

However -
40 fps is far from ideal and actually makes the whole display flicker when you don't focus your eyes on it. Since most of the time you're actually not looking at the display you get this annoying flicker in the corner of your eyes while playing. I can assure that staring at this display gives you headache. Trust me.

By analyzing where the time culprits are I've managed to see that the first opening of a file (i.e finding the file on disk) takes a whopping 11 ms, while reading 512 bytes takes 5 ms (slow, I know). If I somehow am able to minimize the open file time I can get 82 FPS instead (much better!) by setting the max delay time to around 6ms instead of 12ms.

Furthermore -
I've come up with a byte compression scheme that will allow me to send the same amount of data in almost 1/3 of the time by cutting away all the wasted space. Basically - with 8 color levels used only the three least significant bits are actually being used:  B00000111 = 7.
What I'm currently doing, and is allowed during testing, is to send the whole byte which wastes 5 bits for nothing! So by taking the first 3 bits of eight pixels I get three bytes to send in the end.

So instead of sending 4096 bytes for a full frame I send 1366 bytes (and get 2 wasted bits).
While not doing very much for the actual refresh rate of the screen, it triples the refreshrate of the animations, thus making smoother animations.

Much better!

Wednesday, January 4, 2012

Interior decorating

I've also created the final cable that will handle flipper buttons, coin and start-button + various lights in the front of the machine. The cable runs in a cable "chute" to keep it tidy inside the box.

Its's by far the most complicated cable I've done, with 7 inputs, 1 output, +3.3V, +5V and +12V running in one cable. It was very important to plan ahead since I wanted the cable to be as neat as possible while still packing all the components I needed.

The best thing is that everything worked on the first attempt. I guess planning ahead really makes a difference. The coin mechanism is now correctly connected to accept swedish 1, 5 and 10 kronor and it's nice to know that it all just works!

I think it turned out great!

1) Front interior. Lockdown bar, flipper buttons, cable "chutes" and the coin-mechanism. There's also LED lights installed to keep the coin-return buttons lit.

Note that I have not installed a coin validator in both slots, nor do I intend to. There's two coin entries simply because I didn't find a reasonably priced coin door with only one entry.
I intend to simply return the coin to the coin-return if the wrong one is used, or possibly replacing the door completely further on.

Visual cues

I also promised a bit of feedback on the display issues. 
After a long an extensive troubleshooting, including mailing the good guys at PinballControllers I finally found the answer - a broken cable.
How embarrassing.

After numerous testing, pulling and inserting the old rudimentary cable must have snapped internally and just barely worked. This probably means the logic level converter would have worked - although it's entirely redundant now so it won't be reconnected. 

After making the new, better and final display cable it looks really good!

1) The new display hooked up and running the example scene. There's a slight blurring going on but that's because
a) I don't have a nice camera and DMD photos are hard to take, and
b) there's animation going on and combined with the previous fact these pictures rarely turn out great.

What you do see however is the was difference in brightness and definition compared to the old display. The old display also had large gaps where the LED-elements were joined.
Since the new display is individually placed LED's there no gaps, no grid, no 'it's supposed to look like that' - just a great display!

2) The old display for comparison. Note the uneven brightness of the LED modules and the clearly visible grid of modules. This is NOT a great display. 

Another nice thing about this display is the unique power protection that keeps the columns blank during the upstart, and starts the display when it find the row scanning. That means, the display is blank when booting and turns off automatically in case the host fails and thus no burnt display. 

Too bad I had to experience the bad display before I found the good one. To make it worse, they were almost in the same price range but I chose the cheaper. Shame on me.

Just a side note - 
If you're like me and is creating or is planning to create your own pinball machine, check out PinballControllers. They got great hardware for doing custom machines and a very mature code library (believe me, I've wrestled quite a bit of code - and not everyone likes their bits and bytes!) that really boost development. Their customer support is extremely helpful as well!

Had I known about it when I started my machine I would have cut the development time in half. 
Just saying...

Drillmaster Deluxe and the Visual Gang (featuring Interior)

I spent a little time dissecting an old electric "pepper-grinder" to get the motor that was inside and insert it into the Big Daddy toy I'm working on. The results were actually better than I expected and the rotating drill will now be a part of the final toy's range of movements.

Basically, what I did was cutting away the old forearm since the motor was slightly to big to sit inside the drill itself. The motor will be covered up (probably only painted to prevent overheating) so that it will look like the original forearm of Mr Bubbles.

1) The original arm - about to be dismantled!

2) The various pieces of the right arm. Unfortunately I didn't take any 'before cutting' pictures.
The motor is already inserted as you can see in the picture.

3) Close-up of the new forearm/motor. Will be painted green etc to match the original arm.
But as you can see...

4)'s already hardly noticeable that a swap has occurred. The white plastic inside the protection-bars will not be
there when assembled properly - this is just a mockup assembly for the camera. ;)

I was a little nervous that I might not be able to make it spin, but it turned out great!
The only thing that wasn't so great was the mist of superglue that I accidentally sprayed onto myself when gluing the motor/drill connector in place!

I connected the motor before letting the glue dry completely and saw a burst of glue spray out from the motor. I could smell the superglue so I wouldn't be surprised if it got into my nose as well. There was a lot of eye-drops being used during that night in fear of going blind.

Lesson learned: