Bus Pirate “Ultra”: using ADS7042 12bit Analog to Digital Converter from the FPGA

ADS7042 pins. Source: ADS7042 datasheet page 6.

Beginning with Bus Pirate “Ultra” prototype v1d, all analog measurements are handled by the FPGA using an external serial Analog to Digital Converter chip. This lets us pipeline ADC measurements into the command queue so that bus interactions can be done with very precise timing.

We’ll be using Texas Instruments’ series of tiny ADCs with a max speed of 1MSPS: the ADS7041 (10bit) and ADS7042 (12bit). For the prototype we went with the 12bit version, but availability and final BOM price will dictate what goes into the final design.

ADS7042 sampling interface timing. Source: ADS7042 datasheet page 10.

The ADC uses a dead simple three wire interface that resembles SPI without a Master Out Slave In connection. CS falls, the first two clock ticks are 0, then the next 12 bits are the analog voltage measurement. We stripped down a copy of our Verilog SPI peripheral to drive the chip, the current source is here.

ADS7042 calibration interface timing. Source: ADS7042 datasheet page 24.

There are two methods of calibrating the ADC. Offset calibration can be done immediately after power up by sending 16 clock ticks, however it’s risky to depend on the ADC being in the reset state. Calibration can also be done at any time by sending 32 clock ticks, which is the method we used.

Bus Pirate “d” command retrieves the ADC value through the FPGA

This is a very basic test that retrieves the raw ADC value from the FPGA while measuring the programmable output power supply voltage.

In the final revision, absolutely every aspect of the Bus Pirate hardware front end will be controlled from the FPGA:

  • IO pins (added in v1a)
  • Logic analyzer and SRAMs (added in v1a)
  • Analog voltage measurement (added in v1d)
  • Pull-up resistors (added in v1d)
  • Programmable output power supply (to be completed in v1e)

It’s possible we might use a 3.0volt reference for the analog section on the next revision. Currently we can measure 0-6.6volts with a divide-by-two resistor divider and a 3.3volt referent. A 3.0volt reference gives a 0-6volt measurement range, which increases the resolution over our target range of 0-5ish volts and might mean we can use a cheaper, lower resolution ADC. The Digital to Analog Converter used in the power supply has almost no noise rejection, so a dedicated reference voltage would help ensure clean DAC output as well.

Bus Pirate Ultra 2.8 inch display and the danger of Taobao suppliers

We’ve been prototyping the Bus Pirate Ultra with a 240 x 320 pixel 2 inch LCD, but it’s just a bit small and hard to read from a distance. A 2.8 inch version is available that fits the full width of the Bus Pirate PCB, with the trade off of bigger pixels/lower pixel density. We bought a few displays from various “manufacturers” on Taobao and made up a daughterboard. It failed spectacularly because the datasheet was so wrong!

Anode and cathode pin locations in the “datasheet”
Anode and cathode position on the actual display

We don’t have to go beyond pin 1 to find a major and obvious error. The datasheet lists pin 1 as the LED backlight anode, and pins 2-5 as the cathode. The printing on the flex connector makes it clear that four cathodes (K1-4) join into a single trace to pin 1. A single anode (A) trace connects to four pads on the connector (pins 2-5). The backlight connections are backwards.

Coincidentally, datasheets for other similar displays (2.8 inch, 50 pin connector) match the corrected pinout. This datasheet just had it backwards. We reversed the backlight power and ground on the PCB by drilling out a trace and creating some strategic solder bridges. While the LEDs light, the display doesn’t respond to any commands so other connections could be wrong.

That’s not all. The flex cable is actually several millimeters shorter than listed in the datasheet, so it can’t reach the connector through the slot in the daughterboard.

We had similar issues with this supplier’s 2 inch display. The dimensions in the datasheet are a bit off, and their sample initialization code doesn’t work. We asked for an updated datasheet and received three different versions, none of which matched the actual display.

