It is currently Wed Oct 16, 2019 2:34 pm

All times are UTC - 7 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Nov 13, 2016 9:47 pm 

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21634
Location: NE Indiana, USA (NTSC)
I've been discussing a microcontroller project with koitsu if anyone's interested. How hard would it be to make an MCU read a DualShock and output PWM?

Several old computers and video game consoles are designed to use paddles (non-centering absolute rotary inputs) or 2-axis analog joysticks:

  • Apple II: DE9, 2 to 4 paddles or 1 to 2 2-axis joysticks, 3 buttons
  • Atari 2600: 2 paddles, 2 buttons
  • Atari 5200: 2 axes, several buttons
  • IBM PC game port: 4 axes, 4 buttons

All these are potentiometers (variable resistors), normally read by passing a voltage through the pot, feeding the output to charge a capacitor and waiting until an NE555 or compatible timing comparator determines that the cap has charged to 2/3 of reference voltage. (See description of Apple II paddle circuit.) The trouble is that the existing stock of paddles and joysticks are wearing out, and it's also becoming hard to find repair parts such as 150 kilohm pots.

So I thought of a solution: use pulse width modulation (PWM) instead of variable resistance. Output high Z on the pin for an amount of time proportional to the position of the stick, and then slam it to Vcc momentarily. The circuit after the comparator shouldn't be able to tell the difference, should it?

In fact, almost the same protocol would work for the Zap Ruder tech demo, which waits between the top of the screen and when the Zapper's photodiode turns on. Except the "zapkernel" (input routine of Zap Ruder) expects a light pulse that dissipates after 25 lines or so, so it can tell the difference among a Zapper pointed at the screen, a Zapper pointed off-screen (dark for the whole frame), and no Zapper at all (always light even during vblank).

So the idea is to make a microcontroller read a DualShock controller and convert the joystick position from PCM to PWM.

Because joysticks are auto-centering and paddles aren't, a useful "paddle mode" for such an MCU may require a different form of input translation where the pulse width is proportional to arctan2(x, y), with readings held when the stick is near the center dead zone.

Pin Eight | Twitter | GitHub | Patreon

PostPosted: Mon Nov 14, 2016 1:36 am 

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8611
Location: Seattle
I'm not certain whether this "direct emission of time as ADC value" is actually simpler than just using a open-collector pull-up transistor with a current limiter and high PWM frequency to implement an adjustable current source. After all, you have to detect when the hardware discharged the capacitors before you can start your timing loop. But at least the IBM PC joystick port should already have the requisite current limiting resistor on its input to keep the microcontroller's output from getting in a fight with the 558.

PostPosted: Mon Nov 14, 2016 1:51 am 
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4210
Location: A world gone mad
Thanks for posting this, tepples.

My main concern right now is for joysticks, specifically a single-player joystick (but from reviewing the pinout, it looks like supporting two wouldn't add much complexity). Paddles are (IMO) more complicated given the design of the PS2 controller, and the games which use paddles on the Apple II are substantially fewer than those which use joysticks.

I also want to point out that the hookup for this should be the DE9 port, not the internal 16-pin port. I realise the 16-pin port or even something in a card slot provides lots more capabilities, but I'm trying to keep this as practical as possible. It also needs to work on an Apple IIC/IIE, so any "IIGS-isms" might need to be configurable in some way.

There are some other resources I wanted to post here for anyone who would be interested in helping with this, in particular the first link, which contains successful homebrew efforts to build a replacement Apple II joystick and contains relevant circuitry schematics. (Please understand: my goal is not to build a replacement joystick -- I strongly feel an adapter for existing joysticks that are easily purchasable is a much more practical and affordable method). These links are just kind of a "brain dump" of stuff I've come across (either read or skimmed) and found relevant: ... nnector.29 ... oid-mac-pc -- I really don't like this product, too expensive too ... -apple-ii/ -- bad idea IMO (re: USB device compatibility), too expensive -- neat, but isn't what I'm aiming for ... -joystick/ ... S.html#004 -- for PC-to-Apple-II converter details (diagram) ... ystick.pdf -- site is often down but I HAVE gotten this to work before ... Manual.PDF -- page 2-28 onward is extremely relevant

I can't find it in my browser history right now (argh!), but I did come across a page which went over some of the differences between Apple II models (for example something about the IIGS supporting up to 4 buttons, while the IIC/IIE only support 2 or 3, things like this). The last PDF I link to, however, is for the IIGS and goes over what it offers.

BASIC code for verifying 1st joystick behaviour (this can work from both true Applesoft BASIC as well as the built-in ROM):

10 PRINT "X= "; PDL(0); TAB(15); "Y= "; PDL(1); TAB(30);
20 IF PEEK(49249) > 127 THEN PRINT "  B0";
30 IF PEEK(49250) > 127 THEN PRINT "  B1";
50 GOTO 10

The two PEEK locations correlate with $C061 and $C062. PDL() makes things easy for getting axis data (it's more complicated otherwise (no real way to do it in BASIC due to timing; certainly possible in 65xx though)).

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group