Difference between revisions of "49-Way Joystick Conversion Board"

From Williams Arcades Wiki
Jump to navigation Jump to search
Line 12: Line 12:
  
 
Amtel Microprocessor Source Code:
 
Amtel Microprocessor Source Code:
 
+
<nowiki>
 
//Program Written By: Brad Raedel
 
//Program Written By: Brad Raedel
 
//03162020 - Revision 1 - Just get it working
 
//03162020 - Revision 1 - Just get it working
Line 197: Line 197:
 
   digitalWrite(Right,!RtOut[0][AbsPos]);
 
   digitalWrite(Right,!RtOut[0][AbsPos]);
 
}
 
}
 +
</nowiki>

Revision as of 15:23, 17 March 2020

  • The images and most of the information below is from Sean Riddle's site and the work he did building an EPROM based translator. You can visit his site HERE. (Thanks Sean!)

Amtel Microprocessor Source Code: //Program Written By: Brad Raedel //03162020 - Revision 1 - Just get it working //Up int Opto1 = 2; //Input Pin 2 int Opto2 = 3; //Input Pin 3 int Opto3 = 4; //Input Pin 4 int Up = 10; //Output to Game - Pin 10 int Dn = 11; //Output to Game - Pin 11 //Down int Opto4 = 5; //Input Pin 5 int Opto5 = 6; //Input Pin 6 int Opto6 = 7; //Input Pin 7 int Left = 12; //Output to Game - Pin 12 int Right = 13; //Output to Game - Pin 13 //Option Switches - These will be used to select mode/options (0 to 15) int Op1 = A0; //1 int Op2 = A1; //2 int Op3 = A2; //4 int Op4 = A3; //8 int OpVal = 0; //Default to zero bool Opto1St; //Opto States bool Opto2St; bool Opto3St; bool Opto4St; bool Opto5St; bool Opto6St; bool UpSt; //Set HIGH when stick is UP bool DnSt; //Set HIGH when Stick is DOWN bool LtSt; //Set HIGH when stick is LEFT bool RtSt; //Set HIGH when Stick is RIGHT bool LockedStUD;//Used to Latch the UP or DOWN position bool LockedStLR;//Used to Latch the LEFT or RIGH postion int UpVal = 3; //Store the Up position (0-2) int DnVal = 3; //Store the Down postion (0-2) int UpDnPos = 3; //Absolute postion of Up/Down 0 = Top, 6 = Bottom, 3 is Center/Neutral int LtVal = 3; //Store the Left position (0-2) int RtVal = 3; //Store the Right position (0-2) int LtRtPos = 3; //Absolute postion of Left/Right 0 = Left, 6 = Right, 3 is Center/Neutral int AbsPos = 24; //Rows Then Columns - Stored Like this { {Row 0 - 0 to 48},{Row 2 - 0 to 48}...etc.. //Column Zero is the 8-Way With No Dead Zone bool UpOut [1][49] = { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,} }; bool DnOut [1][49] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,} }; bool LtOut [1][49] = { {1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,} }; bool RtOut [1][49] = { {0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,} }; void setup() { Serial.begin(57600); //Disable when not debugging pinMode(Opto1,INPUT); //Set Direction of physical inputs/outputs pinMode(Opto2,INPUT); pinMode(Opto3,INPUT); pinMode(Opto4,INPUT); pinMode(Opto5,INPUT); pinMode(Opto6,INPUT); pinMode(Up,OUTPUT); pinMode(Dn,OUTPUT); pinMode(Left,OUTPUT); pinMode(Right,OUTPUT); pinMode(Op1,INPUT); pinMode(Op2,INPUT); pinMode(Op3,INPUT); pinMode(Op4,INPUT); //Let's get our DIP Switch settings (Will = 0 to 15) if (digitalRead(Op1) == HIGH) { OpVal = 1; } if (digitalRead(Op2) == HIGH) { OpVal = OpVal + 2; } if (digitalRead(Op3) == HIGH) { OpVal = OpVal +4; } if (digitalRead(Op4) == HIGH) { OpVal = OpVal + 8; } //Serial.println(OpVal); } //Main Program that loops void loop() { // Up/Down Logic Opto1St = digitalRead(Opto1); //Read Optical Switch 1 Opto2St = digitalRead(Opto2); //Read Optical Switch 2 Opto3St = digitalRead(Opto3); //Read Optical Switch 2 if (Opto1St == true && Opto2St == true && Opto3St == true) //Determine if the joystick is in the center { LockedStUD = false; //Unlatch to allow Up or Down to assume control UpSt = false; //Clear Up State DnSt = false; //Clear Down State UpDnPos = 3; //Set Vertical position to center } //Latch Direction (Determines if up or down if (Opto1St == false && LockedStUD == false) //UP if True { UpSt = true; //Set UP State to TRUE LockedStUD = true; //We lock the State so DOWN can't Steal it! } if (Opto3St == false && LockedStUD == false) //DOWN if True { DnSt = true; //Set DOWN State to TRUE LockedStUD = true; //We lock the State so UP can't Steal it! } //We will figure out what row we are in (0 to 6 - 3 is center) if (UpSt == true) //Up doesn't need any change since adding the Optical Switches is 0 to 2 { UpVal = Opto1St + Opto2St + Opto3St; UpDnPos = UpVal; } if (DnSt == true) //For Down, we determine how many Optical Switches are Low, add them up then use a look-up table to generate the position 4 to 6 { DnVal = Opto1St + Opto2St + Opto3St; switch (DnVal) { case 0: //All Optos are LOW UpDnPos = 6; break; case 1: //Two of the Optos are LOW UpDnPos = 5; break; case 2: //One of the Optos are LOW (The others are still High) UpDnPos = 4; break; } } // Left/Right Logic Opto4St = digitalRead(Opto4); //Read Optical Switch 4 Opto5St = digitalRead(Opto5); //Read Optical Switch 5 Opto6St = digitalRead(Opto6); //Read Optical Switch 6 if (Opto4St == true && Opto5St == true && Opto6St == true) //Determine if the joystick is in the center { LockedStLR = false; //Unlatch to allow Left or Right to assume control LtSt = false; //Clear Left State RtSt = false; //Clear Right State LtRtPos = 3; //Set Horizontal position to center } //Latch Direction (Determines if Left or Right if (Opto4St == false && LockedStLR == false) //Right if True { RtSt = true; //Set Right State to TRUE LockedStLR = true; //We lock the State so Left can't Steal it! } if (Opto6St == false && LockedStLR == false) //Left if True { LtSt = true; //Set Left State to TRUE LockedStLR = true; //We lock the State so Right can't Steal it! } //We will figure out what row we are in (0 to 6 - 3 is center) if (LtSt == true) //Up doesn't need any change since adding the Optical Switches is 0 to 2 { LtVal = Opto4St + Opto5St + Opto6St; LtRtPos = LtVal; } if (RtSt == true) //For Down, we determine how many Optical Switches are Low, add them up then use a look-up table to generate the position 4 to 6 { RtVal = Opto4St + Opto5St + Opto6St; switch (RtVal) { case 0: //All Optos are LOW LtRtPos = 6; break; case 1: //Two of the Optos are LOW LtRtPos = 5; break; case 2: //One of the Optos are LOW (The others are still High) LtRtPos = 4; break; } } //Calculate the absolute position AbsPos = (UpDnPos * 7) + LtRtPos; //Serial.println(AbsPos); digitalWrite(Up,!UpOut[0] [AbsPos]); digitalWrite(Dn,!DnOut[0][AbsPos]); digitalWrite(Left,!LtOut[0][AbsPos]); digitalWrite(Right,!RtOut[0][AbsPos]); }