Sunday, May 10, 2020

Holy optimizations, Batman!

Spent a "little" time optimizing the code base, along with actually trying to work out the kinks of why optimized mode doesn't work. I'm not all the way there yet, but the results so far are very nice! 

Note: The flickering apparent in both videos is mostly picked up by the camera only and isn't really noticeable IRL, and the refresh rate can be pushed up further. Just keeping it a bit "low" to avoid confusing myself while debugging the rest of the code in case it causes crashes/erratic behavior etc.
For instance - 
Here's a clip of SD-card videos running as fast as possible in the old code. 
Notice the slow motion (faked by frame-skipping previously, removed here). 

And here's the same clip after optimization. 
Compared to the old version, it's a lot smoother and I'm actually running the videos at 40fps here (faster than original 30). Notice the long blank space between the videos, where the old version barely finished rendering the first one when the second one was timed to start. :) 

Some crude counter increments:

Previous one-second count: 28402
New one-second count: 91857

Quite the improvement! 
Very satisfied with the results so far!

In case you didn't notice, I used two simultaneously running SD-animations (background & fx) during the second video. Works great and allows me to spice things up. #thumbsup 
And the cable mess have been mostly corrected now, all lights tested and working. :) 

Monday, May 4, 2020

Rolling with the punches!

What's this... two post within a year? Yes - it actually happened! ;)

Been using my new found determination and time to keep working on the machine, finishing up bits and pieces all over. To start off - flashers, GI and playfield lights are now soldered up and working correctly.

Well, mostly at least.

I ran out of cables so I had to order more.
And I kind of ran out of output ports for the lights, so I'll have to hook up some of them to the AUX-ports I made on the board. (phew). But it's all good! 

1) All lights, switches and solenoids are wired/soldered!
2) It looks very messy, but the cables are actually measured and the "exact" length required.
I ran out of zip-ties, but will of course tie everything neatly when the new arrives.

As for input during menus, I've gone ahead and made the switch "box" that houses the menu buttons. It will be painted and/or covered with a left-over decal, but I'll do that once I've finished the building.

When not in maintenance mode, the red button will lower volume and the green button raise it. Pressing the white button enters maintenance mode. During maintenance mode red/green goes left/right (use can also use flipper buttons), while the white button confirms and start button cancel.

3) The early draft of a control-box inside/behind the coindoor.
Basically - menu buttons and volume etc.

I've also adjusted the syringe to be a little more reliable as a pinball toy and replaced the tiny LED with a proper pinball LED-bulb.

4) I replaced the standard LED with an actual pinball LED-lamp.
No more worrying about accidentally applying too much voltage!

Software-wise I've optimized loading and SD-buffer creation to utilize hardware interrupts for SD-card loading. I've used this a while for DMD rendering, but now I've managed to get it running on the SD-card as well.

So the loops are pretty tight now, which are very nice.
For instance - When sending new data to the DMD I process switches/solenoids etc in the small gap the display needs to stay blank. This is not uncommon among older games which did processing between scanlines (more or less). Works a treat and pretty much doubles the performance.

And now I've done the same for SD-loading, where I basically start loading 512 bytes, and as soon as they're done loading I schedule the next batch and start building the buffer with the 512 bytes just loaded. The unpacking is needed to convert 2K (half-byte per pixel) to a DMD buffer (byte per pixel). The SD card is slower than building the buffer, so that's the reasoning behind not loading the full frame from disk. Previously I built the buffer after all 2K was received, but now I've shaved of a few milliseconds by doing it while "idle". Very nice! 

I've also started the rather tedious task of converting away from Arduino/Chipkit's "String" class. It's ridden with bugs, memory intense and in fact - won't even run when compiled as O3 ("optimize for speed")... There seem to be a problem with the hardware watchdog resetting during optimized compilations, but I can't get my hands around why at the moment. Considering the standard/built-in libraries won't even run properly, I'm not terribly sure my code is the culprit here...

But first, back to the 80's we go; hello, C-string.

Monday, April 20, 2020

A Ferrari-style pit stop!

Got around to do a little tinker on the board the other day!

* audience cheers *

First - had to recreate the development environment on my laptop. Took a little while, but well worth it in the end. And, naturally, the SD card for audio (and the reader) had given up and didn't work. (...sigh).  A purchase of a new reader and a format later solved that. No big deal. But annoying.

Still a bit of wiring to do, but slowly getting there!
Switches, flashers and global illumination is now done, and with a little luck I'm done with the playfield lights in the coming days (or so).

