Jump to content
IGNORED

Joystick multiplexer help


gauauu

Recommended Posts

Good news!  I received both 7800's from @McCallister today and they both work flawlessly with the QT, so I think we can consider that one solved (especially since I distinctly recall it working on my 7800 too).  Turns out my 2nd controller port on my 7800 isn't working now either, so there's a bunch of things wrong with it.  Anyone have any recommendations for a service that can repair a 7800? ;)  

 

So as long as we don't need pullups on the joystick inputs (and it sounds like we don't), we're good to go! :D  Nathan T.  @gauauu is itchin' to get the design finalized and put into a case for a hopeful holiday release! :thumbsup:  

 

Thanks again everyone for the help!

 

John

 

  • Like 2
Link to comment
Share on other sites

3 hours ago, johnnywc said:

Turns out my 2nd controller port on my 7800 isn't working now either, so there's a bunch of things wrong with it.  Anyone have any recommendations for a service that can repair a 7800?

From what you've noted so far, it seems that replacing the 6532 is the first order of business.  And since its port B also affects the pull-ups for 2600 mode, it may be the entire problem.

Link to comment
Share on other sites

Thanks @Danjovic! I've got a prototype PCB off at the fab that I'm waiting for. The circuit should be fine (I've done another version of the board in the past), but getting the physical dimensions right for a case is the tricky part. I might bug you for advice if I have trouble getting the physical design right.

Link to comment
Share on other sites

7 hours ago, gauauu said:

Thanks @Danjovic! I've got a prototype PCB off at the fab that I'm waiting for. The circuit should be fine (I've done another version of the board in the past), but getting the physical dimensions right for a case is the tricky part. I might bug you for advice if I have trouble getting the physical design right.

If you have access to a 3D printer, then you could print the board and see how it fits in the case. 

 

I know KiCAD can output the needed STL file. 

Link to comment
Share on other sites

  • 3 weeks later...

Hello all,

 

I've been working with the Stella team as they are adding in QuadTari support. :thumbsup:  

 

One thing that they're asking for is the minimum amount of time needed between switching the muxs and safely reading the ports.  My original implementation tries to maximize the time between enabling/disabling the select line (via DUMPORTS) and reading the values from SWCHA (joystick direction) and INPT4/INPT5 (the buttons).  To do this, I read the ports at the beginning of VBLANK assuming DUMPORTS is high;  DUMPORTS is then disabled at the end of VBLANK (when the screen is drawn), and then I read the ports at the start of OverScan (with DUMPORTS low), and then immediately set DUMPORTS high again for the next port read in VBLANK.  This has a huge delay of at least 200 scanlines between setting DUMPORTS low in VBLANK and reading the values in Overscan, and a delay of at least 20 scanlines between setting DUMPORTS high in overscan and reading the values in VBLANK.

 

So, to answer the Stella's team question about the minimum amount of time, I referred to the 4053 multiplexer datasheet.  I may be misinterpreting the values, but it states a "On time - Max" of 720ns and an "Off time - Max" of 450ns.  I believe this refers to the time to switch the multiplexer from "off" to "on" and vice versa, respectively. 

 

I did some math and it takes approximately 837ns to execute 1 cycle on the 2600.  (1 / (262 scanlines/frame * 76 cycles/scanline * 60 frames/second)) = 8.37 e-7 = 837ns.  (hopefully that's right)

 

If so, it would seem that you could "safely" read from the ports 1 cycle after enabling or disabling DUMPPORTS (selecting on or off for the multiplexer), since it takes 837ns to execute one cycle on the Atari but the max "on time" and "off time" is < 837ns. :ponder: 

 

So, I did a test and modified my code so that it reads the ports when DUMPORTS is low (to read the first joystick on each port), enables DUMPORTS, and then immediately reads the ports again (which would read the second joystick on each port), and it works without any issue. :thumbsup:  This is with a delay of 21 cycles between setting DUMPORTS and reading SWCHA, which is certainly much less than 21 scanlines. :)  I am going to test with reading SWCHA immediately after setting DUMPPORTS which should in theory still work since that takes 3 cycles or about 2500ns, well above the maximum on/off times in the spec sheet.

 

Anyway, I thought I'd share my results and see if there is something I may be missing.  To be safe, I think we're going to keep the delay between setting DUMPPORTS and reading the ports to 20 cycles in the Stella implementation, unless we can definitively come up with a smaller reliable max delay.

 

 

 

 

Link to comment
Share on other sites

3 minutes ago, Karl G said:

If I'm understanding correctly from browsing this topic, it looks like the quadtari will only work for 2600 games when using it on a 7800?

Hi Karl,

 

No, that is not correct; apologies if that was suggested.  The QuadTari hardware works on the Atari 2600 AND the 7800 (and most likely the Atari 8-bit computers also; more details to come). :)  

 

It currently is supported only by 2600 games (Galagon, Wizard of Wor, and the upcoming Zoo Keeper, Robotron and Gorf Arcade) but support can be added to any 2600 game.  I'm not a 7800 developer but if the reading of the joystick ports and charging the paddles through the VBLANK is similar to the 2600, I would anticipate that QuadTari support could be added to a 7800 game also.  This may not be true as I don't know if 7800 supports paddles for 7800 games and the QT mechanism relies on the paddle charging mechanism to select which joystick to read from.   Now that I think about it; since the 7800 has a 2-button controller, it's most likely using pin 5 and pin 9 (the 2600 'paddle' pins) to read the extra button so perhaps the QT would not work on a 7800 game.  Either way, the QT does work on a 7800 running a 2600 and on a 2600 running a 2600 game. :D  

 

Hope that makes sense!

 

John

 

  • Thanks 1
Link to comment
Share on other sites

The 7800 in 2600 mode is the same as a 2600, so I'll focus my comments on 7800 mode...

 

Paddles can be read, and the entire process is the exact same as on the 2600. But yes, this is provided you've set the console to single-button mode. So single-button mode should work fine, as far as your device.

 

In two-button mode, you indeed are using both paddle lines to read the buttons. The controllers themselves are even more complicated than that, because they have extra circuitry to ensure both buttons respond on the regular joystick button line if the console is in single-button mode. (or if the controller is plugged into a 2600)

7800_circuit.png.7691cb3075553043a165ba3fa2855aec.png

 

 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, johnnywc said:

Anyway, I thought I'd share my results and see if there is something I may be missing.

@johnnywc, you're not missing anything, lol! The switching times for the mux ICs are really low.

Adding a few CPU cycles may compensate, though, for the capacitance of the controller wires that altogether with the pullup resistors form an RC network asmuch as a paddle.

It is possible to make some measurements of the capacitance of the wires of a typical controler and do some math to estimate ẗhe time, for instance:

 

Consider 1nf of total capacitance (which is pretty high) and a threshold voltage of 2.0 volts for Atari to identify a voltage as high, being powered by 5Volts and using 10K pullup resistors you get around 5us

http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=0.1&vto=2&vs=5&c=0.000000001&r=10000

 

The opposite way, discharging from 5 volts down to 0.3 volts should render about 32us.

http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=5&vto=0.3&vs=0.1&c=0.000000001&r=10000

 

Again this is a rough estimative with a pretty high value for stray capacitance (1nf).

 

Nevertheless I dare to say that a single horizontal line should be safe for all cases.

 

Link to comment
Share on other sites

17 hours ago, RevEng said:

 

Paddles can be read, and the entire process is the exact same as on the 2600. But yes, this is provided you've set the console to single-button mode. So single-button mode should work fine, as far as your device.

Thanks!  I didn't realize there was a 'single button mode' for the 7800... I assume that's done by setting a specific bit/register?  

17 hours ago, RevEng said:

In two-button mode, you indeed are using both paddle lines to read the buttons. The controllers themselves are even more complicated than that, because they have extra circuitry to ensure both buttons respond on the regular joystick button line if the console is in single-button mode. (or if the controller is plugged into a 2600)

 

 

Thanks for the explanation!  So it sounds like someone could develop a 7800 game that is compatible with the QuadTari and support 4 joysticks if they set the console to single button mode, and then follow the QT SDK to detect a QT (INPT0 is low and INPT1 is high on startup) and switch/read the 4 joysticks using VBLANK/DUMPORTS (charge or discharge the paddles) and read SWCHA/INPT4/INPT5.  :thumbsup: 

  • Like 1
Link to comment
Share on other sites

12 hours ago, Danjovic said:

@johnnywc, you're not missing anything, lol! The switching times for the mux ICs are really low.

Adding a few CPU cycles may compensate, though, for the capacitance of the controller wires that altogether with the pullup resistors form an RC network asmuch as a paddle.

It is possible to make some measurements of the capacitance of the wires of a typical controler and do some math to estimate ẗhe time, for instance:

 

Consider 1nf of total capacitance (which is pretty high) and a threshold voltage of 2.0 volts for Atari to identify a voltage as high, being powered by 5Volts and using 10K pullup resistors you get around 5us

http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=0.1&vto=2&vs=5&c=0.000000001&r=10000

 

The opposite way, discharging from 5 volts down to 0.3 volts should render about 32us.

http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=5&vto=0.3&vs=0.1&c=0.000000001&r=10000

 

Again this is a rough estimative with a pretty high value for stray capacitance (1nf).

 

Nevertheless I dare to say that a single horizontal line should be safe for all cases.

 

Thanks for the confirmation!  I'm going to test with a 3 cycle delay (read SWCHA immediately after updating VBLANK) and see what kind of results I get.  We are going to keep a 1 scanline delay in Stella and recommend that for developers on real hardware.   Galagon, WoW and Zoo Keeper are already released or about to be released and have a minimum 20 scanline delay so those will be all set. :)  

 

PS Silly question, but what does 'us' stand for in your estimates above e.g. '5us', '32us'? :dunce:  

Edited by johnnywc
Link to comment
Share on other sites

36 minutes ago, johnnywc said:

Thanks!  I didn't realize there was a 'single button mode' for the 7800... I assume that's done by setting a specific bit/register?  

Thanks for the explanation!  So it sounds like someone could develop a 7800 game that is compatible with the QuadTari and support 4 joysticks if they set the console to single button mode, and then follow the QT SDK to detect a QT (INPT0 is low and INPT1 is high on startup) and switch/read the 4 joysticks using VBLANK/DUMPORTS (charge or discharge the paddles) and read SWCHA/INPT4/INPT5.  :thumbsup: 

You're welcome. Yep, it actually defaults to single-button mode. It's controlled by a couple RIOT PORTB bits.

 

And yes, I don't see why single-button games wouldn't work with QT. If that QT startup state held very long? The 7800 has a bios that runs for at least a second or two, prior to control being handed over to the game.

Link to comment
Share on other sites

17 minutes ago, RevEng said:

You're welcome. Yep, it actually defaults to single-button mode. It's controlled by a couple RIOT PORTB bits.

Great - thanks for the head up!  I can't visit that site unfortunately (Norton gives me the RED SCREEN OF DEATH), but are these the same bits that I used above to disable the pull ups when I was troubleshooting the 7800 button issue?

17 minutes ago, RevEng said:

And yes, I don't see why single-button games wouldn't work with QT. If that QT startup state held very long? The 7800 has a bios that runs for at least a second or two, prior to control being handed over to the game.

The QT startup state is just it's normal state; INPT0 will always be low (hooked up to ground) and INPT1 will always be high (hooked up to a 10K pull up resistor/vcc) as long as you don't enable DUMPPORTS, at least I think that's true. :D If so, you should be able to check those bits at any time after the 7800 bios is done.  Are you a 7800 developer by any chance?  I can always reach out to Bob aka PacManPlus to see if he would be interested in testing and perhaps even making a 4 player game for the 7800. 

Link to comment
Share on other sites

Yes indeed, they are the same bits. I think we were just trying to push or pull things for troubleshooting, but I'm hearing that you're using the paddle lines, so definitely you need to not enable two-button mode. It also may be a small issue on the 7800 for two button games, if QT is supposed to act like a pass-through for one player games.

 

Good stuff on the QT detection. I've made a couple 7800 games, and ported another from the A8, but the majority of my hobby time is spent developing 7800basic (bB for the 7800) and the a7800 emulator.

Link to comment
Share on other sites

1 minute ago, RevEng said:

Yes indeed, they are the same bits. I think we were just trying to push or pull things for troubleshooting, but I'm hearing that you're using the paddle lines, so definitely you need to not enable two-button mode. It also may be a small issue on the 7800 for two button games, if QT is supposed to act like a pass-through for one player games.

Okay great thx for the confirmation!  Yes, the QT acts as a pass-through for one player games that aren't QT compatible (meaning, they don't explicitly enable/disable DUMPORTS to switch the multiplexer).  If DUMPPORTS is kept low, the QT will run in 'low' mode which means joystick 1 will always be enabled.  The 4 directions and the button are mapped; pin 5 and pin 9 are not mapped from the joysticks since those are used as the select line from the Atari. :) 

1 minute ago, RevEng said:

Good stuff on the QT detection. I've made a couple 7800 games, and ported another from the A8, but the majority of my hobby time is spent developing 7800basic (bB for the 7800) and the a7800 emulator.

I may have to take a look at 7800basic as I've always wanted to try my hand at 7800 development (and 5200 development also, but that's another story).  Maybe we can work together to add QT support to 7800basic once the QT is actually released (soon hopefully). :D 

Link to comment
Share on other sites

6 minutes ago, johnnywc said:

I may have to take a look at 7800basic as I've always wanted to try my hand at 7800 development (and 5200 development also, but that's another story).  Maybe we can work together to add QT support to 7800basic once the QT is actually released (soon hopefully). :D 

Definitely we can do that. And there's always room for one more 7800 developer! ?

 

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
Just now, fdr4prez said:

Have you tried this with the Driving Controller?

 

A 4-person version of Indy 500 would be neat

Yes, it works with 4 driving controllers :) you can also use 8 paddles but it only recognizes the buttons of course.... maybe a four player competitive pinball game? ?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   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...