USB-I2S Solutions 2020


1) CMEDIA. 

Doesn't looks active, never reply to my emails, only resend that to their local agents in SHZ. Local agents are ignorant as usual in mainland-china, any tech question will take months of email ping-pong. Also, agents are crazy greedy, they asked me $5 for CM6642 bridge, which I found for $2 finally. The chip(6x5mm QFN) is quite handy just 4pcs 0402 external components required, single power rail 5V, 20mA at 24/44.1. 

The chip contains OTP for the FW, and CMEDIA gave me win exe app to program IC by USB(BTW, the DLL used with the app was made by Realtek!). However, CM6642 contains the design defect, it has no CRC validation for audio packets, hence, any dust in the USB-C connector may cause a loud noise. 

CMEDIA product manager said that they can't fix that defect by FW, hence, only the new silicon version may help. Actually, most USB audio bridges(but not XMOS) made on 8051 free core and state machine, hard-logic for the fast USB operations. The FW(8051 program code) may correct some functions but not all.

Pros: compact, low power, no external oscillator required(PLL from USB's 48MHz), single power rail. It doesn't need driver at all.

Cons: SPDIF output only with 24/192 limit. Near to zero support, design defective chip. A quite bad idea to go with cmedia in 2020..


2) XMOS. 

All app info is opened, well documented. Good support forum, easy to start, easy to modify a custom FW(I spent a couple of days).

Cons: Expensive chips(XU208 PCM 32/384 DSD256 near to $10), no free Win driver. Huge power consumption, 24/44.1 about 110mA, just a lot of surrounding parts. absolutely not suitable for a portable purpose.

3) Realtek ALC4050, it is a combo, the same as CM6642 i.e. DAC+HPA + ADC, supplied with I2S port Off. 6x6mm QFN, single-rail power 5V, a few surrounding parts(5pcs 0402 caps and 1 res) needed to work as USB/I2S bridge. 32/384 DSD256. Core 1.2V, 18mA 24/44.1 consumption. Very low cost, $1.3-1.5. 64kB flash for the FW onboard. Widely used in the new PC motherboards and USB-C/3.5mm jack adapters.

Cons: Zero support, even to get I2S On is impossible(I can On/Off anything in CT7601 source code during a couple of minutes!). In the case if Realtek will offer its source code, it would be the most advanced USB/audio bridge for a portable purpose!

 18 bit DAC: Precision Voltage Source

Introduction

我在Analogicg參與了AN8200精密20bit DAC的開發,這是非常精密的六位電壓源,輸出範圍可從100mV至最高1000V。

2000年代早期,這項產品是出自Data Precision唯一的產品線。為何?因為其具有驚人的表現且價格合理。因此,全世界的自動測試裝置系統通通採用了它。事實上它後來也被兩家以上的公司克隆。我想要建造一個相似的產品,但是更簡單、超便宜並更小。於是完美的選擇便是LTC275x 系列18 bit DAC。

這裝置應該有如下的能力:
It should have the following capabilities:
  • 輸出範圍為0至5V以至正負10V
  • 10ppm的精密度且飄移不超過10ppm
    • 使用優於3ppm/C的穩定基準
  • USB或者前面板控制
  • 全隔離
  • 小巧且便宜:低於USD $100的零件成本

18b dac box

Design


我很快地決定使用LTC2756A 單通道18BIT DAC,由於只打算製造少量的成品,因此會採用最好的A級。A級具有令人滿意的0.5LSB INL,售價USD 45元;而B級則是2LSB,35美元。以10V輸出來說,1 LSB代表40uV,0.5 LSB就是20uV,等效於10V的2ppm,相當棒!


Linear Tech的LT2756參考電路使用LT1468精密OP於電壓基準部分,以及作為輸出的I/V轉換器。我有一管的LT1469,也就是雙通道版本的LT1468,因此我決定採取雙通道設計;不過雙通道OP在精密線路中相較於單OP還是有一些輕微缺點。
  • 雙OP功耗是單OP的兩倍
    • 這代表兩倍的溫昇
    • 以及約兩倍的偏壓飄移
    • 以及更高的偏流以及飄移
  • More complicated or compromised layout if the two circuits aren't naturally close.更複雜的線路或者犧牲最佳化佈線,如果線路原本就不夠接近的話。
  • If one amplifier is the output amp, its temperature rise will increase with higher load current
    • This can cause the reference section to drift with output load.
