VRC7 and 5B amplifier investigation, also VRC7 LFO reset!

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

So, I wrote a frequency sweep test that approximates a sine and quasi-logarithmically increases the frequency. The APU sines are assuming the DMC is linear (which it isn't quite), and the 5B sines are making do with the logarithmic steps (trying to mitigate by summing all 3 channels). Not ideal but maybe has enough SNR to be usable?

The graph here uses an FFT to find the dominant frequency for some window in the recording, and RMS to estimate its magnitude in that window. I'm sure there's some bias in this process, but again hoping it's good enough to be usable. (Anyone better versed in filter analysis techniques than me, feel free to give me advice on doing this better.)

There's also a 10 second noise burst (APU noise / 5B noise) for each of these tests, which have spectra that seem to match these curves pretty well (but harder to read through the noise), so that seemed to verify the validity of the analysis technique. I also tried modelling a best fit to the step responses for each of these but I had a hard time duplicating the curves, and abandoned the attempt.

The result:
sweep_5b.png
  • 1. NES APU, just for comparison.
  • 2. Famicom APU. Note that for me this has a stronger highpass than the NES. Is this normal? Wiki: APU Mixer says "The Famicom hardware instead ONLY specifies a first-order high-pass filter at 8 Hz" which is... obviously not what I'm looking at here...?
  • 3. 5B sine through the 5B amplifier. I assume this would be unaffected by the Famicom's APU highpass?
  • 4. Famicom DMC sine through the 5B amplifier. I assume this is double dipping with its own highpass and the 5Bs on top?
Additionally, I tried to measured my recording device against a cheap signal generator I had, which seemed to show a 1-pole lowpass with a corner of ~7.1Hz. (Also a sharp lowpass up near the nyquist.) So, I presume that would colour these results a little. Edit: Kind of uncertain about this, its DC filter might be lower and sharper... need to do some more tests. I don't have very good tools for meauring my tools. ;)
Last edited by rainwarrior on Wed Sep 12, 2018 6:47 pm, edited 3 times in total.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by tepples »

In a previous topic, I posted a ROM and source for sine sweep that is at least somewhat corrected for DMC DAC nonlinearity. Feel free to incorporate it.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

tepples wrote:In a previous topic, I posted a ROM and source for sine sweep that is at least somewhat corrected for DMC DAC nonlinearity. Feel free to incorporate it.
The reason I didn't correct for its nonlinearity is simply that I haven't measured its linearity curve yet (one of many things on my to-do list), and I'm not willing to assume that "blargg's formula" is accurate for this purpose. I could easily have put that formula into my program that generates the sine table, but I feel like that would mostly only accomplish a slightly better SNR in emulators that implement blargg's formula.

For the purposes of the test, as far as I can tell the difference isn't very significant (...but please correct me on that point if you know I'm wrong). Like I mentioned above, the independent measurement of the noise spectrum seems to match fairly well with the sweep analysis, so I feel some justification in making this assumption.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by Rahsennor »

