Gas station without pumps

2015 July 16

FG085 function generator bugs

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 17:50
Tags: , , ,

I previously reported on assembling the FG085 function generator kit and measuring its output impedance. I noted that the output impedance was only 46.7Ω, instead of 50Ω, and in Testing nFET body diode with function generator that the output current was limited to about ±5omA, which is ok for 50Ω at 5V peak-to-peak (±2.5V), but not enough when the maximum offset of 5V is added (or –5V, for that matter). I also complained about the buttons (particularly F/T and 0) needing to be pressed up from below, because the return springs weren’t strong enough to push the buttons back up.

I also noted in the first post that the cheap and noisy DAC had some bad glitches.  I decided to investigate that a bit more today, using the new version of PteroDAQ. The voltage calibration was reasonably good on the KL25Z board (about 0.28% too high), so I decided to use that one with 32× hardware averaging.

I set the FG085 function generator to 3.1V peak-to-peak and a 1.7V offset outputting a 1Hz upward ramp, and recorded for about 2 minutes (603882 samples). Looking at a couple of periods shows the glitches:

Glitches are observable in the traces caught by PteroDAQ.

Glitches are observable in the traces caught by PteroDAQ.

Although the glitches are visible, there seems to be some measurement noise. Indeed, zooming in makes the noise very evident:

The glitch at about the ¼ point is visible, but the discrete steps are hard to make out, being buried in noise.

The glitch at about the ¼ point is visible, but the discrete steps are hard to make out, being buried in noise.

I wrote a program (which I’ll be releasing after I do some more polishing on it, as part a suite of tools for analyzing data generated by PteroDAQ) to average copies of repetitive waveforms to reduce noise and get finer temporal resolution. This is similar to the code I wrote for dejittering the BitScope recordings, and I plan to merge the tools so that I don’t need two sets of software tools. Averaging 120 periods makes the waveform much cleaner—here are essentially the same two plots as above, but with the averaged waveforms:

Averaging the waveform reduces the noise.

Averaging the waveform reduces the noise.

After averaging the ¼-way glitch is very clear, and the discrete steps are easy to see and measure.

After averaging the ¼-way glitch is very clear, and the discrete steps are easy to see and measure.

Let’s also look at the top and bottom of the waveform, to see how well the voltage and period are set:

I synchronized the waveforms so that they passed downward through 2V at time=0.  The bottom voltage is approximately 64.44mV.

I synchronized the waveforms so that they passed downward through 2V at time=0. The bottom voltage is approximately 64.44mV.

The top voltage is approximately 3.25630V, and the period is approximately 1.00845s.

The top voltage is approximately 3.25630V, and the period is approximately 1.00845s.

The voltages were supposed to be 150mV and 3.25V, but instead came out as 64.44mV and 3.2563V. The top end is about right but the offset is 1.66V instead of 1.7V and the peak-to-peak voltage is 3.1919V instead of 3.1V. I don’t know if these are hardware errors (as the DAC nonlinearities are) or an off-by-1 error in the software that sets the peak-to-peak voltage.

The period being 0.845% too long is almost certainly a software error—the crystals aren’t that far off. It looks like they are almost exactly 2 steps off on the duration, as if they had added one instead of subtracted one from 256 somewhere. They claim a frequency error of at most 0.0005960 Hz when frequencies are below 40Hz, and the observed error is 14 times that. I am reasonably certain that the error is in the function generator, not PteroDAQ, since I get similar error when measuring with the BitScope digital oscilloscope.

The ¼-way glitch shown above is not the biggest one—the ½-way one is bigger:

The glitch at the midpoint is a transition downward of about 5 steps, instead of a transition upward of 1.

The glitch at the midpoint is a transition downward of about 5 steps, instead of a transition upward of 1.

I suspect that the error comes from not including the output impedance of the digital outputs in making their crude DAC, so that the resistor ladder is not properly balanced. But relying on digital output pins having carefully matched output impedances is a state of engineering sin.

Overall, the FG085 looks like a decent student project (maybe B work), but not the work of professional engineers.

Update 2015-Jul-16: Just a little after publishing this post, I checked the firmware release info on the FG085, and it seems that I don’t have the 113-08502-053 [ 2014.08.01 ]  release of the DDS core firmware which “Fixed a bug that caused frequency error when frequency setting is less than 40Hz.”  So now I have to figure out how to update the firmware.  The manual assumes that you have an AVR programmer, but I’ll be using an Arduino as ISP, which takes a while to look up and set up.

 

Update 2015-Jul-16 21:29:

I did the firmware upgrade, which took me much longer than I thought it would, because I had to install avrdude again, edit the ArduinoAsISP sketch to work with the Leonardo board, edit the avrdude.conf file to include m48p (it only had the m48, which has a different signature), and generally debug using the Arduino as an in-system programmer.  The command I ran that finally worked was 

avrdude -c avrisp -p m48p -P /dev/tty.usbmodem24141 -b 19200 -U flash:w:113-08502-053.hex -v -v -v -v

I recorded the waveform and now get a period of 1.0005 seconds, which is just within spec for the FG085.

With the up-to-date firmware the function generator now gets a period that is within space (they allow 596 ppm, and this is about 500ppm off).

With the up-to-date firmware the function generator now gets a period that is within space (they allow 596 ppm, and this is about 500ppm off).

4 Comments »

  1. While I had the Leonardo set up for use as an AVR in-system programmer, I updated the main firmware on the ATMega168P chip as well, to version 113-08501-132. There wasn’t much to that update—but the new function of doing a factory-default reset of the parameters by pressing the ADJ knob during boot-up seems to work.

    Comment by gasstationwithoutpumps — 2015 July 16 @ 22:01 | Reply

  2. […] The BitScope is capable of seeing the glitches in the waveform at lower frequencies, like 2kHz, but only barely. The nonlinearities are much better viewed with the PteroDAQ running at lower frequencies. […]

    Pingback by Measuring BitScope BS-10 input impedance | Gas station without pumps — 2015 July 20 @ 07:46 | Reply

  3. […] a couple of cheap function generators: the Elenco FG-500 and the JYEtech FG085 (also here and here). But I can’t remember whether I’ve reviewed the use of the function generator that is […]

    Pingback by Bitscope function generator review | Gas station without pumps — 2015 August 17 @ 23:11 | Reply

  4. […] The FG085 uses a 24-bit phase oscillator with a 2.5MHz clock (except for frequencies below 40Hz, where it uses a 10kHz clock), so the worst case rounding should be for 3kHz, with a phase increment of 20133 instead of 20132.659, making the frequency 17ppm too high.  If they truncated instead of rounding, then the frequency would be 32.7ppm low.  At 30kHz, truncation error would be only 3ppm, though, so this does not explain the consistently high errors.  I think that bad crystals are the simplest explanation—it is certainly consistent with the super-cheap (and bad) design of their DAC (see FG085 function generator bugs). […]

    Pingback by Calibrating PteroDAQ frequency measurements | Gas station without pumps — 2015 September 2 @ 22:35 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.