But.... the increased baseline power and therefore the temperature is fairly constant and so doesn't contribute too much to drift.  

Also I think there generally will be a low load on this circuit, like micro amps. If I load it to much ( > 1mA) then I expect a bit more drift.

對於10V量程的設計,18BIT全用上的話就是262144步,但如果使用250000替代,則每步就是40.00uV,這會方便一點。

如果使用全18BIT,1 LSB就是38.147uV,就不方便了。於是我想到了一個簡單的解決方案。 

Instead of a 5V reference, use 5.0 * 262144 / 250000 = 5.234V. 

比起5V基準,使用5.0 * 262144 / 250000 = 5.234V為基準電壓。

額外好處是,量程稍微增加到10.486V;但是如何把增益調整為1.0486倍? 很簡單,採用non-inverting、低飄移的OP,並搭配溫度係數25ppm/0.1%的電阻。

為了得到一個放大1.0486倍的放大器,使用一個10.0K以及487歐姆的回授電阻即可。

因為10K以及487R僅貢獻5%的增益,因此每個25ppm的電阻僅貢獻25ppm的5%,僅為1.25ppm。

我在這一級採用了低成本的OP07。



For a 5V reference, I chose the ADR431 which is 3ppm/C.

To calibrate the output for near-perfect 0.0000V and 10.0000V, it is necessary to have gain and offset calibration. 

Should I use a software cal or hardware trimpots? 

With software you can't get much closer than about 1/2 LSB of offset error. And the gain calibration affects the DAC LSB step size. 

And as long as the trimpots aren't contributing much change, they also don't contribute much signal change (or drift).  

The LTC2756 DAC has convenient gain and offset adjust pins. Just feed in a low correction voltage to these pins.

Here is the schematic diagram for Rev 1. J2 is 
the 5V power and SPI in connector, driven by LeoLed, my small front-panel Arduino board.

Sch1


以下是內部照。

上面的板子是LeoLed的背面,LeoLed是一種搭載OLED顯示器的Arduino Leonardo控制器。

下面則是Rev0 18BIT DAC電路板。

guts



控制Control

LeoLed搭載一個128X64的OLED圖像顯示器,另有Leonardo式的Arduino處理器。
另外LeoLed也內建一個16位元的ADC以及優異的12位元DAC數個,雖然這個計畫用不到。
搭載14Pin的擴充端子具有+5V供電以及方便的IO。
可完美驅動精密SPI型DAC。
原本打算做為小型的量測面板以及控制器,不過我已經在數個計畫用上LeoLed,包含電子負載以及SMU。



LeoLed 特色:
  • Arduino Leonardo (ATMEGA32U4) 處理器
  • USB介面但不須 USB to serial轉換: faster USB, 不須設置Baud Rate
  • +5V 供電自USB
  • 128x64 1.3" OLED display, SPI
  • Buttons for controls
  • Rotary encoder with switch
  • I2C 隔離器*
  • 16b ADC, 12b DACs *
  • 5V-5V隔離型DC-DC轉換器*
* 未使用於18b DAC 計畫。

For SPI data isolation. 
I like the Silicon Labs Si86xx series parts.
For this design the 6 channel part with 5 signals in one direction and one return signal will do:  Si8661.

The power needs of this project are minimal.

 A few tens of milliamps of +/- 15V, and +5V. A small 1 watt, +5V to +/-15V DC-DC provides the +/-15V as well as the required isolation. 

A small +5V regulator makes the +5V. 

I have been bitten by the common-mode switching noise of DC-DC converters so to keep noise low, a common mode filter and a .01uF safety cap should help.

Here is a view of the LeoLED board.  

It and the 18b DAC board mount nicely in a Hammond plastic box. 

leoled

韌體Firmware

The firmware runs on an Arduino Leonardo-style (ATMEGA32U4) processor. 

SPI graphics for the OLED使用U8G2 資料庫。 

The hardware interface uses bit-bang SPI to drive the DAC. 

I do this partially because the hardware SPI is busy doing the OLED graphics, and partially because the SPI requirements for this DAC are pretty slow. 

對於低速SPI裝置,我通常只使用bit-bang SPI. 

宣告SS/ pin low, set up a data bit (MOSI or SDI), and toggle the clock (SCK). 

接著left-shift (data <<1) out however many bits are needed in a FOR loop.  

