DCC is a nasty waveform to get an accurate current or voltage reading on. Tony's has a pretty good product on the market for measuring DCC, but you know me - I've always got to tinker with building my own. The core of this will actually be used for a layout where we need to monitor 30+ different subcircuits (yes, it's a huge layout), so the objective here was low cost, low part count. I don't guarantee awesome accuracy, but it should be within 5-8% without any user calibration and should be less than $14 in parts to build.
This meter circuit does *not* do true RMS (root-mean-square) measurements. It's an average voltage/current meter. See this for why I think RMS is overkill for model railroader use.
The circuit is powered off DCC, and displays:
- Average voltage
- Average current
- DCC data integrity (The upper right corner of the display will show 'CC' for valid DCC signal, 'AC' for some other AC waveform, or 'DC' for DC power.)
- All measurements are updated 4 times per second.
How This Mess Works
Each signal filtering chain consists of three stages - a gain section, a precision rectifier, and a low-pass filter.
- The first op amp in each chain amplifies or buffers the input, providing a solid low-impedence source for the the precision rectifier circuit. At this stage, the signal should have a maximum of 2.5Vpeak corresponding to either 10A or 25V on the DCC lines.
- The second two amps comprise a pretty typical precision rectifier circuit. These create an output signal that's the absolute value of the input waveform.
- The final amp in each stage is part of a low-pass filter, averaging out the waveform before the ADC in the micro samples it.
- The resistors in most of the analog section section (the second and third amps in each signal chain) absolutely must be 1% or better to assure decent accuracy.
- Due to the need for negative supplies for the analog stages, the circuit only works on AC waveforms like DCC. Straight DC will power up the micro and LCD, but its measurements likely won't make any sense.
- You can substitute the op amp, but you need one with very good slew rates (>10V/us) for the precision rectifiers and decent gain-bandwidth (say a few MHz) and low offset (<=3mV) for the input current amp stages. Also, it needs to have an input common mode and output range from -3V to +3V given +/- 5V rails. The MC33074 is a good compromise, and is dirt cheap.
- You can substitute other signal diodes, but they should have fairly fast reverse recovery (<6ns). Regular 1N400x power diodes won't work - they're too slow.
- Be sure to provide bypassing caps on the op amps. These aren't explicitly called out in the circuit, and are left to the implementer.
- As with most of my code here, this is free software licensed under the GPL v2.
- Included in here is an AVR version of the DCC decoder engine used in the DCC To Serial project, where it originally ran on a PIC. It's modularized and can (and probably will) be reused in other DCC-related projects.
- Until I get around to writing my own, this uses Peter Fleury's excellent 44780 LCD library for the AVR. Thanks Peter!
Analog Schematic - v1.1
Digital Schematic - v1.1
Source Code and Binary - v1.0