Jump to content

Arduino Shield For PORTA Input


k-Pack

526 views

 Over the years I've been using an Arduino UNO to setup data for transfer to the Atari Joystick ports.  The first attempt was to read the data from a  Wii nunchuk and translate it to joystick movements.  Lately I've been experimenting reading midi data using an Arduino Midi Shield, along with using the Cassette Motor Control pin on the SIO port as feedback to the Arduino. You may have read some of these blogs.

 

During the "Switched On POKEY" music experiments, there were many modifications tried and some were put off for later evaluation.  At first the cassette motor control(CMC) pin on the SIO was used to signal the Arduino. Then bit 7 of PORTA(joystick) was set as output and trigger 2 was set and used for bit 7 input.  It worked but didn't solve a click problem I thought I was having when switching the CMC.

 

 

MIDI setup then and now:

1139782126_PrototypewithMIDIshield.thumb.JPG.f8f7bf05083a0e91236853cd79b10316.JPG

 

1391239464_shieldwithMIDIShield.thumb.JPG.f83fe47ed80c7f7aae10f67bf2f1b707.JPG

 

 

It seemed time to gather my thoughts and solder together a prototype shield.  And to,  establish a point of reference for beginning future experiments.

 

From now on I will refer to this Arduino Uno shield  as AU2PORTA.  This shield will be able to set the joystick direction pins (PORTA) and the 2 triggers.  With 1 bit output from the Atari's CMC pin, wired to be used to signal the Arduino when needed.

 

 

1083082856_AU2PORTAshield.thumb.JPG.e310588561dffba70b4c478f4dbbbbfa.JPG

 

 

The parallel data transfer used most of the digital lines. D0 and D1 are used for serial communication with the MIDI shield (or computer) leaving D2 free for other uses.  The Analog signal lines are still avalible for analog input, I2C devices or reading voltages of digital logic signals.

 

AU2PORTA.thumb.jpg.ed2b7561785e27cab3f42f92efb1560e.jpg

 

The ground for each of the joysticks are separate.  This allows the shield to be hooked up to a joystick port of different computers and maintain separate grounds. This might come in handy someday.

 

The circuits use 11 optocouplers (PS2501).  Some people may think I am being overprotective of my Atari computers but I prefer to think of it as being very protective of my computers.  These isolators will keep the Arduino and Atari circuits from harming each other, no matter what gets hooked up to the Arduino.

 

Note:  The prototype circuit uses the PS2501 for CMC feedback bit and worked.  I grabbed a PS2502-1 optocoupler from the parts bin while building the shield.  The PS2501 has one transistor while the PS2502 has two in a Darlington configuration.  They both work. The next shield that gets built will use a PS2501-1.

 

The shield was soldered and tested using the following Arduino program that set all the digital pins HI and then LOW.

 

*The Arduino toggles the pins wired for the Atari to read.

 *

 *The CMC circuit is not tested.

 *

*/

// Atari PORTA(54016) mapped to pins on Arduino

int porta0 = 4;

int porta1 = 5;

int porta2 = 6;

int porta3 = 7;

int porta4 = 8;

int porta5 = 9;

int porta6 = 10;

int porta7 = 11;

int trig1 = 3;

int trig2 = 12;

 

int digPin=0;

 

void setup() {

  pinMode(porta0,OUTPUT);

  pinMode(porta1,OUTPUT);

  pinMode(porta2,OUTPUT);

  pinMode(porta3,OUTPUT);

  pinMode(porta4,OUTPUT);

  pinMode(porta5,OUTPUT);

  pinMode(porta6,OUTPUT);

  pinMode(porta7,OUTPUT);

  pinMode(trig1,OUTPUT);

  pinMode(trig2,OUTPUT);

}

 

void loop() {

 for (digPin = 3; digPin<13; digPin++) {

    digitalWrite(digPin,HIGH);

    }

  delay(200);

 for(digPin = 3; digPin<13; digPin++) {

    digitalWrite(digPin,LOW);

    }

  delay(200);

}

 

 

Then when the Arduino and Shield are hooked up to the joystick ports this next small Atari BASIC program was used to read the trigger and joystick.  15 means all Arduino controlled digital pins are LOW.  0 for all HIGH.  Triggers; Arduino is HIGH and Atari reads 0.(Note the reverse logic.  Arduino - LOW/Atari - HIGH. Very important when programing)

 

10 ? STICK(0),STRIG(0),STICK(1),STRIG(1):LAST = STRIG (0)

20 IF STRIG(0)=LAST THEN 20

30 GOTO 10

 

Once the 3 bad solder connections were fixed, the following program was used to toggle the Cassette Motor control on the SIO port.  A Volt meter was used to read the voltage drop across the 1K resistor as it was switched.  Atari HIGH - Arduino HIGH.

 

10 POKE 54018,52:REM TURN ON CMC

20 FOR X=1 TO 200:NEXT X

30 POKE 54018,60:REM TURN OFF CMC

40 FOR X=1 TO 200: NEXT X

50 GOTO 10

 

The next task is to optimize the data transfer routines and resolve problems that are caused by the reverse pin logic and the startup logic defaults.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...