For a READ, shift in the read data. It only takes a few instructions. 

Depending on the slave, you need to control the clock polarity. 

Analog Devices通常使用low-going clock. 

LTC and TI 通常使用high-going clock. 

timing

以下是 bit-bang SPI 的常用方式,其方式為a 32 bit WRITE operation to the LTC2756.

/*  Low-level Bit-bang 32 bit SPI Write for LTC2756 DAC.
    Data is clocked in on + edge of CK\
    Assert SS/, clock out 32 bits, de-assert /SS
*/
void spi32W(long data)
{
  int i;
  digitalWrite(SPI_CK, 0);    // CK Should already be in this state
  digitalWrite(SPI_MOSI, 0);
  digitalWrite(SPI_SS, 1);

  digitalWrite(SPI_SS, 0);
  for (i = 0; i < 32; i++)
  {
    if (data & 0x80000000L) digitalWrite(SPI_MOSI, 1); // MOSI = 1
    else digitalWrite(SPI_MOSI, 0);                 // MOSI = 0
    digitalWrite(SPI_CK, 1);                        // Clock HI then LO
    digitalWrite(SPI_CK, 0);
    data = data << 1;                               // Shift up
  }
  digitalWrite(SPI_SS, 1);
}

The initial firmware uses an underline cursor to select the digit to be adjusted. 

編碼器用來增減數值。 

兩個按鈕控制游標的左右。

不巧的是,目前U8G2以及其他LCD顯示資料庫並沒有自動游標
因此我畫了一條短線位於合適的字元底下,並忽略了小數點,簡單有效。


關於更多韌體細節,參考 
LeoLed digital panel meter。(失效!!!)

This project needs a proper USB control interface, so ATE tests can set the voltage and range.

此計畫需要合適的USB控制介面,以便於ATE測試可設定電壓及量程。

我計畫導入並測試Arduino SCPI資料庫,並參考DIY-SMU的程式碼。

如果有興趣,我會製造REV2電路板以除去一些需要跳線或者斷路的錯誤。

Ranges and Calibration量程以及校正

My plan is to use hardware only calibration on the 10V range. 

This requires only multi-turn trimpots on the offset and gain trim pins. 

So if you want the highest accuracy, use 10V range. 

But hardware calibration takes, well, hardware, and is impractical to use on all the ranges. 

I'm not sure how important the other ranges are. 

The lower voltage ranges provide 1/2 the LSB voltage, so 20uV resolution. 

The higher voltage ranges provide bipolar voltages such as +/- 10V and +/- 5V. 

If you really need negative output, you could simply reverse the output terminals. 

Negative output may be more important in an ATE environment.

As far as calibration of the other ranges, EEPROM corrections for offset and gain would need to be implemented. These would provide very good cal, +/- 1/2 LSB.

Rev2 計畫

Since I am looking at adding SCPI software control, I also am looking at a Rev2 PC board. 

I originally built only one unit based on the Rev1 board. 

It did not have the x 1.0486 amplifier so used 2^18 codes full scale for 10.00V. 

But it worked very well, providing me with a very convenient, precision voltage to set the DIY-SMU project with.

I was having guilty second thoughts about my decision to use a dual op-amp.

 It should be the builders decision, right? 

So I made provisions for either a dual or two single op-amps. 

Here are the changes for the Rev2 board.
  • Fix rework errors
  • Op-Amp options
    • Dual opamp (LT1469) or
    • 2 singles (LT1468 or other)
  • 5V reference options:
    • ADR435: 3pppm / C
    • LM399 + LT5400: < 1ppm / C, select-able R4 to correct for LM399 V

More Stable Reference Voltage: LM399

The Rev1 board had a few minor PCB errors that needed correcting. 

And there was a bit of output voltage gain drift, traced back to the 5V voltage reference. 

After I built this project, I played with LM399 temperature controlled references

Particularly, ways to get better (1PPM) accuracy from these crude 7V +/- 3% devices. 

For a perfect 5V, you can use an LT5400 matched resistor network which has < .5ppm tempco match. 

They build a version with two 1K and two 5K resistors. 

The two 1K's can be wired in series to get 2K. So it's ideal for building a 2K/5K divider for converting 7.0V to 5.0V. 

But how to deal with the +/- 3% tolerance? 

Turns out since 18bDAC wants a 5.243V reference to achieve 40uV / LSB, 

