Red Pitaya DAC performance

In Short

The RedPitaya fast analog outputs have a noise level of the order of the 3-4 least significant bits. This noise is correlated with the switching of digital signals on the board, notably switching of the digital output signal itself, which leads to a nonmonotonic DAC performance. With a tiny modification of the board, this problem can be removed: DAC’s are nicely monotonic and noise performance improves so that the outputs have about 13 ENOBs.

Symptoms of the problem

With the RedPitaya V1.1 (the currenly sold version of it), I have observed a somewhat strange performance when it comes to the analog outputs. Since I use it mostly for feedback, I have done quite a few measurements of the analog transfer function realized with the internal PID module.

The measurement is simple: Send a sine of fixed amplitude (always 0 dBm in this post) and variable frequency to the analog input of the RedPitaya (properly terminated with 50 Ohm), set the PID module to a constant proportional gain, and measure the output signal (normalized by the input sine) to recover the effective gain and phase of the digital PID controller. This can be done very efficiently with commercial network analyzers like the Agilent E5061B that we have in our lab at the LKB.

For effective proportional gains down to about -30 dB one obtains pretty much what theory predicts for a perfect PID controller, however at lower gain I get this:

unmodified

The variable p in the label stands for the proportional gain setting in counts (that is, the integer you assign to the FPGA register holding the proportional gain), where 4096 would nominally correspond to unity gain. A factor of 3 in gain corresponds to a theoretical increase of roughly 10 dB of the transfer function (10*log10(g^2)), but the DC-gain in the low-gain region changes way less than that. Even worse: above a few hundred kHz, we measure higher gain for p=1 than for p=3, that is, a higher p-gain leads to a decreased output signal!

It is fair to say that this only occurs for rather low gains, but since I wanted to realize arbitrary transfer functions with digital filters implemented on the FPGA, I did not want to have to take into account this effect (which just reduces the effective number of bits of the converters, and therefore gives you less dynamic range than you’d expect from 14bit converters). So I started debugging the effect. In this, it was very helpful to get in touch with the Zumy Topcagic from RedPitaya, who was as interested as me in finding the bug and helped me with many suggestions and schematics.

Long story short: The DAC’s on the board provide a unipolar voltage to which a constant offset is added in the anlog circuitry just before the output SMA connectors to make the output swing from -1 to +1 V. The problem is that this offset is directly derived from the +3.3V digital supply voltage. That means, that any change in the digital supply voltage, e.g. due to switching on or off a LED, may also influence the analog output voltage. This is expecially problematic when the supply voltage fluctuates due to the switching of digital pins of the DAC’s: In this case the (undesired) offset fluctuation is added to the (desired) change of the DAC output voltage, and may cause nasty crosstalk or a nonmonotonic dependence of the output voltage on the digitally set value for the output. That is, you tell the RedPitaya to increase the output voltage and it actually decreases!

You can test this on your device in various ways, the easiest being: Output a linear ramp, increasing the DAC register value by 1 unit per 10 ms or so, and monitor it on a scope or on the RedPitaya input. You will observe that this ramp is not perfect. If you have other things working in parallel, such as the LEDs blinking or the second output doing something, then the irregularities will get worse.

The solution: There are two possibilities.

  1. Use a voltage regulator to stabilize the voltage that is used to create the offsets for the analog outputs. The original design has actually foreseen this option and all you have to do is buy the right regulator and place it on the board, together with a few resistors and capacitors. A detailed description of this modification can be found here. While the design allows you to place both a regulator for positive and negative analog supply voltage, you only need the positive one to remove the bug. As far as I know, RedPitaya is working on making this version the new standard. Result: regulator
  2. Remove two resistors per output from the board, which will disconnect the noisy offset voltage from the output. This will lead to a unipolar output going from 0 to 2 V (instead of the original -1 to +1 V). But it will also lead to even better performance than the regulator, with less work: offset removed

Which resistors must be removed?

With the naming on the picture below, R1 and R2 on the top side of the board are responsible for the offset of output 1, and R3 and R4 for the offset of output 2. offset removal.png

