Using AC turntable with CS controller

Getting ready to fulfill my wish to play CS 5-keys with an ASC (arcade style controller)!

I created a module that reads the arcade turntable’s sensors and converts them to Up/Down signals on PlayStation.

How it works

To detect turntable rotation, it uses two sensors (photointerrupters / transmission-type photosensors).

This site has more info:
CS controller: How the turntable works

Program

I created a program that takes Left/Right signals from the turntable and converts them to Up/Down keys on PlayStation.

I used a PIC10F320 for this one.

#pragma config FOSC = INTOSC
#pragma config BOREN = ON
#pragma config WDTE = OFF
#pragma config PWRTE = ON
#pragma config MCLRE = OFF
#pragma config CP = OFF
#pragma config LVP = OFF
#pragma config LPBOR = ON
#pragma config BORV = LO
#pragma config WRT = OFF

#include <xc.h>
#define _XTAL_FREQ 4000000

char currentScrState=0b00;
char lastScrState=0b00;

// Timer interrupt process
void __interrupt() InterTimer( void )
{
    if (TMR2IF == 1) {           // Is timer 2 interrupted?
        TMR2IF = 0;
        RA2 = 1;
        RA1 = 1;
        TMR2IE = 0;
    }
}


void main(void) {
    OSCCON = 0b01010000;    //4Mhz
    TRISA  = 0b1001;        //RA3 Left In(RO); RA2 UpOut; RA1 DownOut; RA0 RightIn;
    PORTA  = 0b0110;        //Initialize output
    ANSELA = 0;             //Don't use analog

    T2CON  = 0b01111111;    //Prescaler 64; Timer2 On; Postscaler 16 1.024ms
    PR2    = 146;           //1.024ms*147=150.528ms
    TMR2   = 0;
    TMR2IF = 0;             //Set timer 2 interrupt flag (T2IF) to 0
    TMR2IE = 0;             //Stop timer 2 interrupt
    PEIE   = 1;
    GIE    = 1;

    while(1){
        //Sensor read
        currentScrState=(PORTA & 0b1000)>>2 | (PORTA & 0b01);
        char scr = lastScrState << 2 | currentScrState;
        
        if ( lastScrState != currentScrState) {
            //Scratch up
            //if ( scr == 2 || scr == 11 || scr == 13 || scr == 4 ) {  //Detect rise and fall from all sensors (sensitivity is 4x AC's)
            if ( scr == 2) {  // Only detect when left sensor rises (same sensitivity as AC's)
                RA1=1;
                RA2=0;      //Up signal output
                TMR2IE = 1;
                TMR2IF = 0; //Stop timer start
                TMR2   = 0; //Timer value reset
            }
            //Scratch down
            //if ( scr == 1 || scr == 7 || scr == 14 || scr == 8 ) {  //Detect rise and fall from all sensors (sensitivity is 4x AC's)
            if ( scr == 7 ) {  // Only detect when left sensor rises (same sensitivity as AC's)
                RA2=1;
                RA1=0;      //Down signal output
                TMR2IE = 1;
                TMR2IF = 0; //Stop timer start
                TMR2   = 0; //Timer value reset
            }
            lastScrState = currentScrState;
        }
    }
}

コメント

Copied title and URL