adding a x1.0486 gain stage will do it, then just pick the value of R4 (shown as 486 ohms) 

as a function of the LM399 voltage. 

The gain will be nominally +4.86% (x1.0486), but can be easily adjusted from 1.000 to about 1.08  just by changing one resistor: R4. 

It means you need to measure your LM399(s) first, then buy the correct resistor(s).  

This is a preliminary schematic.

It has the latest changes including the heater current limit and the reference driver op-amp, but has not been built yet. 

Wondering if I should add a +12V regulator.

sch



Since this stage only contributes 3-7% of the output voltage, it also only contributes 3-7% of the tempco drift. So a readily available 25ppm 0.1% resistor only contributes about 5% of 25ppm or 1.25ppm. Not bad for a $0.25 resistor. Here is a plot from a spreadsheet showing the R4 value to correct for a range of the LM399 Voltages. The bumps in the curve are because I use actual resistor values. The spreadsheet is in the project files above.

resistor vs lm399 V



The LM399 heater draws significantly more power than the ADR435 reference. I measured about 1W, but the power draw peaks at about 2.5W during a cold-start of the LM399 heater. 2.5W is the maximum power to draw from a USB 5V connector: 5V at 0.5A. Would a USB C connector help? A solution is to add a current-limiting circuit to the LM399 heater. I can also use +/- 15V or 30V to power the heater, drawing equal and lower current from both +/- 15V supplies,

On my LM399 page I talk about some surplus (so free) precision resistor networks that I have. These have 12 resistors, two sets of 6. Each has 2x10K, 2x1K, 3340 and 3224ohms. It didn't occur to me at the time that I can put the two 10Ks in parallel to get 5K, and two 1Ks in series to get 2K. These are in a nice 16SOIC ceramic package, more convenient than the LT5400 in a SSOP-8 with heat tab. And free!

I have not yet ordered these PCBs. Copy this design at your own risk.

SCPI Control

For SCPI control, 

I looked at 3 libraries I found: 




Thanks to Vini from the OSMU project for the pointers. 

One of OIC's examples implements a simple Source-Measure unit using Arduino ADC 

and PWM pins: nice. I tested the code with various number formats for the voltage settings: Integer, fixed point, and scientific notation. 

Now I'm changing the example to implement ranging, current measure, etc. 

I tried all 3 libraries. Here is a quick review:

LachlanGunn/OIC
This one was easy to install and to run the examples. 
I like that the basic example uses Arduino analog I/O. 
I found it to be a bit touchy: 
It seems to hang if you send it bad SCPI commands. 
Interprets floating point numbers fine. 
To specify commands is slightly cumbersome, requiring you to specify both the long and short forms as well as the string lengths.

  source = scpi_register_command(ctx.command_tree, SCPI_CL_CHILD, "SOURCE", 6, "SOUR", 4, NULL);
  scpi_register_command(source, SCPI_CL_CHILD, "VOLTAGE",  7, "VOLT",   4, set_voltage);


Vrekrer SCPI Parser
Also easy to install this library and run the basic example. 
The basic example is a dimmer, and controls an LED brightness. 
Command register format is more convenient. 
Just call out the name once, and no need to specify string lengths. 
Interprets Floating point fine. So far so good, I'll stick with this one for now. 
BTW F("stuff") causes the string to live in Flash memory. I did not know that.

  my_instrument.SetCommandTreeBase(F("SOURce"));
    my_instrument.RegisterCommand(F(":VOLTage"), &SetVoltage);
    my_instrument.RegisterCommand(F(":VOLTage?"), &GetSourceVoltage);

Jaybee.cz/scpi-parser
This one is not a native Arduino library. 
It it quite large, about 10 .h files and another 8 .c files. 
I spent a day trying unsuccessfully to coax it to compile on a Teensy, and then gave up.  
A real programmer could probably do it.

 

I began with the OIC library. 

I got it working on Teensy and on ATMEGA, and was happy with how quickly it came up. 

18b DAC was crying for a proper way to control it via USB. 

And unlike DIY-SMU, the 18b DAC is a simple project: Set the DAC to a voltage, done!

I moved the code to the LeoLed I use to control the 18b DAC. 

The code fits, but is a tight squeeze on the ATMEGA32U4 processor. 

Between the U8G2 library (with large fonts) and the SCPI Parser with floating point math, 

