From: Scott McDonnell (netsamurai_at_comcast.net)
Date: 2007-04-08 23:34:58
I agree with you about the 512 cycles, now that I read up a bit more.
The sample rate would actually be 1/512uS which works out to be about
1.9KHz. We need to take half of that to comply with the nyquist rate to
get the fastest frequency we could reliably sample, which is 850Hz. This
does not take into account any processing time (though, I would think
with some slick machine code, the samples could be fetched and stored
quickly enough.) It is also assuming that the 512 clock cycles will
complete regardless of the count. That is how I understand it to work.
"Some" audio samples may actually be possible to capture with the right
support circuitry. Would probably sound horrible, though. This is beyond
my programming abilities, though I think I could design the support
circuitry to do it.
Sorry, there was some miscommunication there about the multiplexing.
There are two POT inputs to the SID and two pots on each control port.
POTX and POTY of the given control port are connected to the SID at the
same time. The PORTS are multiplexed, not the POT lines. This is done by
the CD4066. My mistake in not being clear.
Perhaps my last post will explain the charge/discharge issue.
I am fairly certain Jeri just used a modern ADC, since it wouldn't make
much sense to do it exactly the way the original commodore worked when
there are better and easier ways now. There is an ADC chip connected to
the POT on the Hummer. I don't have one in front of me, but it is
probably one of the Dallas Semi integrating slope ADCs (dual slope, most
likely.) It isn't important to emulate it exactly, as long as the SID
registers are filled with the values expected by a game. You have a lot
more license to do it your way when you recreate the internals. That's
the secret of emulation: As long as the circuit takes the inputs
expected and outputs the results as expected, what happens in between
isn't all that important.
Again, yours and Levente's methods both work as you both have
demonstrated. Nobody is questioning that, of course. But, I am just
assuming since the original poster didn't go that route, that he is
dealing with a linear voltage source, not a micro. Perhaps he will clear
that up before any more time is spent on this.
Scott
-----Original Message-----
From: owner-cbm-hackers@ling.gu.se [mailto:owner-cbm-hackers@ling.gu.se]
On Behalf Of Jim Brain
Sent: Sunday, April 08, 2007 4:43 PM
To: cbm-hackers@ling.gu.se
Subject: Re: Commodore joystick ports
Scott McDonnell wrote:
> Pasi,
>
> 512 cycles, because of the nyquist rate (at least 2x the max desired
> sample frequency), perhaps?
>
Since I've already put a disclaimer out on my analog skills, I don't
believe that is the reason, since the ADC in the SID was not designed to
measure waveforms, just a static load.
Based on testing, they do not appear to be multiplexed. I base that on
placing two 10K resistors from 5volts (pin 7) to both POT lines. The
scope shows the drive to 0v happens at the same exact moment.
From:
http://stud1.tuwien.ac.at/~e9426444/sidtech3.html
"These pins are inputs to the A/D converters used to digitize the
position of potentiometers. The conversion process is based on the time
constant of a capacitor tied from the POT pin to ground, charged by a
potentiometer tied from the POT pin to +5 volts. The component values
are determined by:
R*C = 4.7E-4
Where R is the maximum resistance of the pot and C is the capacitor. The
larger the capacitor, the smaller the POT value jitter. The recommended
values for R and C are 470 kOhm and 1000 pF. Note that a separate pot
and cap are required for each POT pin. "
If I disconnect the 10K from one POT line 1.0volt is still charged onto
the cap. The discharge time goes down quite a bit, but it's still 1uS
or so.
I'm struggling with the note above about measuring the discharge time.
Based on my notes, and allowing for the error introduced by using the
scope, the difference between a reading of 10 and 255 is 1uS, far too
small a time constant for the 64 to measure, no matter which clock you
used for the counter.
Jeri should chime in, since she re-implemented the SID POTs for the DTV,
but based on more testing, I'm going to go with the following theory
SID contains 1 9 bit counter, and 2 2volt comparators. 9th bit is
hooked to 2 transistors that clamp input POT lines to ground. At time 0,
SID releases the POT line from ground and starts counting.
the internal comparator latches the current counter value (lower 8 bits)
into the appropriate POT register when 2 volts is reached.
At time 256, the 9th bit goes high, clamping the line to 0.
the cycle repeats. (the comparator is still active, but the line will
never reach 2.0v, so the value is never latched into the SID register.)
At time 512, the counter rolls over, 9th bit goes low, releasing the POT
line and the process repeats.
I am pretty sure everything but the part in parens is correct. I
connected a paddle and tried it out, while watching the scope. The
reading was 255 until the charge cycle hit 2 volts. By varying the
charge cycle to hit 2v at time 128 (0 being unclamping of the line), the
POT register read 128 (or so). From the scope:
(caclulated value in parens)
2v at 100% = 255 (255)
80%=210 (204)
75%=189 (191)
60%=153 (153)
50%=130 (127)
40%=104 (101)
20%=54 (51)
0%=4 (0)
My statement in parens in the description is based on CBM designers
being typically thrifty. I can see them implementing a 9 bit counter,
using the high FF to switch a transistor that would drive the POT line
to ground, but not bother with bypassing the comparator (since it would
never get triggered).
The thrifty rationale is how I explain the 512 cycle period. Since it
would have taken 2-5uS to completely discharge the cap, they'd need to
wait that long (or a bit longer) before unclamping the line and starting
the counter. That would mean another counter, or a check of 261 (256
line + 5 or so) on the counter (more gates), and then more gates to
reset the counter. Since the POT lines were assumed to be DC (no
periodic waveforms), letting the counter simply roll over used the least
gates for the task at hand.
It piqued my interest, but I fear I've exhausted my free time to
research this. Hopefully others can add more light to the mystery.
FWIW, the AVR code I use to simulate the paddles is at
http://www.jimbrain.com/WebSVN/filedetails.php?repname=PSXJoy&path=%2Ftr
unk%2Fsrc%2Fjoy.c&rev=0&sc=0
Jim
--
Jim Brain, Brain Innovations (X)
brain@jbrain.com
Dabbling in WWW, Embedded Systems, Old CBM computers, and Good Times!
Home: http://www.jbrain.com
Message was sent through the cbm-hackers mailing list
Message was sent through the cbm-hackers mailing list
Archive generated by hypermail pre-2.1.8.