Jump to content





Proportional control auto-fire for Pole Position steering - fail

Posted by k-Pack, 03 August 2016 · 510 views

arduino
Proportional control auto-fire for Pole Position steering - fail

Ever since the first time the Wii nunchuk was hooked up to the A8 (NUNCHUK + ARDUINO = ATARI JOYSTICK) I've been wondering if it would be possible to use the analog stick readings to adjust an autofire rate to steer the car in Pole Position.  The  Arduino Uno,  a 10kohm variable resister and a few parts was all it took to convince me that it wasn't going to work.
 
Before the Arduino was hooked up, the Pole Position cartridge and joystick were plugged into the computer.  While jogging the joystick left or right, it was observed that the controls were slow to respond, resulting in a lack of steering control.  Experimentation continued with the Arduino Uno to gain some experience for future reference.
 
The Arduino was set up with an analog reading taken by adjusting a 10K variable resistor and the output was sent to the joystick ports for left and right pins. 
 
Attached Image
 
The Arduino sketch simply takes the analog reading at a given frequency and then sets the "on" duration, proportional to the analog reading. 
 /*
 *  Simple test of variable autofire for right and left turn
 *  Adjustable resistor/ no joystick
 *  .5 second cycle adjusted on/off period
 */
  // Variables
int resistor = 0; // Analog channel
int Left_Pin = 5;
int Right_Pin = 6;
int steer = 0;
int turnRate = 0;
void setup() {
  pinMode(Left_Pin,OUTPUT);
  pinMode(Right_Pin,OUTPUT);
}
void loop() {
  steer = analogRead(resistor);
  if(steer  < 500){
    turnRate = (500-steer)/2;
    digitalWrite(Left_Pin,HIGH);
    delay(turnRate);
    digitalWrite(Left_Pin,LOW);
    delay(250-turnRate);
  }
  if(steer>524){
    turnRate= (steer-524)/2;
    digitalWrite(Right_Pin,HIGH);
    delay(turnRate);
    digitalWrite(Right_Pin,LOW);
    delay(250-turnRate);
   
  }
}
This BASIC test program was used to verify the input.  You should be able to hear the sound pulses change as the variable resister is changed.
 
10 IF STICK(0)=15 THEN SOUND 0,0,0,0
20 IF STICK(0)=11 THEN SOUND 0,100,10,10
30 IF STICK(0)=7 THEN SOUND 0,150,10,10
40 GOTO 10
 
The computer was booted up with Pole Position.  The timing parameters in the sketch were adjusted several  different times.  When the on pulses were to short the computer never detected them and the same was determined when they were to long.  Ever once in a while a sweet spot was found, were the steering seemed to jog at the proper rate to keep the car on the track, but never with any predictability.
 
Never got the nunchuk hooked up for a testing.  If this had been close to working a more refined way of output timeing would have been needed.  The other joystick pins would need to be checked while still outputing the steering pulses. However, the idea of an adjustable auto fire circuit on any of the joystick pins may find a use in the future.






If Pole position uses the OS shadow locations for the joystick, then the value is read and updated once per frame. If the device is toggling the joystick direction bits faster than once per frame then the game and device can get out of sync and you'll see unpredictable fast/slow steering behavior. That's my theory.
  • Report

Since I could manually move the joystick fast enough for the computer to miss the change, I'm thinking that the status of the joystick ports are not being checked even that often.  When you play the game and look for it, you'll notice the lag time.

  • Report

Latest Visitors