Hello,
I am trying to connect a PlayStation Namco Guncon Lightgun to my Arduino Uno using the SPI Library.
The PlayStation controller bus protocoll is described here:
PSX Controller pinout and bus protocol
The Guncon's specific controller ID and data formats can be found here:
Namco Guncon Specifications
The protocol is basically SPI (250khz, LSB first, SPI_MODE3 to be specific) with an additional "Acknowledge line" that is pulled low by the controller once after a byte has been received or the PlayStation will assume that there is no controller connected to that controller port.
Using a Logic Analyzer I captured the following sequence of my PlayStation2 talking to the Lightgun:
The "Data Line" is MISO,"CMD" is MOSI and "ATT" is the enable line and all the data matches the expected sequence(see Namco Guncon Specifications) exactly.
When I try to replicate this using an Arduino instead of the PlayStation2, I get this:
MOSI,SS and the Clock are working as expected, the two commands get sent and the Lightgun answers.
But MISO and the Acknowledge are behaving very strange.
They show high frequency pulses lasting only about 42ns, have huge varation in pulse lengths and of course MISO does not send the expected data.
Why is the Lightgun's output so weird even though the timing of MOSI,CLK and SS are very close to the PlayStation's timing and MOSI sending the exact same commands?
My sketch:
#include <SPI.h>
const byte CLKPin = 13;
const byte ATTPin = 10;
const byte CMNDPin = 11;
const byte cmnd1 = 0x01;
const byte cmnd2 = 0x42;
const byte nullbyte = 0x00;
const byte delaytime = 16;
void setup()
{
pinMode(CLKPin,OUTPUT);
pinMode(CMNDPin,OUTPUT);
pinMode(ATTPin,OUTPUT);
digitalWrite(CMNDPin,HIGH);
digitalWrite(CLKPin,HIGH);
digitalWrite(ATTPin,HIGH);
}
void loop()
{
digitalWrite(ATTPin,LOW);
SPI.begin();
SPI.beginTransaction(SPISettings(250000, LSBFIRST, SPI_MODE3));
SPI.transfer(cmnd1);
delayMicroseconds(delaytime);
SPI.transfer(cmnd2);
delayMicroseconds(delaytime);
for(byte i=0;i<7;i++)
{
SPI.transfer(nullbyte);
delayMicroseconds(delaytime);
}
digitalWrite(ATTPin,HIGH);
SPI.endTransaction();
SPI.end();
delay(19);
}
Any help would be appreciated!

