trunk/src/emu/sound/ay8910.c
| r31203 | r31204 | |
| 1 | /* |
| 2 | * Couriersud, July 2014: |
| 3 | * |
| 4 | * This documents recent work on the AY8910. A YM2149 is now on it's way from |
| 5 | * Hong Kong as well. |
| 6 | * |
| 7 | * TODO: |
| 8 | * |
| 9 | * - Create a true sound device nAY8910 driver. |
| 10 | * - implement approach outlined below in this driver. |
| 11 | * |
| 12 | * For years I had a AY8910 in my drawer. Arduinos were around as well. |
| 13 | * Using the approach documented in this blog post |
| 14 | * http://www.986-studio.com/2014/05/18/another-ay-entry/#more-476 |
| 15 | * I measured the output voltages using a Extech 520. |
| 16 | * |
| 17 | * Measurement Setup |
| 18 | * |
| 19 | * Laptop <--> Arduino <---> AY8910 |
| 20 | * |
| 21 | * AY8910 Registers: |
| 22 | * 0x07: 3f |
| 23 | * 0x08: RV |
| 24 | * 0x09: RV |
| 25 | * 0x0A: RV |
| 26 | * |
| 27 | * Output was measured on Analog Output B with a resistor RD to |
| 28 | * ground. |
| 29 | * |
| 30 | * Measurement results: |
| 31 | * |
| 32 | * RD 983 9.830k 99.5k 1.001M open |
| 33 | * |
| 34 | * RV B B B B B |
| 35 | * 0 0.0000 0.0000 0.0001 0.0011 0.0616 |
| 36 | * 1 0.0106 0.0998 0.6680 1.8150 2.7260 |
| 37 | * 2 0.0150 0.1377 0.8320 1.9890 2.8120 |
| 38 | * 3 0.0222 0.1960 1.0260 2.1740 2.9000 |
| 39 | * 4 0.0320 0.2708 1.2320 2.3360 2.9760 |
| 40 | * 5 0.0466 0.3719 1.4530 2.4880 3.0440 |
| 41 | * 6 0.0665 0.4938 1.6680 2.6280 3.1130 |
| 42 | * 7 0.1039 0.6910 1.9500 2.7900 3.1860 |
| 43 | * 8 0.1237 0.7790 2.0500 2.8590 3.2340 |
| 44 | * 9 0.1986 1.0660 2.3320 3.0090 3.3090 |
| 45 | * 10 0.2803 1.3010 2.5050 3.0850 3.3380 |
| 46 | * 11 0.3548 1.4740 2.6170 3.1340 3.3590 |
| 47 | * 12 0.4702 1.6870 2.7340 3.1800 3.3730 |
| 48 | * 13 0.6030 1.8870 2.8410 3.2300 3.4050 |
| 49 | * 14 0.7530 2.0740 2.9280 3.2580 3.4170 |
| 50 | * 15 0.9250 2.2510 3.0040 3.2940 3.4380 |
| 51 | * |
| 52 | * Using an equivalent model approach with two resistors |
| 53 | * |
| 54 | * 5V |
| 55 | * | |
| 56 | * Z |
| 57 | * Z Resistor Value for RV |
| 58 | * Z |
| 59 | * | |
| 60 | * +---> Output signal |
| 61 | * | |
| 62 | * Z |
| 63 | * Z External RD |
| 64 | * Z |
| 65 | * | |
| 66 | * GND |
| 67 | * |
| 68 | * will NOT work out of the box since RV = RV(RD). |
| 69 | * |
| 70 | * The following approach will be used going forward based on die pictures |
| 71 | * of the AY8910 done by Dr Stack van Hay: |
| 72 | * |
| 73 | * |
| 74 | * |
| 75 | * 5V |
| 76 | * _| D |
| 77 | * G | NMOS |
| 78 | * Vg ---|| |
| 79 | * |_ S Vs |
| 80 | * | |
| 81 | * Z |
| 82 | * Z Resistor Value for RV |
| 83 | * Z |
| 84 | * | |
| 85 | * +---> VO Output signal |
| 86 | * | |
| 87 | * Z |
| 88 | * Z External RD |
| 89 | * Z |
| 90 | * | |
| 91 | * GND |
| 92 | * |
| 93 | * Whilst conducting, the FET operates in saturation mode: |
| 94 | * |
| 95 | * Id = Kn * (Vgs - Vtn)^2 |
| 96 | * |
| 97 | * Using Id = Vs / (RV + RD) |
| 98 | * |
| 99 | * Vs = Kn * (RV + RD) * (Vg - Vs - Vtn)^2 |
| 100 | * |
| 101 | * finally using Vg' = Vg - Vtn |
| 102 | * |
| 103 | * Vs = Vg' + 1 / (2 * Kn * (RV + RD)) - sqrt((Vg' + 1 / (2 * Kn * (RV + RD)))^2 - Vg'^2) |
| 104 | * |
| 105 | * and thus |
| 106 | * |
| 107 | * VO = Vs * RD / (RV + RD) |
| 108 | * |
| 109 | * and this can be used to re-Thenevin to 5V |
| 110 | * |
| 111 | * RVequiv = RD * ( 5V / VO - 1) |
| 112 | * |
| 113 | * The RV and Kn parameter are derived using least squares to match |
| 114 | * calculation results with measurements. |
| 115 | * |
| 116 | * |
| 117 | * FIXME: |
| 118 | * There is voltage of 60 mV measured with the EX520 (Ri ~ 10M). This may |
| 119 | * be induced by cutoff currents from the 15 FETs. |
| 120 | * |
| 121 | */ |
| 122 | |
| 123 | |
| 1 | 124 | /*************************************************************************** |
| 2 | 125 | |
| 3 | 126 | ay8910.c |