SPI DAC board to drive oscilliscope channels - Page 1
Forum section: electronics / projects

author: timpattinson
author_rank: Contributor
timestamp: December 22, 2018, 07:45:42 am
content: Hi,What I am trying to do is output information from a MCU to an oscilloscope in real-time to aid in development/debugging of a motor-drive system.I have considered three ways to do this. The MCU i'm working with has a SPI port available, and 4 hardware PWM pins.I have more time than money (EE student) so I want to do a DIY solution.1. Interface to a DAC over SPI2. Use the PWM pins to output a direct pulse-width and measure this3. Use the PWM pins with a LPF as a voltage DAC1. requires the most work and has a bit of software overhead.2. Works well, but doesn't show up as a wavy line on the scope (no intuitive waveforms)3. Don't have a high enough carrier frequency, as the carrier is tied to the main PWM carrier at about 10-20kHz, and I am looking at 0-1kHz signalsSo I have decided to go with option 1 and make a small board with some DACs. The concept is simple:Board header with power and SPI --> 20cm ribbon cable --> PCB with DAC --> Male BNC --> Coax cable --> OscilloscopeFor sampling frequency, 40kHz maximum, probably more like 30kHz. There is no point outputting data faster than that as nothing internal to the MCU changes any quicker.I would like sufficient analog bandwidth for this (Dunno how much, but i doubt it's a problem to reach)I have chosen to have 4 channels. This will only be conected to oscilloscopes so I decided a 12-bit DAC is sufficient to exceed the resolution/noise floor of anything I connect it to.I am considering the TI DAC7554https://media.digikey.com/pdf/Data%20Sheets/Texas%20Instruments%20PDFs/DAC7554.pdfand the Maxim MAX5715BAUD+https://datasheets.maximintegrated.com/en/ds/MAX5713-MAX5715.pdfI have available 3.3V and 24V supply voltages with sufficient current capability. Regarding output voltage, I'm not fussed about whether it's unipolar or bipolar, although differential output is not required.The exact output voltage range is TBD, but I suppose to maximise SNR/dynamic range of the oscilloscope input a bipolar signal would be better.So the questions I have:What voltage output is most suitable for driving an oscilloscope input (nominally 1Meg/20pF) with the best possible performance, Do i require 50R termination at these frequencies?What DAC specifications are most important for this application?Do I need to buffer the DAC output? They advertise similar drive capabilities (2kohm, 200pf) but will an external buffer help at all?I intend to keep this thread updated as I do schematic design, receive PCBs and test them.Thanks,Tim

author: jbb
author_rank: Super Contributor
timestamp: December 22, 2018, 09:36:24 pm
content: I've been right where you are, TimI can't be much help with the 'scope range, but i have used this sort of trick in the past. (Among other things, I used a VGA port on an FPGA board.)I can offer some thoughts:'Scopes generally only have 8b ADCs, so there's no need to stream about maximum signal quality. But do keep an eye out for DC offset drift on bipolar signals.If your micro has a good chunk of RAM left over, you can make a software 'scope (buffer, trigger, readout etc.) and get raw dataUsing PWM outputs for data it probably quite annoying from a filtering / decoding viewpoint. E.g. a simple low pass filter will add some delay and confuse comparisons with real voltages and currentsIt's a shame to turn nice crisp internal digital data into fuzzy analog data.So when my colleagues were having similar concerns a few years ago, I suggested:Form all the outputs you want (i.e. data structure of measurement and state variables) into a data packetStream the data packet out an SPI port (use CS for framing) once per control cycleCollect SPI data on digital 'scopeSuck raw data into Matlab and decode to appropriate individual variables (I'm sure Python and matplotlib would do just fine)They used a USB 3 'scope with big sample buffer (Picoscope or maybe Cleverscope) and an API to run the show directly from Matlab. They said to me a couple of months later that it worked really well and helped a lot.Let's look at possible capture size:Need 3 channels (CS, SCK, MOSI). Unless you're willing to use some analog combining resistors to combine all 3 signals onto 1 channel and write a custom decoder.Assume 20 MSample memory on 'scopeScope sample rate probably needs to be minimum 4x data rateHence can get around 5 Mbits out of the controller. That would be approx. 300,000 16b values.At 20kHz execution rate and 15 signals of interest, that's about 1 second..

author: timpattinson
author_rank: Contributor
timestamp: December 23, 2018, 02:27:56 am
content: Hi jbb,Thanks for the reply.I'm still looking for a way to display things on the scope, but I might just use both.I'm currently filling a buffer in the switching interrupt, and printing it to the serial as a table, but it's not synchonised to the scope, so your idea sounds promising. The scope I'm using (4ch Tek MDO3000) is 10M record length, and trusting my interpretation of the specs I should be able to get 25MS/s at 40ms/divI don't have the digital inputs enabled, but potentially I should be able to use just SCK/MOSI (with careful SPI settings) leaving the other two channels free to show the AC currents.On another note, I'm slightly confused by the specifications of the scope input..Looking at the page in the scope manual describing the DC offset range (attached). Is there a circuit inside the scope which subtracts a DC offset, allowing for a more sensitive measurement? I'm trying to decide whether I need a bipolar output to use all the range of the scope. At 1V/div, can I use +-5v, or is it possible to have a 0-10V output with the same resolution/performance?

author: jbb
author_rank: Super Contributor
timestamp: December 23, 2018, 06:35:13 pm
content: Hi TimYes, there is an internal DC level shift in the scope. From those specs you could certainly do 0-10V with 1Meg input impedance.Before designing a board, how about you do a quick check on the scope - just try to set it for 1V/div and 5V offset.

author: timpattinson
author_rank: Contributor
timestamp: December 24, 2018, 02:36:13 am
content: Good point, that may have to wait until after Christmas. Anyway I can probably get started knowing i'll need some kind of opamp circuit on the output.

author: fchk
author_rank: Frequent Contributor
timestamp: December 25, 2018, 11:03:50 pm
content: Basically, all you need is a fast debug output, right?Why go analogue then?My idea:Get a FTDI FT232H or FT2232H chip or breakout board. These USB chips can do not only UART but also SPI via their MPSSE engine."MPSSE is capable of a maximum sustained data rate of 30 Mbits/s." (quote from data sheet)This should be more then enough for 40kHz sample rate.