I knew about this before, but I may have to increase voltage for the lights. Currently 5V is a bit on the low side, as lights are quite dim. To avoid using a lot of constant power I also duty cycle the GI, so I figure 12V would be ideal here.

Luckily; there's not a whole lot that needs to be done - either cut the 5V traces and connect the existing 12V line, or move the drive cables to a 12V port on the board. This can be done "any time" so if the board feels too dim during actual play I'll adjust accordingly. :)

Stay safe!

Saturday, June 15, 2019

"Woah" - Keanu Reeves

Can't believe it's been six months since the last update. :|

This will be another short and disappointing one, unfortunately.
I've had little to no time to work on my pinball machine, due to work, hobbies, life and family in general. And I've gone pretty close to burning myself out the last years, so I must take a hiatus from several projects for a little while.

I still expect the machine to be done somewhat soon, so bear with me. :)

Thanks again and check back from time to time! \m/

Saturday, December 29, 2018

....still cables.

Waiting for cables.... damn holidays. :) 
In the meantime, enjoy this random photo (source unknown). 

Wednesday, December 26, 2018

Cables... oh god. So many cables...

Been busy removing old cables and stripping the playfield from "debris" the last few weeks. It was a big but crucial step in order to get the new wiring neat and functioning properly. 
1) Cutting commenced! It's funny how destroying things always goes faster than building them...

2) Patient is on the operating table.
Straight under a florescent light, there's _finally_ a good work space to work on the machine!

3) Remains from the sockets and switches. The cabling all in all filled a big plastic bag... :|

I found out that I had placed all switch diodes wrong, so I actually redid the switches... twice.

Oh the horror when reconnecting a fully rebuilt pinball table and.... nothing. Haha.

But it's done properly this time, and as an added bonus the wiring is identical to commercial machines now. This means that if I forget how it's built in a few years I can always look up the wiring online - or in the manual I've decided to write for the machine. The manual will keep track of all hardware, parts and positions etc, and will have pictures and "maps" to show each position. I have also started gathering manuals for the actual hardware used on the PCB and table/cabinet. Nothing should have to be guessed or "reinvented" during the next repair. :)

4) Yo, Internet. Welcome to my crib...

I've also miscalculated the amount of cabling necessary now that I've gone full matrix on lights and switches and making sure each switch follows the trunk. So basically I'm 90 meters in and only had enough cables for the switches. :'D

But more cables are on the way, so early next year I'll have the lights and other cables in place!

5) The finished (more or less) wiring for switches! Since I've been using different switches of various makers
I've unfortunately not been able to keep a pro-standard everywhere, hence the "floating diodes" in a couple of places.
I also ran out of shrink tube, which will be used everywhere there's a cable "edge" visible.

The coding was also revamped slightly to accommodate the changes in the switch matrix, and overall it seems rock solid. Of course, it will be tested and retested during game rules programming, but I haven't been able to "trick" the machine from detecting hits now, something that was possible earlier due to the relatively (very) slow switch detection.

Thursday, November 29, 2018

A Pin Best Servo'd Cold...

Woho, a proper update!

I've rewritten (or rather written) a servo library that piggybacks on the existing I/O loop. The good thing is that there's zero jitter and no "overflow" or "rollover" issues that is present in some libraries, and it seems to work pretty well. Although I had to guesstimate certain values, as the servos require a rather exact timing to function, it should be close enough for my purposes. I expect to trim and tune these parameters once everything is connected properly (like everything else) but it's nice to see the "last bastion" of remaining functions taken care of.

Furthermore, I've finalized solenoid, switch and light functions so they work properly and reliably with callbacks. I think I covered the switches in an older post, but the hits are buffered and executed in the order they were triggered and is put in the outside loop at ~40 Hz. 

For time critical events I've add high-prio callbacks that gets called right away in the inner loop (even before buffering the hit) that will be used by slingshots, flippers and bumpers, to ensure these solenoids gets triggered within the next microsecond. Sound, points and game related callbacks will run as usual in the outside I/O-loop. Hopefully this will, and should, make the game feel super snappy and responsive.

I've started the time consuming work of making the cables needed for connecting the new PCB-board to the pinball machine, and it's a few hundred meter cables that needs to be redone. Obviously I only do the ends of the cables, but still... ;)

So things are rolling once again, which is rather nice!

1) Doesn't exactly show the servos, but at least the colors are nice. ;)