Their Taobao page has pictures of a factory and a nice section on after sales support. A charitable guess is that they manufacture runs of custom displays, and sell the excess on Taobao. That would explain all the different datasheets they so readily have available. We tried to get another grab-bag of PDFs for the 2.8 inch display, one of which might match the actual pinout, but at this point they got tired and ghosted us.

Will we stop buying prototyping samples on Taobao and 1688? Definitely not! It’s a great way to see what’s a cheap commodity product. This process plays out in the Shenzhen markets as well, people sell a lot of stuff without knowing exactly what it is. It’s kind of up to us to know what we’re buying, and sometimes it’s a crapshoot. When we find a sample we like, it’s time to send someone up to the factory to meet the boss, drink way too much tea, and ensure we’ll have a steady and consistent supply in the future.

Bus Pirate Ultra prototype v1d: the last alpha

Bus Pirate “Ultra” v1d is stuffed and about half tested. This should be the last alpha “figuring out if we can pull this off” version. New in this revision:

Analog voltage measurement is now done from the FPGA using a 12bit 1 million samples per second ADS7042 Analog to Digital Converter. This will let us pipeline voltage measurement commands with other bus commands and reduce dependency on any specific MCU.

The programmable output power supply is now controlled by a DAC104S085CIMM Digital to Analog Converter chip, instead of the DAC in the MCU. This further reduces our dependency on a specific MCU, and will later allow us to control the voltage regulator from the command pipeline in the FPGA. It may be possible to simulate different power supply conditions and glitches, for example.

A lot more thought went into the programmable output power supply. V1d measures current through a shunt resistor, and we added a small load to test it. There’s several other goodies in there, but we’ll reveal them later.

In addition to sampling voltages on each IO pin from the FPGA, we’re now sampling several other voltages from around the board (power supply output, current consumption, etc) . We swapped the 8 channel 74HCT4051 analog multiplexer with a 74HCT4067 16 channel multiplexer. This part of the board needs some more thought because some of the voltages would be better measured without the divide by 2 resistor divider currently used after the op-amp.

The display daughter board now uses a 0.5mm pitch flex connector. We though these connectors and the flex cables would be a nightmare to work with, but they’re actually a lot of fun. They’re really compact too.

After a little more testing we’ll get to work on v1e, which should be the first beta and possibly the first version ready for a small production run. Find the latest updates and follow a group build of v1d in the forum.

Bus Pirate cables arrive from DirtyPCBs.com custom cable service

We received 100 Bus Pirate cables using our pinout color scheme from DirtyPCBs.com custom cable service. The cables were just over $1 each for 100 pieces.

The primary reason we ordered these now is to get a feel for how the pinout color scheme works in practice before we commit to it permanently.

The leads are 30cm long, which seems a bit unwieldy in real life. The next version will be a few centimeters shorter.

One end is terminated with 1 pin female “DuPont” connectors. These are easy to use with breakout boards and bread boards that have 2.54mm header pins. We’ll need to choose a nice probe hook and mating crimp eventually.

While the wire quality is fine (top), it’s a bit stiff and we’d prefer something really nice for the final cable. The Saleae Logic cable (bottom) has really amazing tangle free wire with great flexibility. We took the Saleae cable to a bunch of wire manufacturers in Shenzhen, but none of them had anything close in terms of quality and flexibility. Our search will continue.

Bus Pirate Ultra v1d 2.8 inch display board

In addition to the 2 inch IPS LCD we’re been using with the Bus Pirate prototype “Ultra”, we’re also sending off a PCB for a larger 2.8 inch display. Both panels are 240*320 pixels, so the larger version probably won’t look quite as stunning as the smaller display with high pixel density. If it does pass muster, a capacitive touch screen controller option is available that might be an interesting addition.

APP NOTE: make an analog to digital converter using FPGA pins

