Friday, March 20, 2009

Transistors n such


So since I had to learn how transistors work and what they actually are, i thought id write about them. Transistors are cool - apparently most everything electronic you have ever had anything to do with (post invention of the transistor) had one or more transistors in it. Quick disclaimer: what im about to write about may be horribly inaccurate and possibly wrong, but is what i understand about transistors.

Soooo transistors have 3 legs on them, called Base, Collector and Emitter and they work like this. If you give some current to the Collector leg then nothing much happens. If you give current to the Base leg only, then i think that you will see it pop out the emitter (provided of course that it is connected to ground or whatever). Now heres the fun part: Give some current to Collector AND to the base, then you get base + collector coming out of the emitter. So pretty much its like a switch between Collector and emitter that you can turn on or off (or steppings thereof) by supplying some (much lower) current to the base leg.

Say for example you have a basic stamp or something that only supplys 10ma (i made that number up but what it supplys is low enough) but you need 100ma to run all your led's and whatnot. Easy, just point the 10ma to the base of your tranny that has 100ma on its collector. Now its emitter has 110 coming out of it.

Now it gets a touch more complex than this as there are various different transistors out there that can handle different max voltages/currents and need different amounts of voltages/current on their base to turn them on or off. I use a 182b transistor for my stuff as it is a general multipurpose tranny that (luckily) does what i need it to do.

Oh heres a fun fact. If a tranny is completely off or completely on, then it generates not very much heat. If it is partially on, then it will generate heaps of heat as it is actively curbing the amount of stuff (current/voltage/whatever) going thru it, and the stuff that isnt getting through is being disappated as heat. This is why (i assume) some trannys are attached to heatsinks.

Something else to be aware of is that trannys can come in different packages and the pinouts may change. Read the datasheet on your trannys to work out which pins are B, C and E. Additionally there are 2 types of transistors: NPN and PNP. I just described an NPN transistor.

Thursday, March 19, 2009

Lighting (controlled)

After the Gi was done and working (pretty much a no-brainer - just connect it all up to 5v and you're laughing) it was time to move onto the controlled lighting. First thing I did was to wire up all the lights. I had picked up some phone cabling (i think) which had 4 cores through it. The controller IC's im going to use have 8 outputs, so that worked out well, just wire up two sets of 4 to each controller chip. The fact that the cables were grouped in 4 made the back side of the machine a lot neater (but probably not as neat as from the factory).

While all this was happening, i had ordered a basic stamp from parallax (www.parallax.com) - the bs2sx OEM model (OEM coz i didnt mind building it myself, and also it had a serial port built into it, as well as handy dandy outputs that i could plug into an IDE cable).

Link to the bs2sx: http://www.parallax.com/Store/Microcontrollers/BASICStampOEM/tabid/135/ProductID/501/List/1/Default.aspx

Next my main problem was that the basic stamp i chose has only 16 in/out pins for me to play with, which is well under the 43-or-so lights that i needed to control. I thought about a heap of solutions to this, such as an output matrix and flip flops, but the simplest solution is to do it the same way as the pinmame-hw guys - that is to use some separate IC's which are serial in, parallel out chips. 74HC4094 or 74HC595 (which as far as i can tell do the same thing, but with slightly different pinouts).

As it turns out, I had a handful of these chips still floating around from a previous failed attempt at making the pinmame HW circuit. The best move I made here was to purchase some breadboards and prototype the hell out of these things to get a good understanding of how they worked.


(Prototyping the IC's - i used an itermediate board between the basic stamp and the chips, connected by IDE cable - which the stamp fits into perfectly.)

I was basing my design off the pinmame-hw (but using the stamp instead of parallel port) which can be found here: http://membres.lycos.fr/regismalt/. Turns out that they got most of their HW info from another very handy site here: http://homepages.which.net/~paul.hills/Software/ShiftRegister/ShiftRegisterBody.html.

So after a heap of prototyping and soldering i finally had created my first prototype hardware board for the qbert pinball machine.

(Top of the light interface board)
(Rear of the board)

Pro-tip: use the chips to control transistors which allow current from an alternate power source, as i doubt the chips would be able to provide enough power to light all the lamps. Next post will cover some basic transistor theory!

Tuesday, March 17, 2009

Lighting (GI)

The first thing I did with this project was to pull off all the wiring, and lights. I unscrewed each and every light socket and pretty much cut the wires to each of the coils and switches, as i planned on wiring it all up myself later.

(playfield underside with wiring and lights removed)

I then had to work out how i was going to mount an LED in place of each globe. The solution I came up with was to solder a resistor onto the -ve leg of the LED, then solder the +ve leg into the light socket, while wrapping the -ve leg around the outside of the socket like in the image. From there mounting the LED was trivial - just screw it into the existing hole, and wire it up.

(LED + Resistor in a socket - early version - subsequent attempts got neater)

First thing to do was all of the GI (general illumination i.e. always-on lights). I chose to use 5v DC for all of the lights, as the microcontroller I bought can run off 5v, too (more on which later). As this was my first attempt at anything electronic related, it took some learning of soldering skills etc, but I got much better at it as work progressed.

(half of the GI complete)

Monday, March 16, 2009

PC controlled pinball machine (Project Overview)

Here's my first post. Blogging kind of goes against everything i stand for, but im doing this cool pinball project thing at home, and thought i might write about what im doing and how im doing it to help other people who might want to try something similar.

I aquired an old q-berts quest pinball playfield from the local pinball people and decided that i wanted to turn it into a coffee table. Bear in mind it was the playfield only, with a heap of components and wires etc on it. These wires had all been unceremoniously chopped off where they would have gone into the cabinet to be controlled/powered etc.

(the playfield as i got it)


Initially all i wanted to do was control the lights so i could plug my coffee table in and have it light up. From there it grew into a desire to control the lights using code. I found the pinmame-hw site (http://membres.lycos.fr/regismalt/) and started playing around with electronics and things, and it kind of just grew from there.

As i get around to writing more - ill go through all the different stages of the project to date, how I accomplished them and any problems/issues I had to overcome.