Sega Mega Drive Control Pad with NXT ( PCF8574 )
Posted: 17 Sep 2012, 19:20
Very easy to connect !
Inside the pad is a 74HC157 ( Quad two input multiplexer ).
The chip inside the control pad is a 74HC157. This is a high-speed CMOS quad 2-line to 1-line multiplexer. Basically, how this works is there are two inputs ( A and B ) for every output ( Y ). There are four groups like this. There is one select signal for the whole chip. When the select signal is low, the output ( Y ) is the same as input A. When the select signal is high, the output Y is the same as input B.
Pad connector :
The line numbers are determined as follows, looking straight at the plug on the front of the Genesis the numbers are:
1 2 3 4 5
6 7 8 9
explanation :
Line 1 Up output.
Line 2 Down output. These are the only two direct connections.
Line 3 Pin 4 of the chip. Output 1Y.
Line 4 Pin 7 of the chip. Output 2Y.
Line 5 This line carries in +5V. It is connected to the +5V bus line.
Line 6 (TL) Pin 9 of the chip. Output 3Y.
Line 7 (TH) Pin 1 of the chip. This carries in a select signal from the Genesis. This is a signal which varies rapidly and controls which input goes through the output
Line 8 Ground. This is connected to the Ground bus line.
Line 9 (TR) Pin 12 of the chip. Output 4Y.
PCF8574 schematic :
List of matérial :
- PCF8574
- 2*82k ohm resistance
- Mega Drive PAD !!!!
line numbers/PCF8574 matching :
Line 1 : Pin 5
Line 2 : Pin 6
Line 3 : Pin 7
Line 4 : Pin 9
Line 5 : Green wire of NXT
Line 6 : Pin 10
Line 7 : Pin 4
Line 8 : Black and Red wire of NXT
Line 9 : Pin 11
NXC Example Code :
#define I2Cport S1 // NXT sensor port 1
#define I2CAddr8574 0x40 // 0x40 8574 or 0x70 for 8574A
byte WriteBuf[] = {I2CAddr8574, 0xFF}; // Sent to 8574
byte ReadBuf[]; // Receive from PCF8574
int RdCnt=1; // Number of bytes to read
void Changer_Sortie(byte Actuel,int sortie,bool valeur)
{
byte masque=0x01;
byte val;
masque=0x01 << sortie;
NumOut(0,LCD_LINE1,masque);
if (valeur==false)
{
val=Actuel | masque;
}
if (valeur==true)
{
masque=255-masque;
//val=0xFF;
val=Actuel & masque;
}
WriteBuf[1]=val;
}
task main (){
SetSensorTouch(IN_2);
SetSensorTouch(IN_3);
SetSensorLowspeed (I2Cport); // Configure NXT port
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf);
while (true)
{
Changer_Sortie(WriteBuf[1],0,false); // Put Line 7 to high
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf); // read the values of 4 first button
NumOut(0,LCD_LINE1,ReadBuf[0]);
Changer_Sortie(WriteBuf[1],0,true); // Put Line 7 to low
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf); // reas the last 4 values
NumOut(0,LCD_LINE2,ReadBuf[0]);
}
}
Source : http://segaretro.org/Control_Pad_%28Mega_Drive%29
Inside the pad is a 74HC157 ( Quad two input multiplexer ).
The chip inside the control pad is a 74HC157. This is a high-speed CMOS quad 2-line to 1-line multiplexer. Basically, how this works is there are two inputs ( A and B ) for every output ( Y ). There are four groups like this. There is one select signal for the whole chip. When the select signal is low, the output ( Y ) is the same as input A. When the select signal is high, the output Y is the same as input B.
Pad connector :
The line numbers are determined as follows, looking straight at the plug on the front of the Genesis the numbers are:
1 2 3 4 5
6 7 8 9
explanation :
Line 1 Up output.
Line 2 Down output. These are the only two direct connections.
Line 3 Pin 4 of the chip. Output 1Y.
Line 4 Pin 7 of the chip. Output 2Y.
Line 5 This line carries in +5V. It is connected to the +5V bus line.
Line 6 (TL) Pin 9 of the chip. Output 3Y.
Line 7 (TH) Pin 1 of the chip. This carries in a select signal from the Genesis. This is a signal which varies rapidly and controls which input goes through the output
Line 8 Ground. This is connected to the Ground bus line.
Line 9 (TR) Pin 12 of the chip. Output 4Y.
PCF8574 schematic :
List of matérial :
- PCF8574
- 2*82k ohm resistance
- Mega Drive PAD !!!!
line numbers/PCF8574 matching :
Line 1 : Pin 5
Line 2 : Pin 6
Line 3 : Pin 7
Line 4 : Pin 9
Line 5 : Green wire of NXT
Line 6 : Pin 10
Line 7 : Pin 4
Line 8 : Black and Red wire of NXT
Line 9 : Pin 11
NXC Example Code :
#define I2Cport S1 // NXT sensor port 1
#define I2CAddr8574 0x40 // 0x40 8574 or 0x70 for 8574A
byte WriteBuf[] = {I2CAddr8574, 0xFF}; // Sent to 8574
byte ReadBuf[]; // Receive from PCF8574
int RdCnt=1; // Number of bytes to read
void Changer_Sortie(byte Actuel,int sortie,bool valeur)
{
byte masque=0x01;
byte val;
masque=0x01 << sortie;
NumOut(0,LCD_LINE1,masque);
if (valeur==false)
{
val=Actuel | masque;
}
if (valeur==true)
{
masque=255-masque;
//val=0xFF;
val=Actuel & masque;
}
WriteBuf[1]=val;
}
task main (){
SetSensorTouch(IN_2);
SetSensorTouch(IN_3);
SetSensorLowspeed (I2Cport); // Configure NXT port
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf);
while (true)
{
Changer_Sortie(WriteBuf[1],0,false); // Put Line 7 to high
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf); // read the values of 4 first button
NumOut(0,LCD_LINE1,ReadBuf[0]);
Changer_Sortie(WriteBuf[1],0,true); // Put Line 7 to low
I2CBytes(I2Cport, WriteBuf, RdCnt, ReadBuf); // reas the last 4 values
NumOut(0,LCD_LINE2,ReadBuf[0]);
}
}
Source : http://segaretro.org/Control_Pad_%28Mega_Drive%29