spacer

Transistor Logic

Another day, another circuit, this one is a little more complex than the LED/Resistor circuit I made the other week. Having read about transistors I decided to design and build a NAND gate. The final circuit is very similar to the one discussed in the XGS ebook (below is the original circuit schematic from the very same ebook – which I highly recommend; a print version will be out soon as well :) )

NAND Gate Schematic

Aside from been a little blury the photo below shows my version of the NAND gate circuit built from two transistors, 3 resistors, two switches and an LED. The hardest part was finding a suitable 5V regulated power supply. I really need to buy a variable supply.

NAND Gate built

The far right of the image is where the +5V power is sourced, the far left is used as GND. The LED is connected to the +5V line via a resistor which results in the LED been lit by default. At the bottom right you should be able to make out the two switches, these connect the +5V supply to the base node of the two transistors (via one of the two 10Kohm resistors). Thus the switches control the input for the two transistors 1 or 0.

The collector of the first transistor is connected to the same resistor as the LED, with the emitter of this transistor feeding the collector of the second transistor. Finally the emitter of the second transistor is connected to GND.

The result of this is that when both switches are closed, the base of each transistor receives a sufficient voltage to start conducting from collector1 to emitter1 which feeds collector2 to emitter2 and finally running to GND. This gives us a working NAND gate. A 1 & 1 signal will result in a 0 i.e the LED will be off since both transistors are conducting to ground. Any other combination will result in a 1 as one (or both) transistor does not conduct, so we get a flow through the LED.

To most this probably isn’t the slightest bit impressive, its hard to appreciate the amount of background knowledge needed in order to understand how and why even simple circuit works, as well as analyse it; until you have done it yourself. So although it isn’t much to look at, I’m please with myself none the less :)

One lesson to take away from this is that it’s only once you begin to understand the basics that you start to finally realise how much more there is yet to learn. BTW I managed to get the joystick position to control the state of the LED that I mentioned in my previous XGS blog entry.

 

Every project needs blinking LEDs

Although I’m slowly working my way through the Design your own console ebook, theres a lot to learn, so I took a bit of a break last night and took a more hands on approach.

I built a very simple LED circuit and connected it to the XGS via the expansion port. That was the easy part, I then spent the next hour or two reading about the SX52 in order to program it to blink the LED on and off. It might not sound much, but considering I know very little about electronics and have never programmed the SX52 before, I’m pretty chuffed. In fact I’d rate the blinking LED achievment along the same lines as seeing your first triangle rendered via openGL, it doesn’t appear to do much but there was a lot of background work involved in getting that far :)

The XGS includes a lot of source code for a number of different hardware and software projects which I’m going to work through, although I prefer to try my own methods from scratch first. That way I can see just how far I can get from my own knowledge before getting stuck and having to refer to the working examples for hints/help.

So with that said, tonights challenge is to get the Joystick to light up an LED when you moved it in a specific direction. The circuit is about as simple as it gets, an LED, a resistor and a logic gate. Now I just need to find out how to talk to the joystick via the SX52.

Once I’ve built a more interesting circuit I’ll post up some screenshots. Although until I learn more about the overall hardware in the XGS the screenshots won’t be all that impressive :P

 

XGS has arrived.

It only took 8 days to arrive but the wait was almost painful. I made do reading the forums and documents on the XGS website, I have to make do no longer. Below is a picture of the XGS just unpacked, along with joystick, user guide, ebook and SX programming manual. Not shown is the expansion module, sx key programmer, logic exploration kit and logic probe.

Now the moment of truth, time to hook it up to the tv. The demo on the XGS was NTSC, fortunately my tv supports both NTSC and PAL and heres the result.

Once I’ve managed to produce something with the XGS I’ll get it hooked up through composite0 then I can take a few screenshots rather than photos of the TV :P

Now to upload some custom code.

To get this working in Linux I needed to download SX-IDE from Rainer Blessing’s website. This requires QT4 to install and Wine for the assembler to work. It uses gsxprog so you need an SX-Key as well.

Since SXIDE requires an assembler and the only one available at the moment is for windows, it will run the assembler via wine. To get the assembler installed in the first place, just run the XGS cd install.exe under wine. Then copy the s.exe from your wine folder into your sxide directory. The README for SXIDE covers the setup, it’s very straightforward.

After connecting the SX-Key to the XGS header pins, programming was as simple as flicking a switch, then clicking assemble and program in sxide.

Now I know everything works I guess its time to crack open all the manuals and start learning how to program for the sx chip, the xgs hardware and also how the hardware all works (which afterall is the reason for buying this).

I want to thank Rainer Blessing for creating SXIDE for Linux. Even though its only at version 0.7 it can run the windows assembler, communicate with the sx-key and program the device as well as support syntax highlighting within the IDE. I’d also like to thank the gsxprog team without who I guess we wouldn’t have an SXIDE, or at least not so quickly :)

 
 
© 2005-2007 Gary Preston
Figment Games is hosted by DreamHost
Entries (RSS) and Comments (RSS).