freetz Posted December 13, 2014 Share Posted December 13, 2014 Hi everybody, when using an Arduino board to connect to the Atari joystick ports, there are two ways to set the Arduino's output pins which go to the Atari ports: low (sink to ground GND) or high (5V). This has worked quite well so far, but I've read somewhere that sending 5V to the Atari's input pins - which themselves are set to 5V - might cause problems. Unfortunately, I haven't found a way to make the Arduino output pins to behave as GND and "not connected" instead of GND and 5V, so I wanted to know whether this would indeed be a problem if 5V are sent to the respective input pins or whether this is more of a hypothetical issue. I'd be happy for any suggestions/solutions to this problem! Cheers, F. Quote Link to comment Share on other sites More sharing options...
low.blow Posted December 13, 2014 Share Posted December 13, 2014 (edited) Silly question, but why not leave those pins physically disconnected? n/m, I see. Edited December 13, 2014 by low.blow Quote Link to comment Share on other sites More sharing options...
foft Posted December 13, 2014 Share Posted December 13, 2014 You could use a diode, so the arduino is only able to sink current. 2 Quote Link to comment Share on other sites More sharing options...
ricortes Posted December 13, 2014 Share Posted December 13, 2014 (edited) I'm not perfectly clear on what you are trying to do. At any rate the Atari J/S ports are fairly safe. There is a 220 Ohm current limiting resister<& more> on between the silicon and the port. J/S on an XL/XE use the passive pull up part of the PIA so it should offer and extra bit of protection. The 5V out pin of the J/S port should not be connected to another 5V supply of course and anything attached to a J/S port should take that pin into consideration. BTW: The 2600 is a different kettle of fish. J/S go straight to the 6532. Edited December 13, 2014 by ricortes Quote Link to comment Share on other sites More sharing options...
freetz Posted December 13, 2014 Author Share Posted December 13, 2014 Thanks for all the infos - and so quickly! What I'm trying to achieve is to simulate joystick input for the Atari via the Arduino. I see that diodes would be one option, but I'm also thinking whether it would help to set the Arduino pins to "input" in case there is no activity going on and set them to than output/GND when a given pin is active. This would allow me to keep the board rather small. Would that be an option as well? @ricortes: Sure, I won't connect the 5V output of the joystick port to any other 5V supply, but could you explain a bit how the 6532 of the 2600 is different? Would the VCS be more or less prone to damage in my setting? Thanks again for all the support, Cheers, F. Quote Link to comment Share on other sites More sharing options...
HiassofT Posted December 13, 2014 Share Posted December 13, 2014 I see that diodes would be one option, but I'm also thinking whether it would help to set the Arduino pins to "input" in case there is no activity going on and set them to than output/GND when a given pin is active.I was just going to suggest this, used this method several times (not on atmels/arduinos, but on various other stuff) and it works fine. Depending on the specifics of the chip you might only need to set the output to GND once and then toggle between input (high-Z) and output (GND) mode. Simple way to get an open collector output. Other than that I hooked up various active stuff (AD converters, logic chips, even SRAM) to the joystick port back in the 1980s and never had any issues. All these chips had standard push-pull outputs. The only thing to take care of are the paddle inputs. I think I fried the pot inputs of one POKEY because I hooked up the inputs to a voltage source without any current limiting resistors. so long, Hias Quote Link to comment Share on other sites More sharing options...
freetz Posted December 13, 2014 Author Share Posted December 13, 2014 Thanks, Hias! I was also thinking that setting the output to GND once and then toggle between input and output would be an option, but I'm glad you confirm this! So I'd set for example PORTB to 00000000 (all GND) once in the setup and then in the loop set DDRBto 00001010 for example if I want to activate 'up' plus 'left'? Thanks also for sharing your experience, I also didn't encounter any problems so far, but some guys in a Commodore forum mentioned that I might run into troubles, so I just wanted to make sure... Quote Link to comment Share on other sites More sharing options...
thorfdbg Posted December 13, 2014 Share Posted December 13, 2014 This has worked quite well so far, but I've read somewhere that sending 5V to the Atari's input pins - which themselves are set to 5V - might cause problems. No, don't worry, this is a misinformation. I've successfully connected standard TTL chips (74LSxxx) and standard CMOS chips (40xx) to the Atari joystick ports, and they provide both high and low voltage actively (no Hi-Z state). This doesn't cause any problem. The only problem that may exist is if the microcontroller output does not generate TTL-compatible levels, e.g. if it uses 3.3V for high instead of +5V. In such a case, a series of standard silicon transistors should be sufficient to pull the joystick inputs to low. Otherwise, as I already said, even CMOS chips can pull the joystick inputs both to low and high, without a problem. Quote Link to comment Share on other sites More sharing options...
Bryan Posted December 13, 2014 Share Posted December 13, 2014 Yes, you float the Arduino pins by making them inputs. However, there's no problem with driving the Atari joystick input high as long as the PIA pins are configured to be inputs. Quote Link to comment Share on other sites More sharing options...
freetz Posted December 13, 2014 Author Share Posted December 13, 2014 Thanks, thorfdgb and Bryan, for also confirming that this is not an issue with the Atari! Does any one of you know whether the same applies for tge C64 as well? I was informed in another forum that sending 5V toma direction pin on tge Commodore would cause problems if the CIA pulls them low. This might unintentionally be the case as the CIA handles both joystick and keyboard input. However, when testing my board so far there haven't been any problems. But of course I don't want to take any (obviuos) risks... Quote Link to comment Share on other sites More sharing options...
ricortes Posted December 14, 2014 Share Posted December 14, 2014 The 2600 uses a 6532 RIOT chip hooked directly to the J/S. The 800 computers use a 6520 PIA with the signals going through 220 Ohm resistors. The chips J/S interface part is pretty close in both chips. The 220 Ohm resistors will limit current going into the pin to 5V/220 Ohm or 20 mamp. For most stuff it shouldn't be a problem because the J/S ports are only used as inputs vs. actively driving something high or low. I'm pretty sure they have a fail safe start up mode where they are initialized as inputs. *BUT* there is always the possibility of something going wrong, more so with the 800/400 series. We hang all kinds of junk on our serial ports from modems to printers to 80 column displays. There is the remote possibility something will be set wrong and a pin be left as an output when plugging in your device. The 220 Ohm resistors make it less likely it could cause damage. The 2600 should work most of the time but you never know if a home brew cart or start up transients or even applying 5 volts to a pin with the 2600 off, may cause damage. It's much more like working w/o a net. It was an odd choice to leave out ~$.16 worth of resistors in what was a ~$200+ console that would have made it idiot proof. Of course if you put your device out there, you can just specify a fresh boot of the computer before plugging the device in. Another option would be to power it from the J/S port so it only comes on when the computer does, and specify to unplug it before running anything that toys with the port. You can also just add ~220 Ohm resistors on your board since the total<440 Ohm for the 8 bit, 220/Ohm for the 2600> wouldn't effect anything and make it a little safer. You just never know when someone will unplug their XEP80 and plug in your hack w/o cycling the power. Quote Link to comment Share on other sites More sharing options...
freetz Posted December 14, 2014 Author Share Posted December 14, 2014 Wow, thanks a lot for this detailed analysis, this really helps a lot. I hope that setting the pins to high impedance will provide a suitable and safe approach, but in any case I'll put up a disclaimer that mentiones the caveats you explained. Thanks again, F. Quote Link to comment Share on other sites More sharing options...
k-Pack Posted January 3, 2015 Share Posted January 3, 2015 You may want to consider using an optoisolator or optocoupler between the Arduino board and Joystick port digital input pins 1 to4. Connect the photo transistor side to joystidck pins and ground to act as the switch. Connect input side of the optocoupler to the arduino as you would a LED. Control the Arduino pin with digitalWrite(LEDpin, HIGH/LOW). The optocoupler provides some level of safety since there is no physical contact between the computer and arduino. Check out the blog, "Out of the Pack". There is a couple of examples of this method. Quote Link to comment Share on other sites More sharing options...
freetz Posted January 4, 2015 Author Share Posted January 4, 2015 Sorry for the late reply due to the holidays and thanks for the feedback! I had thought about the optocouplers as well, but that would have further increased the number of parts on the already limited space of the PCB. But luckily I realized that it works (at least for my scenario) to set the pins to high impedance inputs. That way I switch from output to input rather than from output "on" (i.e. 5V) to output "off" and no current flows to the Atari/C64 ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.