How to remove these resistors?

  1. Destructive method: Take a fine wire cutter and snap the resistors in question. This is fast and you can be sure that you won’t do any mistake in heating the board too much. But it is irreversible… unless you have a spare pair of those resistors.
  2. Unsolder. Its not too hard to unsolder these small components, but you should be aware that there is a very good thermal link between these components and the rest of the board. I sucessfully did it several times by setting my iron to 325-350 degrees Celsius, applying a little solder between iron and one contact of the resistor to remove and then gently pressing the iron against the resistor. After typ. 10s the resistor can be lifted to a vertical position with the iron. Then it can be pulled with a tweezer while the second contact is heated a bit. Other sucessful attempts used two solder irons to heat both contacts simultaneously. If nothing comes off after >20s, you are doing something wrong and should stop in order to not overheat the more sensitive components on the board (even though, I heated the entire board with a heat gun once for >2 minutes and it still worked after this), and try again with a higher solder iron temperature or by applying a bit more solder to increase the thermal contact.

Improved noise performance

Doing this operation not only improves the transfer function, it also lowers the analog output noise of the board. Integrating the noise specta between 500 Hz and 1 MHz (below 500 Hz the spectrum analyzer has a huge input noise) yields a 6.6-fold improvement of noise power when going from the regulator version (which itself is not very different from the original board) to the offset removed version.

noise

Performance in the lab

If you drive a 50 Ohm load with an “offset removed” RedPitaya output, the maximum current at +2 V is 40 mA. This is within the specification of the output OpAmps, but you can see that the RedPitaya suffers a little: Now there is a bit of crosstalk at low frequencies between the two outputs when an output is loaded with 50 Ohms. This problem is easily fixed in my applications by careful load impedance design, which is possible because I either use an output to drive high impedances at low frequencies (10 kHz).

For applications from 0 to 300 kHz, I design the load impedance as a high-Z (>1 kOhm) in order to not draw too much current. For frequencies above the range of interest I let it roll off to 50 Ohm to avoid reflections and limit the noise. I do that by putting an RC lowpass before the actual load, with typical values of 50 Ohm for the resistor and 3-30 nF for the capacitor. Even if the output drives 50 Ohm at higher frequencies, crosstalk between the two outputs is limited. I guess this is so because in this frequency range, capacitors on the RedPitaya board can properly buffer the fluctuating load current so that the supply voltage remains effectively constant.

For applications allowing an AC-coupled output (>10 kHz typically), I simply AC-couple the output by inserting a DC-block in series with the RedPitaya output. If you dont have commercial DC-blocks, you can also try to simply put a not-too-large (non-chemical) capacitor in series with the output which avoids any significant low-frequency load of the output.

Conclusion

I’ve been constantly using 4 modified “offset-removed”-RedPitayas in the lab for over two months now and did not have any problems related to the modification. Rather, the digital filters that I implement on the board have the transfer function that I expect from design and the output noise of the RedPitayas is at the level of the least significant bit. Only when I do a slow large-amplitude sweep on a 50 Ohm@DC-load, I see some crosstalk to the other RedPitaya output and the inputs – so I simply avoid doing that. With a bit of luck, RedPitaya will soon bring improved boards to the market which perform similar to this hack.

 

Advertisements

