Electronics

more progress

Posted in kNES on November 5th, 2009 by konkers – Be the first to comment

Added the beginnings of the ALU and got the INX instructions working.  The counting code from yesterday is simplified to:

reset:

	ldx #$CA
loop:
	inx
	stx $DEAD
	jmp loop
Next big pieces on the place are the status register, conditional execution, and the rest of the addressing modes.

Fate and Progress

Posted in kNES on November 4th, 2009 by konkers – Be the first to comment

8nes I got the NEEK from my coworker today and look at what was in the part number.  Fate I tell you.  This chip was meant to be a NES.

In other news I’ve grown tired of hand coding the rom and added support for mapping the PRG-ROM from an iNES file to the correct address in the 6502 address space.  As a side effect of this I had to implement proper reset vector support.  There are stubs for nmi and irq but no support.

The test program is now written in assembly and assembled/linked with the cc65 toolchain.  This will be a godsend as I start adding more instructions and one step closer to plugging in a real rom.

And the big deal… the code is now running on real hardware!  Below you can see the NEEK executing a simple counting program and outputting the lower nibble of every write to the 4 LEDs.

Code is pushed to github.

6502 progress

Posted in kNES on November 3rd, 2009 by konkers – Be the first to comment

Lots of progress in the last several days on the 6502 core.  It’s simulating with the Altera timing model under model sim, almost every major functional block except the ALU is in place, and the following instructions have been added:

  • LDA abs, LDX abs, LDY abs
  • STA abs, STX abs, STY abs

The test now successfully runs the following program:

start:
   nop
   lda data
   ldx $#CA
   ldy $#FE
   sty $DEAD
   nop
   jmp addr
data:
   .db $#5A
addr:
   .DB $#01, $#00

Next on the list is to get the thing into a real FPGA and make some LEDs blink.  Then implement the ALU.  Also at some point I should integrate a real assembler into the flow instead of coding rom by hand.

Source is up to date on github.

I’m Crazy

Posted in kNES on October 30th, 2009 by konkers – Be the first to comment

nes-consoleIt’s true. I’m insane.  A few days ago I became obsessed with recreating the NES (Nintendo Entertainment System) on an FPGA.  There are many emulators out there but I only know of two projects that have tried to re-implement the hardware.

  • Kevin Horton appears to have created a full implementation however few details are shared other than pictures documenting the process.  The source code has not been shared.
  • Dan Leach adapted a public available 65C02 to drop into the NES for his graduate thesis.  No other parts of the system were implemented.  Source Code is available from his page.

I’m going to do a full ground up implementation.  Why? Because it’s fun (told you I was crazy.)  It’s all under the Apache Licence.  Why? Because I’m not so crazy I want to try to make money off of it.  If someone else is crazy enough to try, more power to ‘em.  Source can be found at github.

Getting Started

Altera NEEK

The Nios II Embedded Evaluation Kit (of NEEK) from Altera looks like a great board  to us with the additional advantage that a coworker is going to lend me one.  Altera’s basic design software Quartis is available as a free download from the their website.

For simulation and development, Icarus Verilog and GTKWave provide a really quick devlopment cycle.

Some documentation I’ve found invaluable:

Progress so far

10-29-ld

In the last two night’s I’ve managed to get enough of a 6502 working to support the NOP, JMP imm, JMP ind, LDA imm, LDX imm, and LDY imm instructions.  Above is a trace of the core running the following code:

reset:
    nop
    nop
    lda #$5A
    ldx #$CA
    ldy #$FD
    jmp $addr
    .db $00
    .db $00
    .db $00
    .db $00
    .db $00
addr:
    .db $01
    .db $00

Controller Re-design

Posted in LED Display on January 19th, 2009 by konkers – Be the first to comment

This weekend I finished re-designing the controller board to use an ATMEL arm.  The changes are a pretty straight forward swap of the AVR and FTDI chips for an at91sam7s.   Here’s the new schematic:

ledmatrix16_sch_rev1

There are a few other projects for which I’d like to make boards.  I’m going to wait a bit before sending this one off to be fabbed so I can gang the designs onto one panel.

Software

Posted in LED Display on January 17th, 2009 by konkers – Be the first to comment

SVN Repository

The LEDs will be driven a row at a time using bit angle modulation (app-note).  A clever idea I had was to store the frame in the microcontroller pre-modulated.  This means that there is no processing to modulate during row scanning (which happens very fast.)

A simple program running on my laptop takes an 8×8 png, encodes/modulates it, then sends it out over the USB UART.

Unfortunately I am having trouble getting the scan rate high enough for 24 bit color.  Part of this is due to the high interrupt load on the system (4 interrupts for every scan line.)  I’ve had to back off to 12 bit color.  This is also causing the UART to drop bytes resulting in corrupted frames.  I’ve tried several different approaches to the code structure with no apparent change.

I’m thinking I might have to use a better microcontroller if I want 24 bit color and high data rate.  I’m eyeing the Atmel AT91SAM7S321 right now.  It’s faster and has DMA which will significantly reduce interrupt load.  It will also comes out cheap than an AVR+FTDI chip.  However, in the 16×16 module, I am not planning on using USB.

8×8 Display Fabrication

Posted in LED Display on January 17th, 2009 by konkers – Be the first to comment

The first test display is only 8×8.  I used some 5mm common cathode diffused LEDs I got on Ebay from HKJE Led Lamp Center.  The LEDs are mounted on a black piece of polycarbonate scrap I got at Tap Plastics.

The first task was to square the polycarbonate and drill holes for the LEDs.  Thankfully a friend of mine has a nice Bridgeport mill with DRO which made this come out really nice.  I also countersunk the back side of the holes with an end mill in order to have the LEDs stick out further from the surface.

Next was to solder the LEDs together in a matrix.  This was really tedious and took 2.5 hours.  The process that seemed to work best for me was:

  • Bend the 3 anode leads a 90 degree angle with a pair of needle nose pliers.  The correct bend position was determined experimentally.
  • Trim the 3 anode leads so that they just over lap leads of the next LED in the column.
  • Solder all the anode columns taking care not to create solder bridges/shorts.
  • Bend and solder the cathode leads to form the rows with needle nose pliers again taking care not to create shorts.

Some photos of this process can be found on flickr.  Next time I think it’s worth the expense to fab a board with the matrix on it instead of doing it by hand.

The LEDs were then connected to the driver board with kynar wire-wrap wire.  I highly recommend using the kynar wire instead of cheaper wire-wrap as the insulation is much more heat resistant.  It also really helps to have a wire wrap gun to attach the wires to the LED leads.

Now it’s just a SMOP (simple matter of programming)

LED Matrix Design

Posted in LED Display on January 17th, 2009 by konkers – Be the first to comment

I’ve been working on an RGB LED display for the last month or so.  My end goal is to have 16×16 LED modular panels which can be hooked together into a larger display.  That way I can grow the display as I have funds.  I hope to be able to get 24 bit color out of the display.

The drive circuit for the display is based off the SparkFun’s LED Matrix Serial Interface. I added another 8 row and column drivers.  Instead of bit-banging the shift registers I hooked them up to the SPI lines to reduce the load on the microcontroller.

Schematic: ledmatrix16_sch.pdf

I got a panel of the boards fabbed at Gold Phoenix

… and assembled two

Above you can see some blue wires.  One of them was planned because my first test of the board will be for an 8×8 display instead of a 16×16 so I had to route the serial data line around the second set of column drivers.  The other three were real mistakes:

  • Forgot to hook the test pin of the FT232R (USB serial converter) to ground causing frustratingly intermittent function.
  • Forgot to hook up the OE and RESET nets to the microcontroller