Close

First working version

A project log for MAME USB

Extensible USB controller for arcade machines

danjovicdanjovic 08/21/2015 at 04:060 Comments

Found a bug on the function that shifted the bits from the shift registers. This function loops 8 times, one for each bit. The problem was that the clock pulse was being issued before each sample and that caused me to loose one bit.

Wrong:

data=0;
for (i=0;i<8;i++) {
    pulse_clock();
    data<<=1;
    if (Sample_bit ()) data |=1.
}

Correct:

data=0;
for (i=0;i<8;i++) {
    data<<=1;
    if (Sample_bit ()) data |=1.
    pulse_clock();  
}

To find the bug I ran the code in an experiment board that generated the clock/latch signal to the shift registers and allowed me to print each byte that was being received.

Bug found, firmware uploaded and... device not recognized!!

Well, after loose some time _again_ on the fuse configuration I figured out that I was flashing the wrong hex file! Then I have left the fuses on the following configuration LFuse= 0xDF, HFuse=0x5F, and reflashed the ATTiny85 with the correct firmware. This time the beast worked! Windows 7 have recognized all four gamepads (two of them are dummy, though)

Each controller has one directional and 8 buttons:

Below are the pictures of the prototype.

The second picture shows tho important things:

1) When using only one board the Input Data pin shall be short circuited with the +5V line in order to simulate the remaining board with no key or button pressed (all bits in high).

2) The speed-up diode of the LATCH signal soldered right under the 4K7 timing resistor.

The hex file is already available as a link to my dropbox folder for this project. The code still needs to be cleaned and commented. The PCB on the links already contains the correction (insertion) of the speed up diode.

Discussions