วันอังคารที่ 23 ตุลาคม พ.ศ. 2555

ZX- PSX + Unicon Board

การเชื่อมต่อจอยสติ้ก เข้ากับ Unicon Board
ก่อนอื่นทำความรู้จักกับสัญญาณต่างๆกันก่อน แล้ว ทำการเชื่อมเข้ากับบอร์ด ZX- PSX ที่เป็นตัวเชื่อมต่อสัญญาณขาต่างๆให้เข้ากับตัว Unicon ได้

PIN # USAGE
  1. DATA
  2. COMMAND
  3. N/C (9 Volts unused)
  4. GND
  5. VCC
  6. ATT
  7. CLOCK
  8. N/C
  9. ACK
DATA
Signal from Controller to PSX.
This signal is an 8 bit serial transmission synchronous to the falling edge of clock (That is both the incoming and outgoing signals change on a high to low transition of clock. All the reading of signals is done on the leading edge to allow settling time.)
COMMAND
Signal from PSX to Controller.
This signal is the counter part of DATA. It is again an 8 bit serial transmission on the falling edge of clock.
VCC
VCC can vary from 5V down to 3V and the official SONY Controllers will still operate. The controllers outlined here really want 5V.
The main board in the PSX also has a surface mount 750mA fuse that will blow if you try to draw to much current through the plug (750mA is for both left, right and memory cards).
ATT
ATT is used to get the attention of the controller.
This signal will go low for the duration of a transmission. I have also seen this pin called Select, DTR and Command.
CLOCK
Signal from PSX to Controller.
Used to keep units in sync.
ACK
Acknowledge signal from Controller to PSX.
This signal should go low for at least one clock period after each 8 bits are sent and ATT is still held low. If the ACK signal does not go low within about 60 us the PSX will then start interogating other devices.
It should also be noted that this is a bus of sorts. This means that the wires are all tied together (except select which is seperate for each device). For the CLK, ATT, and CMD pins this does not matter as the PSX is always the originator. The DATA and ACK pins however can be driven from any one of four devices. To avoid contentions on these lines they are open collectors and can only be driven low.

เนื้อหาจาก http://www.gamesx.com/controldata/psxcont/psxcont.htm


ZX - PSX 

ทดสอบการทำงาน ดังนี้คือ 

#include <Psx.h>          // Includes the Psx Library ดาวน์โหลดได้จากลิงค์ข้างล่าง
#define Din 19          //ขา Din  ของ zx psx
#define Dout 20          //Dout  ของ zx psx
#define CS 21           //CS ของ zx psx
#define CLK 22         //CLK ของ zx psx
#define LEDPin 13
Psx Psx;                   // Initializes the library

unsigned int data = 0;     // data stores the controller response

void setup()
{
  Psx.setupPins(Din, Dout, CS, CLK, 10);                
  pinMode(LEDPin, OUTPUT); 
}
void loop()
{
  data = Psx.read(); 
  if (data & psxR2) // ตรวจเช็คค่าที่ได้จากการกดปุ่ม ถ้าค่าที่ได้จากการกดมีค่าตามที่กำหนดไว้ในไลบารี Psx.h  
  {
    digitalWrite(LEDPin, HIGH); 
  }
  else
  {
    digitalWrite(LEDPin, LOW); 
  }
}






ดาวน์โหลด ไลบารี่ Psx.zip




ไม่มีความคิดเห็น:

แสดงความคิดเห็น