You're on fire, rainwarrior! I really wish I was in a position to contribute or at least make use of all this awesome data you're posting. :(
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by lidnariq »

rainwarrior wrote:"The Famicom hardware instead ONLY specifies a first-order high-pass filter at 8 Hz"
I put that there, but in retrospect it's pretty misleading. What I meant was that the canonical schematic of the original Famicom – http://nesdev.com/Ntd_8bit.jpg – shows only the presence of a highpass filter with corner frequency at 8Hz. But the RF modulator changes that, and an AV Famicom is probably different too.

.... Also, somehow I did the math wrong. Evaluating 1/(R3//R4//R5 · C2 · 2π) works out to 37Hz, not 8Hz. I don't have any idea what I was thinking at the time.
5B sine through the 5B amplifier. I assume this would be unaffected by the Famicom's APU highpass?
As far as I know, the only highpass is the one behind the inverter-as-amplifier, before it goes to the cartridge slot.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

James-F recorded the APU part of the sweep test in both his Famicoms (one is modded, one is AV). Here's a plot of the results, interesting to compare. (Not sure how much is due to different recording devices, unfortunately.)

I can add more if anyone else wants to record it. (sweep_5b_nrom.nes, doesn't require a hotswap, and the first half of the test is APU only, about 90 seconds.)
sweep_famicom_3.png
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

So I've been pushing around chains of 1-pole highpass filters trying to see if I can model those sweeps:
sweep_models_1.png
My NES and Famicom seem to fit pretty well with a single filter (16 and 32 Hz cutoffs respectively). In all of these there is an additional 3 Hz highpass assumed from my recording device (still not sure exactly what it's characteristics are, but this seemed to improve the fit of the NES/Famicom APU curves, and seems to be within a plausible range of the rough measurements I've managed to take so far).

The 5B curves are too sharp a knee to work with just one filter. I decided to model it as the internal 5B and the APU input each having their own filter before entering the amplifier, then finally an additional shared filter on the output of the amplifier. I'm not sure how much sense this makes, but maybe the amplifier in between justifies having two.

5B APU input: 12 Hz
5B internal: 20 Hz
5B output: 12 Hz

The internal curve here only matches until about 10 Hz. This might be the higher frequency noise due to the rough sine wave that's not being attenuated? Maybe I'll get a better idea of this bias once I implement this in NSFPlay and do the same analysis with my synthesized version. I think in all cases the signal should bias high from the model as it weakens but the noise on the APU's sine is a much lower magnitude. (Ignoring most of the lower left part of the graph.)

The APU passing through the 5B has the sharpest falloff of them all. Picking up the 32 Hz from the Famicom first, then a presumed 12 Hz cutoff on its input to the 5B, then the shared 12 Hz on its output... doesn't fit exactly, but I guess it's pretty close. This might be partly due to the amplifier nonlinearity; the 5B internal stuff is kept quiet enough to stay linear but the DMC here is a lot louder, might be causing distortion that's affecting the curve?

I was hoping the APU thru 5B and internal 5B could be modelled with the same filter (and the APU merely getting an additional filter from the Famicom) but I couldn't find a match that worked for both, which is why I've hypothesized the separate input filters... but it seems bizarre to me that they'd put an extra one on the APU like this.


Anyhow, next step is to model these in my emulator, then record and analyze this sweep test from the emulated version... that should give me some better idea of what's still missing.
Last edited by rainwarrior on Thu Sep 13, 2018 12:42 pm, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by lidnariq »

rainwarrior wrote:I was hoping the APU thru 5B and internal 5B could be modelled with the sample filter (and the APU merely getting an additional filter from the Famicom) but I couldn't find a match that worked for both, which is why I've hypothesized the separate input filters... but it seems bizarre to me that they'd put an extra one on the APU like this.
Every inverter-as-amplifier requires a highpass filter, because they need one to remove the DC offset to make sure the inverter's actually somewhere where it amplifies instead of rails.

As I said, there's the highpass filter before the one inside the Famicom (R3//R4//R5 · C5).

There's also an unknown lowpass inside the Famicom (output impedance of U7 · C8)
There's a highpass filter between the circuit that mixes 5B and APU audio on the cart and the amplifier (R1//R2 · C3)
There's a highpass filter after the amplifier (output impedance of amplifier · C4)

After that, it goes straight to the Famicom's RF modulator, but who knows what that does.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

Started a thread for reading the PCB components: thread
rainwarrior wrote:5B Gimmick! (bootgod)

C1: {R} / 85°C / M4413 / 6.3 v / 47 µF (top left)
C2: 103 (top right)
C3/C4: 85°C / (M) / 228 / 50 v / 1 (top middle, does not say µF after 1)

R1: 10 x 100 5% (right top, brown black orange gold)
R2: 10 x 1k 5% (right bottom, brown black red gold)
R3: 10 x 10k 5% (middle, brown black yellow gold)
...and lidnariq's first response:
lidnariq wrote:(R1//R2 · C3) = 909Ω·1µF → 175Hz.
That's ... not right. Maybe the 5B has a significant output impedance which moves the corner frequency down.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

Does this look correct to you? I was surprised that pins 2 (amplifier input) and 3 (amplifier output) are directly connected with a resistor like this. Feels like I'm missing a connection to ground somewhere in here... (seems to match this diagram)
5b_audio_diagram.png
My tracing:
5b_audio_tracing.png
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by lidnariq »

Yeah, that's the same thing I thought I saw when I traced the board six years ago. I mistakenly thought I'd already linked to that: I'm sorry that I didn't.

Inverters-as-amplifier often have a topology like that. The diagram I drew for the MMC5's amplifier is similar.


The external resistor on an inverter-as-amplifier:

Code: Select all

      +---R---+   
      |  \    |
in ---+--|>O--+-- out
         /           
has the same function as with an op-amp:

Code: Select all

 
      +---R---+
      |  \    |
in ---+--|-\  |   
         |  >-+-- out
    ~2V--|+/         
         /    
but is a lot fewer transistors inside.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

Ah, that makes sense. Thanks.

I guess I had been thinking of the amplifier as a self contained thing, but really I shouldn't have. Ha ha.
User avatar
James-F
Posts: 13
Joined: Fri Nov 03, 2017 11:54 pm

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by James-F »

Might as well be a simple inverting op-amp.
Pin 27 is the 5B chip output, while pin 45 is you standard famicom signal.
I would guess this cart is loud in comparison to others since the amplification factor is quite high if it is indeed a simple op-amp, but I have no idea.
From lidnariq's post I can see MMC5 mixes two additional channels with the famicom 2A03.

Image
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by lidnariq »

James-F wrote:Might as well be a simple inverting op-amp.
Because you're throwing this into LTSpice, you really ought to actually build a CMOS or NMOS inverter rather than just using an op-amp.

Although I can neither find a depletion nMOSFET in their library nor can I figure out how to get it to accept a model statement declaring one...
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset

Post by rainwarrior »

I tried out LTspice (figured it was a good excuse to learn). Though I probably don't have enough knowledge of circuit design to make very good use of it.

A question about using an inverter as an amplifier: to accomplish this, we need to bias the input to some middle voltage? Right? (2.5v?)

Would a voltage divider inside the 5B before the inverter input account for the highpass strength? For example if I put the input from pin 2 through the middle of a 10k / 10k divider, it seems to lower the cutoff from ~145Hz to ~30Hz. (I seemed to be measuring a 2-pole effect though, not sure how to account for that.)

Was looking at the inverter in the Famicom schematics too, does this achieve a bias by outputting the audio signal from the 2A03 already in an inverted state?
Post Reply