15 Comments Add yours

  1. Thanks a lot for posting this. I was about to abandon my redpitaya for our advanced control application. Now revived… 😉

    Like

  2. Jonas B. says:

    I am currently working on a control system with the Red Pitaya and your measurements are very interesting for me. I can see the same peak at around 200kHz as you do when connecting the output directly to the input and acquiring a Bode plot. Did you per chance measure the phase as well? I am getting a pole in the phase plot at around 600kHz (the lag seems to be more than -180° and therefore the plot “wraps” the phase to +180°). Did you also see such a behaviour? I would greatly appreciate an answer in order to differentiate between something inherent to the design of the RP or a faulty RP.

    Like

    1. lneuhaus says:

      Hi Jonas, I do have the phase information in my measurements as well. Give me a few days and i’ll try to post these data. Could you post or mail the phase plot that you measured? Is the magnitude response flat around 600kHz? Are you sure that your cable is short enough such that the phase response cannot be explained by delay? Does the situation get better when you increase the voltage amplitude? How do your data compare to a measurement of the Bode plot with the cable disconnected (check for crosstalk)?

      Like

      1. Jonas B. says:

        Hi,

        thanks for your reply. I compiled a .zip-file with the Bode plots of the previously mentioned RP and another one that I could lay my hands on (https://www.dropbox.com/s/k580wycvgldghj9/RedPitaya.zip?dl=0). Interestingly, the mentioned behaviour at around 600kHz is not existent in the new one. The conditions were the same (1V amplitude, direct connection from DAC to ADC via SMA cable of approx 10cm length). Since I do not have access to a NA I am unable to seperate between ADC and DAC problems. I might try a qualitative analysis using an oscilloscope and an signal generator, but that will have to wait until the week after New Years. Same applies to the crosstalk test, but thanks for the hint. I did not (yet) modify the RPs myself, but I will check which resistors are in place.

        Like

  3. I now took a closer look at this thing. I find that indeed on new versions of the board, the voltage regulators are in place, and the rms output voltage is ~200us in 50MHz bandwidth (100uV in 1MHz). Looking at things with a networkanalyzer however still is bad (with the bias removed and with the bias resistors in place) and only disappears if one moves away from zero offset (e.g. adding a DC offset to the NA output so that the signal going into the RP is stricly positive or negative). My interpretation (which I also strengthened by looking at signal generator output) is that the DAC itself has some funny behaviour on certain bitflip boundaries (e.g. midrange going from 10000000000000 to 01111111111111) where a strong spike ~300uV, 20us is observed. I can show you some data if you like. As I say, the (ugly) fix is to avoid such boundaries. For a feedback loop that would mean not to operate at points near these bad ones… then the response becomes essentially flat.

    Like

    1. lneuhaus says:

      Hi Christoph, thanks for your post. I would indeed be interested to see your measurements. If you dont have a blog, we could chat via email.

      I have also observed a large discontinuity around zero Volts before putting the regulator. With the regulator, it certainly decreases but I only checked the transfer functions as published in this blogpost. Do your data resemble these or are they quslitatively different? The datasheet of the DACs specifies a differential nonlinearity at the level of the LSB, which should amount to 2V/2^14=120uV. So your 300uV spike is well above the expected component performance and is likely due to the analog design of the redpitaya board. Thinking about it, I still believe that a crosstalk from yhe digital pin voltages on the DAC to the analog output is the best explanation for your measurements as far as you described them.

      My suggestion to you is to remove the resistors as described above (i do that on all my redpitayas now), in order to maximally decouple the output from the digital supply voltage. Have you tried that? The removal can be tested on only one output and is reversible, even though it is a little tricky to solder the small resistors back on the redpitaya board.

      Like

    2. lneuhaus says:

      Hi again Christoph,
      I re-read your post and noticed that you say that you already tried to remove the resistors. Are you therefore saying that your NA traces without resistor are worse than mine? It would be really interesting to see them. What input voltage amplitude did you use? Is it possible that rather the ADCs are the problem here?

      Like

  4. zenographie says:

    Hi
    Approximately one and a half year after you post your story, Red Pitaya board send directly by the manufacturer are still 1.0 versions (not even the 1.1 you mentioned)
    Your remarks and mods have never been so “up to date”. Thnks for your work and solutions.
    Je vous dois largement plusieurs bières
    Marc

    Like

    1. lneuhaus says:

      Hi Marc,

      interesting. I was recently wondering how the data reported here translate to the recent (1 year ago) change of Red Pitaya product names. I believe the following equivalence is right (based on pure guessing):

      STEMlab 125-14 = former RedPitaya board V1.1 with the voltage regulator upgrade (to actually get close to 13-14 bits at DC)
      STEMlab 125-10 = former RedPitaya board V1.0 or V1.1 without upgrades (i.e. nominally 14 bits, but actually rather 11 for the V1.1 board and no idea for the V1.0 board)

      Am I right to guess that you purchased a STEMlab 125-10, since everything else would be a scandal? Otherwise, I would ask for an exchange board from Red Pitaya if I were you.

      Liked by 1 person

      1. zenographie says:

        That was my first thought : did they messed with a shipping or inventory reference ? alas not… I ordered a 14 bits board and received a 14 bits board.
        I’ll try to contact the customer service, even if soldering 0402 and tssop is not a big deal here. Thanks for the advice. The hunt for 13 ENOB is just beginning :- ))

        Marc

        Like

  5. Mateusz says:

    My Pitaya is called 125-14 v1.0. There were no regulators on it. I added them but the input of the negative LDO is -3,16V. Whatever are the resistors I will never get -3.0V at the output. Do you have any hint for me?
    Before soldering the regulators I have removed R1, R2, …. and I lost them. Could you please tell me what are their values? In my case removing the resistors does not simply shift the output range from -1V 1V to 0V 2V. I just don’t get the negative part. (One bit of resolution gone…).
    I profoundly suffer lack of electrical schematics.

    Like

    1. lneuhaus says:

      Hi,
      I do not know to what extent the board layout has changed from “RedPitaya v1.1” (the board that I have described in these blog posts) and “125-14 v1.0” (the one you have). So I suggest to proceed systematically:

      1) What are you trying to achieve by modifying your new board? Have you confirmed that the performance was worse that you would expect from a 14 bit device? Do you want a) lower output noise, b) unipolar output from 0 to 2 V, and/or c) monotonic performance?
      2) If you dont need unipolar output and want to put the resistors back, on my board the values were 11kOhm and 680 Ohm, and since they were in parallel, probably a single 680 Ohm resistor will do a decent job already.
      3) For the regulators, as far as I remember, only the positive 3.3 Volt regulator is needed to improve the analog performance. This voltage is fed through a resistor network to the negative input of the output op amp. The signal from the DAC then goes to the the positive input of that same opamp, with the result that the unipolar DAC signal becomes centered around 0 volts.
      4) I can try to help you, but without a 125-14 board at hand I am as good as anybody else. In that case maybe you could post some pictures of the relevant areas on your board with some words on the modifications you did to it. Otherwise, maybe reaching out to RedPitaya could get you some help. Especially if you were trying to fix a defect or sub-specification RedPitaya board in the first place.

      Like

      1. Mateusz says:

        Thanks for your reply and all advices. In principal I don’t care about the symmetrical output range. Most probably I will be constrained to match the output to the actuator I use. My goal is to increase the dynamics (gain the resolution bits) and decrease noise in general.

        I verified that the output range is in fact 2V. I think that the reason why I saw just half of the signal I was generating, was due to integrator windup which was set on the same output with an arbitrary wgen. (Is it possible? If so, is there any way to zero the integrator sum of pid module?)

        Thank you very much for the resistors values.

        I verified that supplying Red Pitaya from a non-switching power source is making things better. Next days I’m going to measure my noise floor.

        I noticed that there is a cross-talk between input and output. But before asking for help in solving it I must verify this fact.

        Like

      2. lneuhaus says:

        I agree:
        1) Noise floor should be measured again, since it is unclear what has changed with the introduction of STEMLab125-14 and -10.
        2) Linearity should be measured as well, i.e. put a slow triangular ramp to one output and make sure that there are no “holes” or “jumps” in that ramp.

        About the integrator: Are you using the official Red Pitaya code? There used to be a way to “reset” the PID modules, which resulted zero output from the PID module if the gains were zero, even after un-resetting them. Alternatively, if you are using my software from http://www.pyrpl.org, you will find a property pid.ival of each PID module that holds the accumulated integrator output voltage, and writing to that property a la pid.ival=0 would set the accumulated value to the one you want. Depending on the gain settings of the integrator and the input signal, it then stays there or drifts away from it.

        About the crosstalk: There is definitely some crosstalk, from any in/output to any other. I have a figure of about -80 dB in the back of my head, but this is really frequency-dependant and also depends on what you connect to the in/outputs (what impedance, what “antennas” behind, whether you have modified your board etc). So I would not be surprised if spikes of that crosstalk could go up to -50 dB. Nowadays, I would always do the measurement as a calibration before the real measurement. For example with the network analyzer GUI of PyRPL, this kind of measurement is a matter of 12 hours.

        And last about the power supply: Switching power generate a lot of spurious noise. I found that most noise was radiated rather than transmitted through the power supply cable, i.e. putting low-pass filters behind the power supply did not help in reducing that noise, but moving around the redpitaya, or putting it into a metal box did help. Completely replacing the power supply is a very good option if you can. For info, I was also able to use a 6V lead battery connected to a microUSB cable to run my redpitaya without any detectable damage to it. In my case, I could run it >12h with a battery that weighted about 1kg. Using a cellphone powerbank works even better.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s