A differential pin pair can be used as a comparator to create a basic ADC. This app note shows how to design a low speed (1 KHz) and “high” speed (50 Khz) ADC technique using only FPGA pins, a resistor and a capacitor. Regardless of whether we ever use this technique, it is illuminating to understand how SAR and Delta Sigma ADCs are constructed:

A simple Analog to Digital Converter can be constructed by adding a small RC circuit to an LVDS input on an FPGA or CPLD…. The LVDS input will act as a simple analog comparator and will output a digital ‘1’ if the Analog Input voltage is higher than the voltage from the RC network. By changing the voltage on the input to the RC circuit, the LVDS comparator can be used to analyze the Analog Input voltage to create an accurate digital representation… A low frequency signal can be processed using a simple Successive Approximation Register… A higher frequency implementation…can be implemented using a Delta Sigma Modulator function, which consists of a sampling register and a Cascade Integrated Comb (CIC) Filter.

Lattice Semiconductor

Via ferdinandk in the forum.

APP NOTE: Give your voltage regulator the margin it deserves

Texas instruments has an app note and video explaining how to make a programmable output power supply using a typical LDO voltage regulator and a DAC. This is the technique we used for the Bus Pirate Ultra power supply to get 0.8 to 5volts output, and it works a treat!

Consider the currents going in and out of the VFB node shown in Figure 3, which is connected to the ADJ pin of the LDO. Almost no current flows in or out the device through the ADJ pin (on the order of 0.01µA). As I previously mentioned, the output voltage of the LDO is always produced such that the voltage at the ADJ pin – and therefore the VFB node – is equal to the LDO’s internal reference voltage. Thus, the current through R2 is constant. It follows that any sourcing or sinking of current by the DAC through R3 is reflected as a proportional voltage increase or decrease at VOUT to compensate for the changing current that must flow through R1.

Bus Pirate Ultra display board v1d

Sorry for the poor image export. What have they done to Eagle?

The LCD carrier board for Bus Pirate prototype “Ultra” v1d went out today. This update matches the form factor of Ultra v1d (in progress) and has several minor changes:

  • Uses 10 pin 0.5mm flexible PCB connector, wired to the main board with a 1:N connection. This connector is much smaller and thinner than the 1.25mm connector on v1b, it reduces the space needed between the display board and the main board.
  • Flipped LCD orientation 180 degrees so font data can be written into bounding boxes in a more natural “left-to-right” orientation, eliminating the need to precalculate the text end point and write characters in reverse sequence
  • Nudged the display towards the IO header. We’ll experiment with some buttons in the remaining available space
  • Decoupling capacitors on LCD power pins

The 2 inch 240*320 IPS LCD display we’re been testing has a very pleasing pixel density, but we’re also itching to try the bigger 2.8 inch version. Next week we’ll send out a prototype carrier board for the bigger display, as well as some Bus Plug breakout boards.

BUS PIRATE: ADS7042 Analog to Digital Converter chip

Source: ADS7041 datasheet

In Bus Pirate prototype “Ultra” v1b we added analog voltage measurement to all the IO pins using a 74HCT4051 8:1 analog multiplexer and an op-amp. In the next revision we’re moving control of as many peripherals as possible into the FPGA. The FPGA doesn’t have an Analog to Digital Converter feature, so we need to add an external ADC chip.

We chose ADS7041/ADS7042 10/12 bit ADCs capable of 1MSPS with an SPI interface. The 12 bit version is $1.75 in 100s, the 10 bit version is slightly cheaper ($1.06). The 10 and 12 bit versions are pin-compatible. We’ll try both and decide later what works best.

There are much cheaper SPI ADCs, but for around a dollar this chip does 1 MSPS with a simple 3 wire interface. That’s the same top speed as the DSO Nano v3, so we can record samples in the two SRAMs and have a very minimal oscilloscope function on any IO pin.

Source: ADS7041 datasheet

