You are not logged in.

#51 2015-09-11 00:18:16

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

PCB's arrived today and they work.  Sort of:
27.jpg

There's a couple problems with the boards:
1) I had a the top layer as +5V signal plane, and the bottom layer as ground plane.  The holes for the supports of the DB9 connectors are plated, so boom.  5V to ground.  Not awesome.  I was able to work around it by drilling out those holes a little wider to remove the connection between them, although that leaves the copper planes exposed.  So, I trimmed off the supports on the DB9 connector and that works.  Only one smoked arduino.  smile
2) I left off a connection on one of the axes of the digital potentiometer, so I had to use a patch wire there.

With those two fixes, I was able to use a classic game pad on the //c to play lode runner with both buttons and axes working.
I haven't tested the DIP16 port on the IIgs yet (apparently my DIP16 sockets are for round machine pin connectors, which won't go very well with the cable I've got), or the Atari port (I was waiting on some right angle DB9 connectors for that one), or the paddle connections (I don't think I implemented the software support for those paddles yet, but the Atari one should be).
But hey.  Some level of success!

Also, that DB9 on there mates to the back of the //c pretty well.  Win!

Offline

#52 2015-09-14 21:26:53

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Woo.  Right angle DB9's arrived, and I soldered it up to the Atari input port.  I had connected the Atari button to the arduino analog input 7, which apparently is one of the few analog input pins that are analog input only.   Which means no digital IO and no internal pullup.  I'm working around this by putting an external pullup resistor and doing an analog read to see if the button was pressed.  It works fine, other than the aesthetics of having the external resistor installed on the bottom of the board.
If there's call to make new PCBs, I'll probably swap the paddle inputs with the button input, since all pins are taken, and the paddle inputs are analog only anyway.  That'd mean existing software wouldn't be compatible, so another option would be to just make a spot to solder in a resistor.
I'd probably also make some other changes to the Atari connection to support Atari paddles.  There's 9 pins: up, down, left, right, button, ground are the basics, leaving 3 other pins.  Atari paddles (2 paddles connected to one DB9) use the 3 other pins for +5V and right and left paddles.  That could easily be supported by sharing those two paddle inputs with the paddle headers.  You still only get one combined button input between the two paddles so I'm not sure how useful that'd be for Apple][ games.
As it stands, the Atari controller now works, but is kind of awkward because of the single input button.  LodeRunner is a challenge because you can only fire to the left, since the apple version doesn't sense the direction you're facing for where to make the hole, it just uses the two buttons.

Offline

#53 2015-09-15 02:44:16

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

So, Eudimorphodon, here's the picture of the two boards with the patches installed:
30.jpg
Tomorrow the DIP16 sockets arrive and I can test the IIgs.  Once that's tested, it's "done".
My primary goal has been accomplished of the wii controller extension being usable as an apple2 joystick, so the rest of the behavior is up to you.  smile

Right now, here's the behavior:
The arduino has a reset button on it, so pressing that can reset the adapter without needing to power off or disconnect or anything.
The wii controller needs to be attached at startup to be properly recognized.
Assuming the wii controller has been attached and recognized, it can be used at any time.  I've only tested with official Nintendo peripherals, and I've read some of the cheaper 3rd party ones can behave differently, so I don't know if those will work.
If the nunchuck is being used, the Z-button is button 0, and the C button is button 1.
If the classic/classic pro is being used, the left joystick and the D-pad can be used interchangeably, A and C buttons are button 1, and B and Z buttons are button 0.

If up/down/left/right is pressed on an Atari controller, those directions will be entered as "hard over" in that direction on the Apple2 joystick, and it will indicate the Atari button state should be used for the state of apple button 0.

I have only briefly messed with the paddle controls and my intention is to have the paddle directions only be recognized if we've seen a button press of the paddle button.  Once the button has been pressed, it'll then use both the potentiometer and button states of the paddles for the apple joystick.

I do have a set of Atari paddles, and I can install some patch wires on your board to connect those to the paddle state so Atari paddles can be used.  I'm a bit torn on the best way to detect whether the Atari paddles should be used, since it'll require interpreting the Atari controller input a little differently.  I did break out the last available pin as a jumper, and could use that.  If the jumper is installed, interpret the Atari input as paddles.

Offline

#54 2015-09-15 16:14:56

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Woot! Looks like I missed a couple updates. So... I'm Googling around for a good programmer, is this the "right" one? (It's the one you threw a URL out for earlier.) Wondering because it appears to come in both 3.3v and 5v flavors and I get the impression the Arduino you're using is a clone of this one, and there's a comment that says you need a 3.3v programmer/cable. I'm a little rusty but hopefully starting from your source I can make some progress. smile

