Measuring APU DAC voltages via Test Mode

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

Post Reply
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Measuring APU DAC voltages via Test Mode

Post by Persune »

So I wanted to measure the nonlinearity of the APU pins by directly measuring the voltages for each DAC combination.

I'm using a LHT00SU1 USB oscilloscope, modified one of its analog channels to amplify its voltage measurement to be approx. 5x with the help of lidnariq. This is to mitigate the poor bit depth of its ADC (8-bit +-5Vpp!).
IMG_20210713_035841.jpg
I'm using PulseView to record and capture the signals.

I've socketed my 2A03G on my Famicom, with a toggle switch on pin 30 between 5V and GND. This allows me to turn on the CPU test mode manually.
IMG_20220928_163152.jpg

I made a test rom that iterates through all the DAC combinations using the CPU test mode's special registers, stepping through on every video frame. This accounts for my poor oscilloscope's poor samplerate (and PulseView seemingly crashing when capturing rates higher than 1MHz?). This also helps me average the values out to account for quantization noise.
https://github.com/Gumball2415/nes-scri ... m-dac-test
IMG_20220928_163124.jpg

Contrary to what the ROM image says, connecting pin 30 to CPU A3 didn't help at all (the Everdrive does not boot), hence the toggle switch mentioned earlier.

I'm currently measuring the voltages and processing the data. Will post results as a reply.
pulseview.png

This test setup could be improved by using a higher quality oscilloscope, but this is what I could afford at the moment.

edit 23-11-2023: after doing a battery test, i found that the gain is 5x, not 6x. also, the range is from -5V to +5V.
Last edited by Persune on Wed Nov 22, 2023 11:00 pm, edited 1 time in total.
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by Persune »

Here's the PulseView project files:
2A03 APU voltage capture.zip
(1.83 MiB) Downloaded 33 times
edit 23-11-2023: apparently i forgot to use the 5x amplified ADC channel. oh well
Last edited by Persune on Wed Nov 22, 2023 11:37 pm, edited 2 times in total.
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by Persune »

Here's some capture data again, but this time at 1MHz sampling rate.
https://drive.google.com/file/d/1VSDURb ... sp=sharing

edit 23-11-2023: apparently i forgot to use the 5x amplified ADC channel. oh well
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by Persune »

I have exported the capture data to .wav, then further processed the .wav with a python script:
https://gist.github.com/Gumball2415/366 ... 692b41d4d8

The resulting table is a binary array of 64-bit double precision floating point numbers.

For each LUT, there are two different outputs; one with absolute voltage values measured, and one with values normalized to within the range of 0 to 1.

To index into APU1_LUT, use this formula:

Code: Select all

(SQR1_size * SQR2_level) + SQR1_level
To index into APU2_LUT, use this formula:

Code: Select all

(DMC_level * NOI_size * TRI_size) + (NOI_level * TRI_size) + TRI_level
I plan to record a higher bit depth capture of the DAC when possible.
Attachments
APU2_LUT_norm.bin
(256 KiB) Downloaded 15 times
APU2_LUT_abs.bin
(256 KiB) Downloaded 21 times
APU1_LUT_norm.bin
(2 KiB) Downloaded 15 times
APU1_LUT_abs.bin
(2 KiB) Downloaded 19 times
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by Persune »

For C and C++ based emulators, the script also prints header files which contain the entire lookup table, declared in hex via Python's float.hex() function.
Attachments
APU2_LUT_norm.h
(719.08 KiB) Downloaded 19 times
APU2_LUT_abs.h
(719.08 KiB) Downloaded 21 times
APU1_LUT_norm.h
(5.66 KiB) Downloaded 21 times
APU1_LUT_abs.h
(5.66 KiB) Downloaded 19 times
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by rainwarrior »

For comparison, a while ago I was trying to improve the DAC model with audio-only tests, though it didn't really have a satisfactory outcome. It didn't quite seem to match Blargg's formula, but it wasn't far off either, and I couldn't really come up with a sensible improvement based on my measurements.

viewtopic.php?t=24288

Measuring the DAC more directly like you've done in this thread, though, would probably do a lot more to help, if aiming for a new idealized model.
User avatar
Persune
Posts: 12
Joined: Sun Apr 05, 2020 9:25 pm
Contact:

Re: Measuring APU DAC voltages via Test Mode

Post by Persune »

as-is, the measured voltages suffer from some quantization error, so i think i would redo this when i acquire a better voltage capture device (or an oscilloscope).

this test also has the limitation of requiring a G rev. CPU or later, which could mean that survey results are biased on those later revisions.
Post Reply