madscijr Posted July 22, 2019 Share Posted July 22, 2019 (edited) I've seen USB adapters for connecting Atari 2600 paddle controllers to a PC, but what about connecting USB optical mice to a real Atari to use as paddles? I'm interested in trying a regular wired USB optical mouse or PC wired USB optical trackball for controlling paddle games - not only would it give a different gaming experience than paddles, but optical controllers would also be "jitter proof". I have already made my own spinner controllers for MAME and Stella on the computer very simply, by duct-taping an optical mouse against a shaft (such as a wood dowel, or a wood dowel through a section of foam pool noodle) connected to a knob, and it works beautifully. So I am curious about making an adapter using an Arduino or Raspberry Pi or similar, that you can plug the mouse into, and outputs the variable resistances that would emulate a real paddle controller on the 2600. (The paddle button would be a simple matter of wiring the button to the appropriate pins.) Has anyone tried this, seen a page on this, or got any idea how a microcontroller might output the resistance range (1M ohm) that a native 2600 paddle controller would? Edited July 22, 2019 by madscijr Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/ Share on other sites More sharing options...
Stephen Moss Posted July 23, 2019 Share Posted July 23, 2019 Seem to me to be a lot of engineering overkill for something that is just a potentiomer and a switch and I don't think that what you want to do is possible, at best it is very difficult as it is an entirely different proposition to your MAME/Stella controller which is still just reading a USB mouse and is already coded to convert the mouse data to a relevant value using the PC's native USB host controller, OS host software and Mouse Driver. You may find examples of using the Arduino's & Pi's as USB slave devices but finding examples of USB host probably don't exist as making a host in much harder than a slave so not many (if anyone) makes DIY USB host devices. 1) I think you will need to write your own USB host controller code & mouse driver (which is where the difficulty lies), certainly for the Arduino as the Pi must already have that for using keyboard & mouse but I don't know how you would tap into the data on the Pi as it may only be accessible by the OS. 2) There is no USB A port to plug the mouse into on the Arduino, only a USB B as it is a slave device. You can add one but being more of a children's toy rather then something for real engineering to my I don't think the micro-controller devices on the Arduino have USB OTG capabilities and the on board USB interface chip is configured to make the Arduino appear to the PC as a serial port slave. Even if you could reprogram the on board USB interface device to host you then would not be able to program the Arduino so you would need a USB OTG device for the mouse. 3) As I recall USB mice provide relative data, i.e. how far it was moved in the X & Y directions as a signed 8 bit integer which would be difficult to convert to a relative value. I would assume that you would need to divide the mouse value by say 10 to get a usable scale otherwise you would only get max L & R, use the sign as direction (L or R) relative to current position. 4) If you could do all the above there is no simple way to recreate a potentiometer. There are digital pots but they tend to be double ended (5 & 0V) and you need single ended (just 5V), you could use a motor to turn an physical pot but then why not just do that to begin with as it is much simpler than faffing about with Arduino's & Pi's. But if you did get this far the better options would probably be to convert the position value to an analogue voltage & either feed it in via a fixed resistor or to the GATE of an FET (source to 2600 input, Drain to 5V) so the varying voltage (instead of varying resistor) adjusts the current charging the capacitor. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4315202 Share on other sites More sharing options...
emerson Posted July 23, 2019 Share Posted July 23, 2019 Here is a USB Host controller IC that connects to a microcontroller via SPI. https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3421E.html Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4315542 Share on other sites More sharing options...
madscijr Posted July 24, 2019 Author Share Posted July 24, 2019 (edited) Thanks for your replies. I did some more digging and I think it will definitely be possible (lots of links listed below). Mouse input - looks like the mouse reading can be very easily done, there are plenty of examples of reading PS/2 mouse with Arduino and you can just plug a USB optical mouse into a USB to PS/2 adapter. I have used these adapters with many old computers.$2 for the PS/2 socket, and if you need an adapter it's $2. There are breakout boards for USB input for Arduino, but the Raspberry Pi has that built in. Recreating the potentiometer - basically we want to create a digital potentiometer - one way might be just to connect matrix of fixed resistors (or just potentiometers tuned to the values) to switches on the Arduino in a binary pattern, that add up to 1M Ohm (1000000 ohms). The more resistors/switches, the more "bits" you have, for higher resolution. For example an 8-bit resolution 1M Ohm digital potentiometer can be made with 8 resistors of these values: Bit Value (Ohms) 1 500000 < most significant bit (MSB) 2 250000 3 125000 4 62500 5 31250 6 15625 7 7812.5 8 3906.25 < least significant bit (LSB) 996093.75 subtotal, comes close to the full 1000000 Ohms These values should provide 256 discrete resistances, which exceeds the 160 pixel horizontal resolution of the 2600. You could add a 9th bit and get 512 discrete resistances (with each bit you add, the number of resistances can be doubled). It really comes down to how many switches the given Arduino / Pi / etc. can control. I see an Arduino Uno R3 board for $15 that has 14 digital input/output pins. Then just have your Arduino program close switches along the circuit path to bypass/short the given resistors to achieve the desired resistance. I'm not sure about the current - a quick google says Atari paddle's pin outputs 5v but not sure what current it carries. You can check with a multimeter (I have a "dummy load" gadget somewhere if I need it). Anyway, need to make sure it doesn't overload the Arduino digital outputs. According to https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins the limit for Arduino is: DC Current per I/O Pin: 40.0 mA DC Current per VCC and GND Pins: 200.0 mAOverall DC current limit for all IO pins put together: 200 mA If the current is greater than what the Arduino's digital switches support, you would have it use transistors (I have seen some Arduino packages include Darlington transistor arrays out of the box). But it's a common problem with plenty of info available. The Darlington transistors should be fine - I don't imagine the Atari would use paddle voltages big enough that you'd need to use relays (which are slow, maybe too slow to keep a game controller responsive). This might take some experimenting to "calibrate" the resistances, but I don't see why it couldn't be done. The bit patterns for the various resistances can either be calculated or even stored in a lookup table to speed it up. Regarding the part about the USB mouse providing relative data, you would probably track a virtual "position" in the Arduino, and output based on that. Maybe add a "panic" button to reset/or center the mouse? I don't know, this would just take some playing around to find out. Not sure if one Arduino could be used as an adapter for 2 or more mice. I saw some posts on reading multiple devices, but would need to read more on it. Theoretically the perfect adapter would let you plug in 4 USB mice, and have 2 9-pin outputs that plug into an Atari, but you might have to build 1 adapter per mouse, where 2 adapters would combine their output into a single 9-pin plug that plugs into the Atari? This is all theoretical at this point, but fun to think about! Some links I found: Micro Connectors USB Female to PS/2 Male Adapter $1.99 at Frys https://www.frys.com/product/3470833?store=32&gclid=CjwKCAjwg-DpBRBbEiwAEV1_-LBP0wQgTWY04b3YUzia7Vmjb3NRNFzpyc5nobYSrP75AWVi-ohp0RoCX8YQAvD_BwE Breakout board for PS/2 Socket $2 at Cytron https://www.robotshop.com/en/cytron-breakout-board-ps-2-socket.html?gclid=CjwKCAjwg-DpBRBbEiwAEV1_-IriJMjpOkzehKzOuMYQDxNwzf1MMjTxopXG5J4mm078Y0uNCHD_kBoCvd4QAvD_BwE PS2 mouse interface for Arduino https://playground.arduino.cc/ComponentLib/Ps2mouse/ GitHub - rucek/arduino-ps2-mouse https://github.com/rucek/arduino-ps2-mouse GitHub - kristopher/PS2-Mouse-Arduino: Arduino/Wiring Library for interfacing with a PS2 mouse. https://github.com/kristopher/PS2-Mouse-Arduino Reading ps2 mouse output with an Arduino (PDF) https://www.robocore.net/upload/attachments/readingps2mouseoutputwithanarduinofinal_769.pdf Arduino PS2 Mouse Interfacing Project with Circuit Diagram https://www.engineersgarage.com/embedded/arduino/how-to-interface-ps2-mouse-with-arduino Arduino Playground - InterfacingWithHardware - Mouse https://playground.arduino.cc/Main/InterfacingWithHardware/#mouse Grove - PS/2 Adapter https://seeeddoc.github.io/Grove-PS-2_Adapter/ Modern mice for old computers http://danceswithferrets.org/geekblog/?p=575 MAX3421E - USB Peripheral/Host Controller with SPI Interface - A Single IC with USB Functionality https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3421E.html Connect PS/2 Keyboard to Arduino https://www.instructables.com/id/Connect-PS2-Keyboard-to-Arduino/ USB mouse library working for anyone https://forum.arduino.cc/index.php/topic,21655.0.html USB ports, one Arduino multiple HID? https://forum.arduino.cc/index.php?topic=514218.0 Darlington Driver 8-Channel ULN2803 DIP - COM-00312 - SparkFun Electronics $1.95 https://www.sparkfun.com/products/312 ULN2003A Darlington Transistor Array Circuit Examples http://www.bristolwatch.com/ele/uln2003a.htm Use Arduino With TIP120 Transistor to Control Motors and High Power Devices https://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/ ULN2003A Darlington Transistor Array Circuit Examples http://www.bristolwatch.com/ele/uln2003a.htm ULN2803: 8 Channel Darlington Driver (Solenoid/Unipolar Stepper) [ULN2803A] ID: 970 - $1.95 : Adafruit Industries, Unique & fun DIY electronics and kits https://www.adafruit.com/product/970 Using MOSFETs versus Darlington Transistors. https://forum.arduino.cc/index.php?topic=198558.0 arduino - Darlington MOSFET Problem - Electrical Engineering Stack Exchange https://support.google.com/chrome/?p=help&ctx=keyboard#topic=7438008 I need a switch on/off power of 18V 20Amp with a arduino. Not sure what to use. https://forum.arduino.cc/index.php?topic=439170.0 Edited July 24, 2019 by madscijr Darlington transistor arrays Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4315963 Share on other sites More sharing options...
ChildOfCv Posted July 24, 2019 Share Posted July 24, 2019 That seems more complicated than it needs to be. The TIA reads the paddle controls by discharging the capacitor on the input and then letting the paddle recharge it through a variable resistor and timing how long it takes to reach the threshold. You can fit into this by putting a diode and a suitably large resistor (maybe start with 10K) on a PWM output. The lower the mouse reading, the longer the pulse width. This will vary the capacitor's charging time in the same way that the paddle would. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4315997 Share on other sites More sharing options...
madscijr Posted July 24, 2019 Author Share Posted July 24, 2019 2 hours ago, ChildOfCv said: That seems more complicated than it needs to be. The TIA reads the paddle controls by discharging the capacitor on the input and then letting the paddle recharge it through a variable resistor and timing how long it takes to reach the threshold. You can fit into this by putting a diode and a suitably large resistor (maybe start with 10K) on a PWM output. The lower the mouse reading, the longer the pulse width. This will vary the capacitor's charging time in the same way that the paddle would. Hmm... So would you attach the PWM output directly to pin 9 (for 5 for the other paddle) and leave pin 7 (+5v) disconnected? Pin Atari VCS 1 Up 2 Down 3 Left 4 Right 5 Paddle B 6 Button 7 VCC (+5 V) 8 GND 9 Paddle A Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316092 Share on other sites More sharing options...
alex_79 Posted July 24, 2019 Share Posted July 24, 2019 3 hours ago, madscijr said: Mouse input - looks like the mouse reading can be very easily done, there are plenty of examples of reading PS/2 mouse with Arduino and you can just plug a USB optical mouse into a USB to PS/2 adapter. I have used these adapters with many old computers.$2 for the PS/2 socket, and if you need an adapter it's $2. Those adapters only change the shape of the connector, but they do not contain any electronics. They only work with mice that are dual standard (that can use both usb and PS/2 protocol). Those were common a few years ago, but I think most new mice are usb only, and the adapter is useless in that case. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316101 Share on other sites More sharing options...
madscijr Posted July 24, 2019 Author Share Posted July 24, 2019 (edited) 59 minutes ago, alex_79 said: Those adapters only change the shape of the connector, but they do not contain any electronics. They only work with mice that are dual standard (that can use both usb and PS/2 protocol). Those were common a few years ago, but I think most new mice are usb only, and the adapter is useless in that case. That's good to know. But no matter, they're still easy to find and dirt cheap, on ebay or any goodwill store (PS/2 optical or older USB optical that work with PS/2 adapters). And Raspberry Pi has USB inputs and can do PWM, if you don't want to go the PS/2 route. Edited July 24, 2019 by madscijr Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316138 Share on other sites More sharing options...
ChildOfCv Posted July 24, 2019 Share Posted July 24, 2019 1 hour ago, madscijr said: Hmm... So would you attach the PWM output directly to pin 9 (for 5 for the other paddle) and leave pin 7 (+5v) disconnected? Pin Atari VCS 1 Up 2 Down 3 Left 4 Right 5 Paddle B 6 Button 7 VCC (+5 V) 8 GND 9 Paddle A You'd need pins 7 and 8 to power your microcontroller. But otherwise, yeah use the PWM output from the controller to charge the Atari's capacitor. You can reduce the "low" time of the pulse rather than increasing the "high" time in order to provide a timing curve that approximates the paddle's potentiometer. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316139 Share on other sites More sharing options...
madscijr Posted July 24, 2019 Author Share Posted July 24, 2019 28 minutes ago, ChildOfCv said: You'd need pins 7 and 8 to power your microcontroller. But otherwise, yeah use the PWM output from the controller to charge the Atari's capacitor. You can reduce the "low" time of the pulse rather than increasing the "high" time in order to provide a timing curve that approximates the paddle's potentiometer. That sounds nice and easy, and I like that the whole thing would be powered by the console. Would the Atari’s one 5v paddle pin supply enough juice to drive an Arduino or Pi (or 2, if one can’t simultaneously read 2 mice) and up to 2 optical mice? I was expecting the controller to need its own power source. Which uC do we want? The Arduino Uno has up to 6 pwm outputs, and I read the Pi has 1 (I recall reading something like it technically has 2 but only one is user programmable?) If the controller can distinguish & read two usb or ps/2 mice plugged into it, and can drive 2 pwm outputs, then you only need one controller per pair of paddles (1 uC per port). Else you need 1 controller per paddle (2 per port). Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316161 Share on other sites More sharing options...
ChildOfCv Posted July 24, 2019 Share Posted July 24, 2019 Just as a note, the RPi is 3.3V-based. It may tolerate 5V inputs, but it won't have 5V outputs. So I would suggest something from the Atmel or PIC line that runs on 5V. I know they make chips that have direct USB support (Arduino Uno actually has 2 Atmega chips, one that has integrated USB and runs the bootloader, and the main one). As for what the Atari can power, pin 7 is connected directly into the 5V rail. There are some voltage spike issues to solve, where 74xx chips can cause static on the screen. But this application necessarily limits power output and might be exempt from that issue. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316178 Share on other sites More sharing options...
madscijr Posted July 24, 2019 Author Share Posted July 24, 2019 (edited) 45 minutes ago, ChildOfCv said: Just as a note, the RPi is 3.3V-based. It may tolerate 5V inputs, but it won't have 5V outputs. So I would suggest something from the Atmel or PIC line that runs on 5V. I know they make chips that have direct USB support (Arduino Uno actually has 2 Atmega chips, one that has integrated USB and runs the bootloader, and the main one). As for what the Atari can power, pin 7 is connected directly into the 5V rail. There are some voltage spike issues to solve, where 74xx chips can cause static on the screen. But this application necessarily limits power output and might be exempt from that issue. Thanks for all that info. BTW, the input device doesn’t have to be an optical mouse - you could use an ultrasonic Ping range sensor, or a photoresistor, or Theramin-like antenna to get analog input. The range sensor appeals to me because you could set it up to make a pong paddle follow your hand movement. Of course, you can just play on the Stella emulator on PC and the mouse controls the paddle. But what about 4 player games? Have they got Stella working with multiple mice? I know Windows has this raw input API to read multiple mice and keyboards. It would be awesome to make a pong/breakout/video olympics/pinball type construction set, the number of players limited only by the number of people, mice, and USB ports... Edited July 24, 2019 by madscijr Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316197 Share on other sites More sharing options...
Stephen Moss Posted July 25, 2019 Share Posted July 25, 2019 15 hours ago, madscijr said: I'm not sure about the current - a quick google says Atari paddle's pin outputs 5v but not sure what current it carries. You can check with a multimeter (I have a "dummy load" gadget somewhere if I need it). Maximum current will flow when when the capacitor is discharged and the wiper is at the 5V end of the pot. But your are limited by a maximum 40mA available 5/40mA = 125 so if you put a 150 ohm resistor in series with the output that will ensure you don't exceed the 40mA. If you proceed with your potential divider method it is a relatively small value in relation to your currently selected LSB value that it should have little impact on the overall resistance. You could try analogue switch IC's but may be better off with SIL relays for this. Actual current used to charge a capacitor via a resistor varies as a factor of both with the resistance value and voltage across it. As the 2600 input capacitor charges the voltage across it increases and that across the resistance decreases by a corresponding amount, consequently as I = V/R, I reduces as C charges. That is why charging of a capacitor through a resistor is not linear, i.e it takes 0.6 * CR to charge to two thirds and 1.6 * CR to fully charge. 14 hours ago, ChildOfCv said: You can fit into this by putting a diode and a suitably large resistor (maybe start with 10K) on a PWM output. The lower the mouse reading, the longer the pulse width. This will vary the capacitor's charging time in the same way that the paddle would. I am assuming that once the capacitor has charged to the trigger voltage an interrupt occurs and a timer value is read to determine the position rather than the TIA reading the voltage every vertical blank and performing an A-D conversion to find the position as for the latter synchronisation of the PWM with VBL would be virtually impossible and the resulting position value would be wrong. Also, if that is how it works the D-A conversion method of using a varying voltage to charge C through a fixed R I mentioned before would not work as the charging voltage may be lower than the trigger threshold voltage. But I am not sure that PWM would produce the correct results either as taking the original maximum 1M controller resistance and assuming that we can apply I= V/R to correctly calculate I, then would it not follow that the diode drop would reduce V, thereby reducing I and increasing the charge time and thus resulting incorrect positioning? Using a Schottky diode may lesson any such effects enough not to matter. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316567 Share on other sites More sharing options...
ChildOfCv Posted July 25, 2019 Share Posted July 25, 2019 3 hours ago, Stephen Moss said: I am assuming that once the capacitor has charged to the trigger voltage an interrupt occurs and a timer value is read to determine the position rather than the TIA reading the voltage every vertical blank and performing an A-D conversion to find the position as for the latter synchronisation of the PWM with VBL would be virtually impossible and the resulting position value would be wrong. All the descriptions that I've seen are that this is purely a software-led method of reading, pretty much the same as what PC does. You set a certain bit in the VBLANK register to discharge the capacitor, then clear that bit. Now you run a timing loop polling the input in question until it reads "high". The Atari itself has a .068uF capacitor on each of the paddle inputs, and the paddle itself is a 470K potentiometer with one side connected to 5V and the wiper connected to the paddle input. So it will eventually charge the capacitor to 5V (and somewhere along the way it will be presented to software as "high"). So no, this isn't the traditional A/D conversion. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4316657 Share on other sites More sharing options...
madscijr Posted July 26, 2019 Author Share Posted July 26, 2019 Thank you everyone for all your input! This discussion has gone way beyond my very limited understanding of electronics, I don’t mind hacking around with connecting a ps/2 mouse to Arduino (which there are instructions for) and programming it the read the input to control resistances, but getting into stuff like sending voltages into my Atari console scares me. My electronics knowledge & skills are more at the level of being able to following wiring diagrams to hook stuff together, but calculating current and voltages is a little beyond me, I’d probably end up frying my Atari (and myself)! So even though wiring up a bunch of resistors to switches or transistors for a rudimentary digital potentiometer is not a very elegant or efficient way to solve the problem, I probably would be less likely to blow something up with this method than messing around with sending voltage via pwm and having to mess with capacitors and diodes. I’m all for learning but know thy limitations may help avoid loss of time, equipment, life! Lamely yours, me Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4317265 Share on other sites More sharing options...
ChildOfCv Posted July 26, 2019 Share Posted July 26, 2019 As for danger to you, you will never see any voltage that could even give you a buzz, let alone kill you. 5V max. Unless you push needles into your body to hit a nerve directly and then apply some voltage across them, you're just not in any danger there. Really, you won't have any trouble with PWM output either. But if you do the resistor thing, you have the MSB and LSB backwards in your description. Resistance is... resistance to current flow. Lower resistance values = less resistance to current, which means more current flow. So the lowest resistor value should be connected to the highest bit. Also, if you use this method, then port bits should be programmed either to output 1 or to disconnect entirely. If you output a zero, you'll be creating a voltage divider that prevents the capacitor from charging to 5V at any time. Third, make sure that whatever you use can output 5V. I don't know what the threshold voltage for the TIA pot inputs is, but you may have trouble with 3.3. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4317281 Share on other sites More sharing options...
madscijr Posted July 27, 2019 Author Share Posted July 27, 2019 Thanks for the tips and vote of confidence, 5v sounds like the way to go. Quote Link to comment https://forums.atariage.com/topic/293688-optical-usb-mouse-to-atari-2600-paddle-adapter-arduino-diy/#findComment-4317606 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.