The interface is read-only and doesn’t have any registers to configure, that’ll keep it simple to work with from the FPGA. Each conversion begins with two clock ticks, then the 10 or 12 bit reading follows. The maximum clock speed is 14MHz to achieve 1MSPS, easy to do with the FPGA.

This post is just a quick followup to yesterday’s look at three Digital to Analog Converter chips.

BUS PIRATE: three inexpensive SPI Digital to Analog Converters

Source: Microchip MCP4902 datasheet

As much as possible, we’d like to move control of all the Bus Pirate peripheral hardware to the FPGA. Then everything can be controlled through the state machine command pipeline. In Ultra v1c we moved analog voltage measurement to the FPGA by adding an SPI ADC. In a future revision it would make sense to move a few other things to the FPGA:

  • Pull-up resistor control
  • Programmable output power supply enable
  • Programmable output power supply margining (using a DAC)
  • v1d stuff not yet announced

For debugging and self-testing we need to keep some redundant connections to the MCU as well, but primary control should be through the FPGA.

We had a look at a few chips that could replace the Digital to Analog Converter in the MCU, here’s a few inexpensive options we considered:

MCP4902 8bit dual DAC TSSOP14

Source: Microchip MCP4902 datasheet

MCP4902 seems to be a classic Microchip part, available at Mouser for $0.99 in 100s. However, the smallest package size is TSSOP14 and a quick check of SZLCSC shows they only have the SOIC version with 17 pieces in stock. That’s not a great sign.

X
Source: Microchip MCP4902 datasheet

Each update of a DAC channel uses a 16bit command, maximum speed is 20MHz.

MCP48FVB02 8bit dual DAC MSOP10

Source: Microchip MCP48FVB02 datasheet

MCP48FVB02 appears to be a part Microchip acquired when they bought Micrel. It comes in an MSOP10 package which is an improvement over the MCP4902. It’s a bit cheaper at $0.90 for 100pcs at Mouser. It’s not stocked at SZLCSZ, which is a huge warning sign. Microchip Direct is really good about delivering parts in China if need be, but they can only deliver 1200 today and new stock won’t be available until February (three and a half months away).

Source: Microchip MCP48FVB02 datasheet

MCP48FVB02 uses a 24bit command to update each DAC, which is a full byte longer than the MCP4092. Both the MCP4092 and MCP48FVB02 operate at maximum write speeds of 20MHz, so the MCP48FVB02 will have a significantly slower maximum update rate.

DAC082S085CIMM/DAC084S085CIMM 8bit dual/quad DAC MSOP10

Source: DAC082S085 datasheet

Here’s where it gets a bit interesting. DAC082S085CIMM is a dual 8 bit DAC from Texas Instruments, available for $1.24 in 100s at Mouser. SZLCSC only has 8 in stock for around $2 in 100s (13.20RMB). Low stock is bad news, and a higher RMB price than USD price that points to a limited stock or specialty chip to avoid (i.e. not something with high demand in China).

However, the DAC084S085CIMM is similar but has 4 DACs. We could use the extra DACs to add more programmable output power supplies, or add a simple analog signal generator on a few of the IO pins. It’s available at Mouser for $1.58 in 100s, and at SZLCSC for $1.15 (8.68RMB) with 1700 available and 1300 shipped in the last month. That’s several good signs: it’s cheaper than the 2 DAC version ($2 vs $1.15), RMB price is cheaper than USD price, and there is a fair amount of stock and turnover at SZLCSC which means it’s probably being used in production somewhere. This seems like a good candidate.

Just to further verify, there are 50K in stock at the TI store, and 20K in stock at Digikey for a slightly higher price.

Source: DAC082S085 datasheet

Commands are 16bits, but where it really shines is the 40MHz maximum update speed. Twice as many DACs, and twice twice as fast as the Microchip DACs.

This is by no accounts an exhaustive list, but after looking at stock on Mouser, Digikey, and SZLCSC these were the best options close to $1. Did we miss your favorite DAC?