Jump to content
IGNORED

Fast and unconventional IO interface


Recommended Posts

This is continuation of ideas from Rybags and me in the How accurate is the XE light gun topic.

 

I believe an interface could be made using a simple microcontroller to communicate primarily by providing light pen and paddle input. My goal would be to send 24-bits of data to the A8 in each transfer, which would take 2 scan lines to complete.

 

The PENH register can updated with a value from 0-228 each line. The POT registers have the same range and can operate over 2 scan lines in fast mode (is the range the same in fast mode?).

 

If we try for 6-bits of data in PENH, POT0 and POT1, then we can have a window of 3 counts per target value (64*3=192) to allow for timing errors. We should throw away the lowest values and target a range of values like 18 to 210 (18,19,20=0, 21,22,23=1, etc..). It would also be possible to have the software calibrate itself before a transfer.

 

The A8 signals the start of a transfer on a joystick IO pin, and triggers POTGO (or, do we have the controller watch for the POTGO alone?). This is done after a WSYNC for alignment. The microcontroller configures the POT inputs and then triggers the light pen input at the right cycle of the first line. The A8 performs another WSYNC and, toggles the joystick line to realign the timing for the next line and then reads PENH. This is the first 6 bits. The microcontroller triggers the light pen input again on the correct cycle. The A8 does one more WSYNC and then reads PENH again. This is the next 6 bits. The A8 then reads POT0 and POT1 for the remaining 12 bits. All these values are translated through a LUT to get the 6-bit results.

 

At the end of 2 lines, we have 24 bits of data. and can start the cycle again. If this can be started every 3rd line, our transfer rate would be about 15K/second. If we also bit bang in some data on the joystick IO lines (instead of wasting cycles with WSYNC), the rate goes even higher.

 

Outgoing data must be sent on the joystick IO lines. Although I believe POTGO can also be detected at the joystick port for one more outgoing signal. It might be possible to load data quickly into the 5200 using just the POT portion of this idea.

Link to comment
Share on other sites

My thoughts on the POTs - probably throw away the 2 lsbs, but you might also need to ignore the msb since the value only reaches 227.

Possibly precision could be improved though. Normal POT operation is you get the (usually) reduced voltage returning which charges the caps.

What about if the IO device returned full voltage? The variance in POT value could be acheived by delaying the time between POTGO and full voltage.

 

Detecting POTGO? Is that just a case of sensing current flowing from +5V to the paddle pin?

 

A disadvantage of doing IO this way - we probably need to use Port 1 on most machines (for pen input) which means constant plug swapping.

 

But still, 15K/second is pretty quick, competitive with IDE class devices.

Link to comment
Share on other sites

Good idea about not simulating a proper pot. The pot caps are 47nF and there will be some charge time so bringing up the voltage at or near the trigger time should give better timing results (maybe charge them through a fixed small resistance).

 

If you don't wish to use port 1, the interface could run slower on other ports (or you mod your machine or make a pass-through interface).

 

Yes, POTGO should be detectable as a fast voltage drop on the POT pins. I also think we can bit bang at least 3 or 4 more bytes during 2 lines. Imagine filling RAM in 2 seconds.

 

The only other thing the routine needs to do is avoid bad lines unless it's restricted to doing everything in the blank.

Link to comment
Share on other sites

Just for fun I modeled the 5200's pot circuits in LTSpice to see how fast two signals could be used as outputs: Pin 9 (Pot supply) and Pins 10/11 (Pokey POT inputs).

 

Pin 9 is the output of a voltage regulator circuit. It contains a pot which is used to affect centering of the sticks, and uses a GTIA IO pin which shuts it off entirely (the trackball games use this feature to prevent the sticks from working). Toggling IO2 on GTIA produces a signal at the port which has a maximum usable frequency of about 5KHz. Could be used for a low speed data channel. This signal has a faster rise than fall.

 

Pins 10/11 are the pot inputs and they can provide an output signal slightly faster than Pin 9 (maybe 6-7 Khz). Hitting POTGO dumps the internal .047uF input cap and it starts charging through a 1.8K resistor connected to the port. This gives this signal a much faster fall than rise. ANDing one of these with pin 9 would give a signal with more precise edges.

 

These are the only signal which can be practically user controlled, unless we start banging on keyboard scanning registers- it might be possible to keep resetting the scan to take direct control of one of the KB lines. Anyway, just using these lines we can read something like a NES controller, but the code would have to be spread out in time.

 

It's funny, there's so many things that could have been better in the 5200. Why is the cartridge port so limited (especially in the 4-port)? Why wasn't the unused GTIA IO3 run anywhere? It could have provided free bank-switching support. Even the expansion port seems to be purposefully restricted. Why wasn't a light gun supported?

Link to comment
Share on other sites

Hey Gary,

 

I found this in the Pokey datasheet:

 

There is an ALLPOT register which allos the logic value of each pot line to be read by the CPU. The main use of Allpot is in the fast scan mode. This is done by:

  1. Place POKEY in fast scan mode (See SKTLS).
  2. Write to POTGO address.
  3. Wait four cycles of computer clock
  4. Now the Allpot register can be read

NOTE: This address (as well as the fast scan mode) is useful only when the charging capacitors on the P0-P7 pads are removed, unless the pads are driven by buffer drivers.

It also claims that fast scan disables the dump transistors (under SKCTL). I'm not really sure how they intended it to be used, except that it looks like the POT pins are intended to be purely digital triggers. The schematic to the Warlords arcade machine shows a different system for reading pots with Pokey using comparators. I guess I could dig through the ROM and see if they're using fast mode.

ALLPOT could be used to implement a Joystick port since it will tell you which pins are high and low after a POTGO.

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