(I was actually playing with my II a little this weekend, and now I'm really interested in seeing if I can make a usable "virtual paddle" mode, IE, that thing I suggested for using the joystick input to increment-decrement the position relatively rather than absolutely. That might *almost* obviate most need for a real paddle controller in most circumstances.)


Flap Different.

Offline

#55 2015-09-15 17:01:14

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Right on all counts.  I've got that 5V FTDI programmer and that's what I'm using, with the 3.3V board (it's a clone, but slightly different, in that it has A4-A7 broken out on the end opposite the programming side).  The 5V FTDI programmer does have pads on it to configure 3.3V, although I don't think I ever touched them.

I've put the Arduino sketch, OsmonPCB file, and gerbers here: a2joystick.zip

Offline

#56 2015-09-15 20:39:32

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Okay, so the 5v programmer is okay? I'll see about getting it ordered. Let me know when you want to hand off a test board to me.

(Either via mail, or... I could be mistaken but I've gotten impression you're in roughly the same neighbourhood as I am. If that's not mistaken and you have a yen to go to Weirdstuff or something could hand it off that way.)


Flap Different.

Offline

#57 2015-09-15 21:01:17

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

DIP16 sockets came in and I tested it with the IIgs.  It seems like different machines treat the potentiometer slightly differently, and I had to adjust the capacitors I was using to go from the digitial potentiometer to the paddle inputs on the Apple2 connector.  But I found something that seems to work OK for both the IIgs and the //c that I'm using.  Hopefully it'll work for you too.

Shoot me an email with your address and I'll send one to you now that all the parts are here.  I'm in Idaho, although I do occasionally go down to the bay area.  I don't think I have any trips scheduled in the near future, so mailing it is probably best.

Offline

#58 2015-09-15 22:30:20

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Ah, okay, I've heard you mention bay area-ness a couple times and jumped to the the incorrect conclusion that you were also in the asylum. I'll shoot you an email tonight. Good to know about the capacitor-ness; it might actually be useful to get a data point from a II Plus board. (I also have a IIgs so likewise can see if there's something that can bracket that spread.) If it needs more tweaking it might suggest that a Rev. 2 board should have spots for adjustable trimmers, if they're available in a suitable size.

Out of curiosity, at the board fab you're using would there be any possibility of getting a "card edge" for the Wii connector on the board itself, or does the PCB thickness just not make that a reasonable proposition?

(I suppose there might also be an additional cost for cutting the board to the right shape. I've never had a board done so I have no idea what the costs involved with getting card edge fingers might be. Something I think I want someday is a copy of Willegal's Brain Board because I have this half-witted idea of repairing my spare II board enough that I can put it in a wooden case with Integer Basic ROMs and recreate the experience of someone who traded their Apple I for a bare II board, but in casual searching I haven't found a ready source for II prototyping cards. They are sorta out there on eBay, I guess.)


Flap Different.

Offline

#59 2015-09-15 23:23:51

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Yeah, a future rev of the board should probably include trim pots, but oh well.  I'm not totally sure on making the wiichuck part of the PCB.  Making the whole PCB the required thickness could prove cost prohibitive.  All the PCBs I've done so far have been rectangular, but I haven't seen any reason it couldn't do that.  OshPark is what I used on this version of the board, mainly because of the much faster turnaround time than compared to shipping from china.  They charge by area used, so maybe it's not bad?  I haven't tried.  seed studio is the other place I use, but generally for orders of ~10pcbs at a time.  They charge by maximum external dimensions.

Offline

#60 2015-09-15 23:28:19

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Oh yeah, and this is the simple program I use to test the values the apple is receiving:

10 print pdl(0) " " pdl(1) " " peek(49249) " " peek(49250)
20 goto 10
run

That'll print the two paddle axes and the two buttons.  The computer reports the buttons as analog values, but any value over 127 is a 1 and anything less is a 0.

Offline

#61 2015-09-16 04:13:53

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Mail sent.


Flap Different.

Offline

#62 2015-09-17 19:33:17

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

JFYI, for the DIP cable, I ordered this cable from digikey.  I got both 18" and 36" versions, and they both seem fine.  They look identical to the one that came with my USB board, but be careful with the pins.  I ended up breaking a pin ( PB0 sad ) during my first round of testing when I was plugging it in for testing and unplugging for modifications.

Offline

#63 2015-09-17 21:22:53

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Cool. I do have a big spool of rainbow ribbon cable lying around (I bought it to make some IEEE-488 cables) so I was going to check my favorite local shop to see if they had the press-on connections to make my own, but a source if they don't is good...


Flap Different.

Offline

#64 2015-09-18 23:54:51

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Courtesy of $1.28 and a trip to Anchor Electronics I'm now the proud owner of a self-fabricated 16 pin IEC-DIP jumper cable, and at Fry's I found this knockoff FTDI breakout board that has a jumper to work with either 3.3 or 5v I/O.. Hopefully it'll do the job.

Just for the heck of it also picked up a cheap Uno R3 "starter kit" with jumper wires and lights to blink, etc. Might as well admit it's time to generally get up to speed on Arduino.


Flap Different.

Offline

#65 2015-09-19 01:23:29

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Nice!
Yeah, I'd make fun of the arduino (well, mainly the community, the poor quality of the libraries, and the whole presenting C++ as an interpreted language but not) as much as anyone else, but there's also something to be said for the low barrier to entry, ubiquity, and inexpensive hardware.
I'm also not much of a hardware guy, and my PCBs tend to basically be "Save As..." for my breadboard projects, so I figure using a premade dev board is probably safer from a power perspective than something I'd hack together.

Offline

#66 2015-09-22 04:05:27

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

So...

I got the PCB in the mail on Saturday, finally had a chance to muck with it a little this afternoon. Things are... not quite right.

With boundless optimism I simply wired the unit into my II+ and fired up "number munchers". (Seemed like a reasonable thing to test simple 4 way digital directional control with.) When the program was started with joystick control enabled it simply hung (*). Mucked around, verified my ratty old joystick still worked as expected, and then booted into BASIC for further investigation. Running the BASIC test program indicates the issue seems to be that according to the II+ both "buttons" controlled by the 4066 indicate they're stuck down. (The numbers PEEK-ed are always above 127.) Same results regardless of whether I tried a Nunchuck or a gamepad. (Both genuine Nintendo.) The digital potentiometer portion of the circuit appears to be working correctly, however. (Button input is working on the system, tested with the real joystick again. Also continuity checked my DIP jumper cable and it seems to check out)

I'll look for my teeny test clips and see if I can determine if the problem might be a dead 4066, although I'm not sure how that could have happened. Also see about dragging out the IIgs, I can see if it works on the 9 pin port. Whee.

(* The hanging behavior in that particular program seems to be the program blocking on a button press until the button is released. If the button's stuck down it just waits forever after hitting the main input loop after the "do you want to use a joystick" screen.)

Last edited by Eudimorphodon (2015-09-22 04:07:39)


Flap Different.

Offline

#67 2015-09-22 15:05:57

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Aw man!  I'd be interested in what the results are for the IIgs and any probes you might have. 
I included the header pins for programming, although they weren't soldered on, since it seemed like they'd be in the way when it wasn't being programmed.  I just hold them in place at an angle to ensure contact when I'm messing with it.
If you connect up the programmer, and use a serial terminal with it at 19200 8n1, there will be some initial output when it boots up on what it detected for the wii controller extension.  The Arduino program has a serial monitor functionality built in, so you could use that too.  There's also an #if 0 section in the code that will print out state information to the serial port.  It's disabled because it slows down the polling loop quite a bit to print it out, but enabling it might give some information about whether the arduino thinks it is registering a button change and it's just not working, or if no button change was found.
Here's the latest code, but pretty much the only change from the last one is paddle support.

Offline

#68 2015-09-22 16:16:49

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Oh yeah, don't plug in the programmer while connected to a machine.  That seems like it could be bad.  The board will be powered by the programmer when that's plugged in.

Offline

#69 2015-09-22 17:00:40

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

bbraun wrote:

Aw man!  I'd be interested in what the results are for the IIgs and any probes you might have.

Somewhere buried on my workbench I have one of those little 8 channel USB logic probe/loggers, maybe it's worth jumping straight to that. Simple enough to clip those onto the "throw this switch" lines on the 4066 and see if they're getting actuated.

I included the header pins for programming, although they weren't soldered on, since it seemed like they'd be in the way when it wasn't being programmed.  I just hold them in place at an angle to ensure contact when I'm messing with it.

I was going to ask you about that. I'd gotten the impression that just sort of wedging it in place was indeed something people did. wink

So... just offhand. I was looking at the PCB layouts earlier in the thread (I'll see about getting that OsmonPCB software installed when I have a chance) and the picture of the board (don't have it in front of me), and was wondering if there might be an obscure technical detail that might explain things? Going back to this reference, in the section about buttons, it talks about needing a pulldown resistor to drive the input low when the switch is open. Since the condition I'm seeing is the button seemingly stuck on... is there a pulldown in the circuit I'm not seeing? I'm wondering if there's a change in the later II's circuitry compared to the II/IIplus' that lets them work fine without a pulldown while the II's is floating without it. (TTL vs. CMOS, maybe? Also remember reading that thing about using the joystick ports for networking supposedly Apple did something to "debounce" button presses on the IIe and later by adding a capacitor or something, maybe that could also make the difference?)


Flap Different.

Offline

#70 2015-09-22 19:39:30

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

... hrm. So, in that reference I tossed out above, the schematic that shows an opto-isolator is apparently from the Apple IIc technical manual. Further research reveals there is no such part in the IIe and earlier; the joystick switches terminate directly on a 74LS251. Digging further I found this schematic page on archive.org, and... is it just my imagination, but in addition to an ILQ1 optoisolator does it also sort of look like there's a set of internal pullups? As for the IIgs, plot thickens again. I don't see any indication of either the optoisolator or internal pullups, but the lines terminate on a 74HCT251, not an LS.

I guess what I'm going to try doing is sticking a couple resistors against the apropos legs of the 4066 to ground (IE, on the side facing the Apple II, not +5v) and see if that gives me some love, unless that sounds like a terrible idea.


Flap Different.

Offline

#71 2015-09-22 22:52:27

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Yeah, there's no pullups or pulldowns on the output of the 4066, so it might not be a bad idea to see if you can add some and see how that goes.  pulldowns seem like the right thing to do.

Offline

#72 2015-09-22 22:56:45

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Righto, I'll give it a try and see if it makes it go. It's actually a pretty unusual design, requiring pulldown resistors in the peripheral. (Seems like it's more standard to use a pull-up internally and have the peripheral pull the input to *ground* on actuation. I wonder if that was Woz doing his "I saved 4 cents!" thing again. Doesn't count against the component count if the resistor is in the paddle instead of the board, right?.)


Flap Different.

Offline

#73 2015-09-23 00:59:17

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 524

Re: ][ Joysticks and USB adapter

Success!

Using test clips I cobbled together a harness tying pin 2 and pin 4 to pin 7 on the 4066 through 330 ohm resistors (closest size I had handy to the recommended 470 ohm) and the buttons now work as expected. (I'd post a picture but I'm too lazy to decide where to host it at the moment.) Guess I can tack them in place with the iron and note the design change for the final version.

Did check with the meter and found without the resistors the lines were floating unsteadily around .9v. That's... a borderline zero in TTL, I think, but I guess I have a sensitive '251.


Flap Different.

Offline

#74 2015-09-23 01:24:31

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Nice!  Thanks!  I'll update the PCB with some pulldowns for those.

Offline

#75 2015-09-23 03:37:48

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Now that you have it working, are the x/y axis values seeming to work in games?  I'm just wondering about those capacitor values and how important a trimmer is.

Offline

Board footer

About ThinkClassic

ThinkClassic specialises in the maintenance, repair, restoration and modification of Vintage Apple and Macintosh computers. Ask questions and find answers about classic Apple desktops, laptops, accessories and peripherals.