it's up to about 23K of the 28K available flash memory. 

For RAM, I use ~2K of the 2.5K available.

As long as I avoid too much feature-creep, it should be OK. 

I'd like to implement SCPI on the E-Load project soon, as well as on the upcoming Switch (MUX) project. 

Both of these projects use my LeoLed on a 'MEGA32U4. 

The Vrekrer and OIC libraries are about the same size.

If I run short of RAM or Flash, 
I could redesign LeoLed to use the newer

Arduino NanoEvery processor: ATMEGA4809, 20MHz, 48K Flash, 6K RAM, $11.  

It does not have native USB like the 'MEGA32U4, but instead uses a small AVR processor as a USB to serial.

I haven't worked with this processor. 

Another CPU upgrade option is

Teensy LC, a lower-cost ARM processor: 48MHz, 32b, ARM M0, 62K Flash, 8K RAM, lots of I/O, $12.



For the basic set of SCPI commands on 18b DAC, I use the following:



  /*
   *  *IDN?         -> identify
   *  *RST          -> Reset to known idle state: 10V range, 0.00V
   *  :SOURce
   *    :VOLTage    -> set_voltage
   *    :OUTput:    -> <OFF/ON> (does nothing for now)
   *    :VOLTage?   -> get_source_voltage
   *  :MEASure
   *    :VOLTage?   -> get_voltage from an 10b ADC channel
   */






The :MEASure:VOLTage? command reads the Arduino 10b ADC. 

It's just there to test some other SCPI commands. 

I am happy that both parsers deal with all kinds of 

number formats: 3, 3.14159, 3141.59e-3 all work fine.


Last Updated: 7/18/2021

SPICE

我花了數年時間研究SPICE的模擬,建立了SPICE模型的資料庫;這些資料庫有些是找到上山下海甚至自己對規格書曲線才得到。

大致上,日系大中小晶體,如東芝、NEC這些都有,所以日系放大器的模擬沒有問題。 而歐美系的,如ONSEMI(摩托羅拉)、IR、NS、TI、ADI這些,重要的都有,配合日系的晶體也多數可以完成模擬。 我用的是Multisim來模擬,DIYAudio等國外論壇則多是用免費的LTSpice分享交流。
Multism<軟體>採用PSpice<語言> LTSpice<軟體>採用LTSpice<語言>

兩者不可互相轉換或者說只有運氣好的情況下可以透過輕微修改讓LTSPICE轉PSPICE。至於為何要用Multisim而不用LT,只能說介面的友善度差很多,LT免費但相當機械化;Multisim至少對我來說我沒有買書參考,透過自學就上手了。LT透過大量指令來建立模型與模擬,而Multisim則多為友善的圖形化介面。 SPICE語言從1970年代由UC Berkeley就開始發展了,淵遠流長分支也很多,至今對於電路設計的輔助幫助相當大,方便之餘也大大降低開發成本。 初步構想是,我想藉由分享部分但重要的大中小晶體模型,至少足夠完成80%以上前後級的模擬運算,來讓更多人接觸Multisim以及PSPICE這門語言,甚至可以自立完成簡單的Layout,因為這些任務對於專長於友善介面的Multisim來說相對的門檻低很多,我記得我第一個GERBER檔案拿去洗PCB就是一個簡單的OP耳機放大器。 如果有更多人可以模擬簡易的單級OP放大器甚至畫PCB,也許有更多人可以走得更深更遠,而至少這樣可以透過共同的語言,來增加社群的討論能量,而成本僅僅是整理好並分享電晶體的SPICE模型,對我而言我相當樂意進行這樣的分享。我的真空管模擬模型也相當多,蒐集並建立資料庫一路走來也是花費相當多心血,真空管模擬如同實際機器一樣,又是另一個世界,而真空管模擬有多大的輔助並可以省下多少精力與成本,做過的人想必非常清楚。 我認為初步先建立一個聊天室比較恰當,有些有趣的想法例如可以設立一些任務解鎖,完成任務得到下一階段模型或者獲得真空管模型等等。全部過程將會是免費開源的,如果能幫助到更多人是最好的,就怕沒人願意做而已。剩下的還沒想那麼遠那麼多,有任何建議或評論相當歡迎!

Class A-Like Topology

- "New Class A" bias module (see Technics folklore - synchro bias) - "Super-A" bias module (see JVC folklore) - "No...