YM2149/AY-3-8190 Audio Signal Mixing and Impedances

Discussion in 'The Projects Forum' started by Loser777, Apr 24, 2013.

  1. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    I'm in the middle of thinking up of a project involving the YM2149 and some sort of microcontroller. The YM2149 or AY-3-8190 is a sound generator that you basically control by writing values to its 16 registers. This chip has 3 output channels which the datasheet says operate with a Vpp of 0.96-1.35v with RL = 1kΩ.

    I've seen this IC connected to speakers in a variety of ways, but I'm stumped as to the reasons for each configuration. From my understanding, this Vpp is about the same as that needed for standard line out, so why would there be any components necessary other than a single resistor to add some output impedance? What's wrong with just bridging all three channels and treating that as a mono audio +?

    I see some schematics that bridge the channels, but have a 1kΩ resistor to ground, but shouldn't that be in series with the load?
     
  2. patricktoday

    Member

    Feb 12, 2013
    157
    42
    Wow, that's a cool chip! Are you trying to get some retro sounds out of it?

    You're right that is about the correct value for a line level signal, but it's just that, line level. You can't drive a speaker with line level, you need an amplifier to supply extra power. If you're suggesting you would put a 1k resistor in series with an 8Ω speaker, I don't know that that would be audible.

    You will probably need to combine the signals into mono and then either plug that signal into an amplifier or make your own. The LM386 chip would probably work well for that.
     
  3. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    I didn't phrase what I was asking quite clearly--I am not intending to drive headphones or any other low impedance load directly with the chip--probably going to use some computer speakers that take line in.

    I don't know much about audio signals, so I'm wondering why there's a resistor to ground (as opposed to being in series with the load) in a lot of the schematics that I see using this chip:
    e.g.
    http://electronicfields.files.wordpress.com/2012/05/ym2149midi.png

    (Chip is bottom middle, AY-3-8912A [A,B,C are audio channels])
    http://i.iinfo.cz/urs/pc_57_04-123978489035453.png

    Additionally, I sometimes see maybe a 10μF capacitor in series. I'm assuming that this is to block DC, but what purpose does that serve in the context of an audio signal and how is that calculated?
     
  4. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    The AY chips have an op open emitter output so the 1k resistors connect to ground. Connecting in series with the "load" would mean the 1k would be added to a rather high input impedance of the power amplifier and restrict current flow into the amp. Once the combined resistance of the 1k and the input of the amp are added and made into a filter with the coupling capacitor, will wipe out all audio frequencies.

    The 1k resistor will allow a 1 mA (approx) signal that is then coupled to the power amp with a capacitor (to remove the DC component). I have recently used the smaller brother of your aY 8912, the AY-9813. It works great when driven by a PIC, after all, they were designed by General Instruments (Predecessor of Microchip). The setup with 1k resistor as shown works perfectly when driving a powered computer speaker.

    Just remember that all documentation for these chips has register values in OCTAL notation, not decimal.
     
    Loser777 likes this.
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    Let me know when you get it working. I am looking for something interesting to do with a drawer full of AY-8913s.
     
  6. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    I'm not quite sure what you mean by "op open emitter output"--quick googling doesn't reveal much (similar to open drain output maybe?). I'm guessing then that the resistor value is used to adjust some sort of gain.

    What you said about the DC blocking makes sense. One point of interest--the datasheet says the channels are biased to +2v DC, but youtube evidence shows the chips working fine without a coupling capacitor (how would you calculate the value for this anyway?).

    I'm trying to start out this project humbly at first--following in the footsteps of others by piping serial data to an Arduino for playback first. If I get that working, then I'll try some scheme where I unpack the ym data. This is where things could get quite intense as the ym file format specifies each of the 16 registers every 50ms so depending on the read latency of the Arduino, there could be some dicey timing-critical code needed. I can't simply dump the entire file into memory at once as 16bytes * [song-length/50ms] gets large quickly.
     
    Last edited: Apr 26, 2013
  7. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    Yes, open drain.
    Also, you don't have to adjust all registers every time. In fact, you can leave the registers set and play the same note at the same volume as long as you want to wait.
     
  8. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    Wikipedia refers to (Open drain) as Open collector??? This seems like an output that would be strictly used in logic, not for an audio signal and uses a pull-up resistor, not pull-down.

    While it's true that most music probably doesn't change EVERY register EVERY 50ms, trying to predict when registers change to avoid updating them that frequently is probably extremely sophisticated. And if you don't update registers often enough, whatever music you're trying to play (which is the eventual goal in this case) is probably going to sound pretty bad.

    Still confused about the outputs :confused:
     
  9. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    On the outputs, I think computer speakers have an internal coupling capacitor to allow DC protection of the circuitry (or there is enough head-space to allow some DC offset). In any case, I also was able to make it work with or without a coupling capacitor in my breadboarded circuit.

    As far as music goes and update frequency, to make the chip sound nice, you want to hold a note (tone - or tone period register) for one note (eighth note, quarter note, ...). To get the note to sound like it is coming from a particular instrument, then you have to control the volume and noise signals. For example, a piano will come on with some noise and full volume of the note then quiet fairly quickly. That part can be updated frequently. You start having trouble and the frequency starts soundling like a mess when you update the frequency of the tone too often. I think you keep restarting hte waveform each time you reset the register. Therefore, if you reset the tone period register every 50 mSec, then you get distorted (rectangluar) wave every 50mSec (20Hz) as your square wave is reset (unless your tone is some multiple of 20Hz).
     
  10. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    I'm probably going to leave the aesthetics of sound generation to the massive library of .ym files available online. The *50ms* comes from how the files are formatted. I'm don't think the waveform is reset each time the registers are updated--the registers seem to be implemented with latches and not flip-flops as the datasheet's diagram shows them not connected to the clock. That means that the timing of the waveform generation is probably only controlled by the clock, so quick updates to the registers need not disrupt how the waveforms are generated.

    Anyway, do you have any documentation about what type of output the analog channels are specifically? I'd really like to learn more about the actual reasoning for the resistors and resistor values.
     
  11. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    For the output resistor, here is the "full" datasheet and application guide with recommended circuits. I was working from memory until now, the full recommended circuit is included in the document. Also, the 1k resistor acts as a voltage divider to keep your output in the range you specified.

    AY-3-A8910 DATASHEET
     
    absf and Loser777 like this.
  12. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    Wow, that gives much more information than the Yamaha datasheet was looking at.

    Isn't the output voltage kept in range by the fact that Vpp is determined and whatever DC-blocking is done by the amplifier? I'm thinking now that the 1k has something do with the audio channels being summed as a single output.
     
  13. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,993
    3,748
    I haven't thought about it all too much. I was more concerned with getting the PIC to make noise. I was able to program a nice version of "mary had a little lamb" from my kid's old sheet music. I just used the circuit as shown connected to a computer speaker.

    I used parallel interface and only one of the three channels.
     
  14. patricktoday

    Member

    Feb 12, 2013
    157
    42
    You can't guarantee the next amplifier stage will be DC-blocked so you probably don't want to omit the capacitor. Your signal will range from 0-1V at the output pin but with a cap it would range from +/-0.5V. From there, if you use the circuit in the datasheet, you'd have a 10K output impedance and that would form a voltage divider with the input impedance of your amplifier. If your amplifier has a 10K input impedance it would receive 1/2 of the input signal, if it was infinitely large, it would receive the full 1V p-p signal.
     
  15. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    Would you suggest 10μF as a good value for the capacitor (the higher the value, the better) for the best low frequency response?

    Well our applications are clearly different--I'm trying to build a project that attempts to faithfully reproduces the old sounds of 80s microcomputers. Using only one of the channels would basically kill off 2/3 of the voices that the chip generates.
     
  16. patricktoday

    Member

    Feb 12, 2013
    157
    42
    Well, you may be going for a different aesthetic end goal but the circuit would likely be the same. You should stick to the recommended circuit unless you try it and there's some shortcoming. The higher the value the cap, the less the bass will roll off. 10uF should be more than adequate. The 3db rolloff point is 1/(2 Pi RC) and the R is the 10k resistor PLUS the amplifier's impedance and the C is your capacitor. With 10k and 10uF you'll get an optimal bass response down to 15.92 Hz.

    http://www.v-cap.com/coupling-capacitor-calculator.php
     
    Loser777 likes this.
  17. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    Looks good, but I still don't know the purpose of the 1k pulldown on all of the outputs after all of this XD.
     
  18. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    An open emitter requires a pulldown resistor to function properly just as the more common open collector requires a pullup.

    Open Emitter.PNG
     
  19. patricktoday

    Member

    Feb 12, 2013
    157
    42
    Right, and look at the circuit. The cap blocks the output. If there was no 1k resistor, there would be no DC path to ground at all.
     
  20. Loser777

    Thread Starter New Member

    Apr 24, 2013
    12
    0
    How is it problematic if the output doesn't settle to 0v as this isn't a logic output?

    What occurs if there's no DC path to ground?
     
Loading...