Dick Cappels' project pages http://www.projects.cappels.org
Return to HOME (more projects)
Voltage Recorder With Playback
The recorder includes the functionality of a data logger but also plays back recorded voltages and can perform a curve trace function.A simple file system provides for up to 128 different sequential files totaling up to 130,000 samples. At 1 sample per minute, that's 90 days of continuous recording.
Figure 1. The buttons on the front panel control all necessary data gathering functions while the quick-connect speaker connectors on the rear panel are used for analog and digital input and output, and that of an undedicated differential amplifier. When this photograph was taken, the button monitor controller was raised above the main board on a Lazy ISP Adaptor to allow programming and debugging.
Download the AVRStudio 4 assembly source and hex files for the data recording controller and the button monitor chip: VOLTAGE_RECORDER_FIRMWARE_dr130101A_vr121222A.zip
The voltage recorder is able to record one or two analog channels or positive analog voltage along with a one bit digital channel, sampled at 1 set of samples per second or 1 set of samples per minute. The analog channels are scaled from 0 to 2.5 volts in 250 even steps. The digital input is connected to the base of grounded emitter NPN transistor inverter with a threshold of about 0.5 volts.
The recorder can operate from batteries or from 12 to 18 volts applied to the power input connector.
When powered though the power input connector, power is applied to a dual opamp, one opamp is connected as an undedicated unity gain differential amplifier and the other opamp is used to buffer the output of a Digital-to-Analog converter (DAC). When the DAC is powered, the voltage sampled on analog channel A is output via the DAC which is calibrated so that the output voltage is equal to the input voltage, and when the contents of the memory are dumped, channel A samples are sent though the DAC either at 1 sample per second or more quickly at about 20 samples per second.
A curve trace function causes the DAC output to step through the range of 0 volts through 2.50 volts in 251 steps while recording the three input channels, after allowing somesettling time for the DAC. There are two sample rates for the curve trace function; 1 step per second or approximately 20 steps per second, depending upon the selected playback rate.
A simple filing system can accommodate up to 256 files totaling 128 K Bytes. The files may be dumped one at a time or all at once; file headers provide the file number and the conditions of the recording, such as recording speed, whether recording was done under battery power.
Figure 2. Two microcontrollers are used. One takes measurements, stores them in EEPROM, drives the DAC, and communicates with a serial terminal. The second controller merely serves to monitor front panel buttons and send button status to the first controller through the serial port.
On the schematic in figure 2, of the circuit of the board,
Going from left to right on the schematic of the circuit board, shown above in Figure 2, the circuit includes a power supply section, a microcontroller (ATMEGA48V) dedicated to monitoring the front panel buttons, an interface for the serial port, adjustable voltage dividers for the two analog channels, a digital buffer to buffer and amplify the single bit digital input, a 128 kByte EEPROM with a Two Wire (I2C) interface, a micrcontroller (ATMEGA48V) to communicate with the serial terminal, receive data from the button monitor and operate the data gathering and storing circuits, and an adjustable R-2R DAC with an op amp buffer.
Notice that the microcontrolers and the EEPROM are low voltage versions so that the entire circuit will operate down to 1.8 volts. You can use other versions, but operation from low battery voltages is not assured.
Also on the board is a undedicated unity gain differential amplifier, the inputs and output of which are all available on the rear connector panel to make it easy to make differential measurements.
If I were to start this over I probably would have have chosen a controller with more I/O and take care of all of the microcontroller-based tasks with one chip, but half the fun is finding a way to work with what I can obtain in my corner of a developing country. The reason the keyboard monitor controller is the over-qualified ATMEGA48V is used is because it is the only microcontroller that I could obtain that will work down to 1.8 volts.
The BC546 can be used to inject a below-ground sync pulse into the DAC output for the purpose of signaling the start of a sequence and is not used by the current version of the firmware. Therefore, the entire circuit, including the 0.33 uf capacitor, the 39k and 10k resistors, the 1N916 and the BC546 can be safely omitted.
The resistors in the differential amplifier, the R-2R ladder network and the input voltage attenuators are 1%, 50 ppm/°C metal film resistors for both accuracy and stability.
Figure 3. The power supply section switches between the voltage from +5 volts, which is derived from the +12 to +18 volt input,and the battery, and provides -2.7 volts for the dual op amp when the +12V to 18 volt supply is present.
Looking at figure 4 above, when voltage from the 12 to 18 volt input is present, 2.7 volts is dropped across a set of four 1N4007 diodes. This voltage drop is used as a negative power supply for the dual opamp to enable the circuit to work with voltages near or, in the case of the differential amplifier even below ground. The reason this method was chosen over using a rail-to-rail opamp is that I could not find a rail-to-rail amplifier that would work satisfactorily in this application.
After subtracting 2.7 volts of drop for the negative power supply the remaining voltage is applied to the 7805 voltage regulator. If the 7805 requires a minimum of 7.0 volts in order to maintain line regulation, then the minimum input voltage through the 12 to 18 volt input to assure proper operation is 9.7 volts.
It is important to note that because of the way -2.7 volt power source is developed, that the 12 to 18 volt power source must be isolated from ground, otherwise the opamp circuits will not be able to operate at voltages close to ground.
The positive battery voltage is applied to the anode of a Schottky 1N5822 rectifier as is the output of the 5 volt regulator. The cathodes of the two diodes are connected together in an OR configuration so that higher of the two voltages will provide power to the circuit. This means that when there is sufficient voltage through the 12 to 18 volt input, the battery is disconnected from the circuit.
Many design options were considered for switching between the two power sources, and in the end, the use of a pair Schottky diodes proved the most elegant solution; the minimal power savings to be had by using active circuitry with a lower drop did not seem worth the extra parts count and board space.
An on-board LED indicates when the 12 to 18 volt source is connected and is there for diagnostic use during board-level development and debugging and can be safely omitted.
When operating from battery power, the power supply only provides power to the two microcontrollers, the EEPROM and the single bit digital buffer circuit. Under battery opeartion the output of the DAC is to zero to minimize power drain. When operating from the 12 to 18 volt power source, power is also applied to the dual op-amp, which means that the undedicated differential amplifier and the DAC output are only available when the instrument is powered through the 12 to 18 volt input.
The functions associated with the opamps that are not available under battery power are playback of channel A, curve tracing, and the use of the non-dedicated differential amplifier.
The Input Attenuators
Both analog inputs are attenuated with adjustable attenuators to bring the full scale 2.50 volt input down to the 1.1 volts ± 0.1 volt bandgap reference in the microcontroller. The input resistance is greater than 1.2 Meg Ohms.
The D-to-A Converter
The D-to-A converter is a simple R-2R ladder network driven directly from the microcontroller's output pins. The ATMEGA48 is not a good candidate for driving the DAC because it does not provide an 8 bit output port, which meant that the DAC is driven by 6 bits from port B and two bits from port C. This is less than optimum because this requires a lot of bit manipulation and two write operations to write to the ladder network. Updating the ladder network in two writes instead of one results in glitches when when changing.
The 10k pot in series with the 6.81k resistor is used to adjust the total resistance of the ladder network so the output can be calibrated. This circuit uses VDD of the microcontroller as the voltage reference.
This is a good place to mention that the datasheet of the TL062C allows up to 15 millivolts (1 1/2 counts) of offset. You can try the C version and see if you are lucky; its easy enough to change opamps if a socket is used. Otherwise, use the TL062 AC to get less than a 6 millivolt offset. There are better opamps available, the only things that recommended the TLO62 were its accuracy and availability. Of course, opamps are made with better specifications.
The discrete transistor serial interface uses very low power. When the serial interface is not active, the circuit's power dissipation is immeasurable. Note that there is no pull-up resistor on the 2N4401. That is because the pull-up resistor on the microcontroller input pin is used instead. It may be possible to reduce power further by using a discrete resistor instead of the controller's internal pullup resistor because less pullup current is actually needed at the low speed of 9600 baud.
Figure 4. The serial port uses discrete transistors to achieve practically no power unless sending characters, and even then, it only dissipates microwatts. A 2N2222 is used to OR the serial data from the button monitor with serial data from the RS-232 line. The transmit data from the Data Recorder Controller is also fed to a ceramic transducer to produce sounds such as key clicks and data being sent via the serial port.
The CMOS level serial data output of the data recorder chip is applied to a piezoelectric transducer through a resistor and a capacitor. The rattling buzz that is heard during transmission provides feedback to the operator during operation without a serial terminal to indicate when button contacts are closed, the menu being sent, and data being sent, whether a terminal is connected or not, after some experience I found the sounds to be very helpful feedback. A slide switch on the front panel disables the transducer.
I had considered using a low voltage CMOS shift register to collect the button status, but using a microcontroller that sends the same ASCII codes as the serial terminal makes it unnecessary to write the shift register routines or modify the command interpreter from what had been developed for use with the serial terminal.
Figure 5. The common base 2N2222 acts as a very low forward-drop diode to Collector-OR the serial output from this microcontroller with the output of the RS-232 receiver's collector signal.
The dedicated button monitor microcontroller shown in figure 5 monitors the status of buttons on the front panel and sends single ASCII character to the voltage recorder controller when a button is closed. With its large base resistor, the 2N2222 acts like a very low forward drop diode so its collector can pull the serial input of the voltage recorder's serial input low when sending a character.
At boot-up the microcontroller is clocked by the internal 8 MHz on-chip RC clock. After I/O initialization, the the tap on the clock prescaler is changed to provide a 4 MHz clock frequency. The asynchronous 32768 Hz crystal oscillator and its associated counter is used to provide a time base which is used to adjust the calibration of the 4 MHz clock. The calibration is necessary to assure reliable asynchronous serial transmission to the other microcontroller. From testing, this algorithm has provided better than 1% error in frequency accuracy. This same approach is also used for the data recorder microcontroller's clock.
After calibration of the 4 MHz clock, the controller shifts multiplexer to 128 kHz operation to save power, the pin change interrupts are enabled and then the controller goes to sleep until a button is pressed. When interrupted by a button closure, the tap on the clock prescaler is set to 4 Mhz so that an ASCII command corresponding to the closed button can be sent to the other microcontroller. The button array state is debounced and decoded and then the corresponding ASCII command is sent. After the character is sent the controller sets its clock rate back to 128 kHz and goes back to sleep until another button change interrupt. All of this switching around of clock frequencies and sleeping and waking is entirely to minimize current consumption during battery operation.
Single Bit Digital Input Buffer
Figure 6. The threshold is one base-emitter drop above ground
and is practically independent of V+ voltage.
The noninverting buffer shown in Figure 6 requires that the source of the digital input sink only nanoamps and to source only a few microamp. The input has a threshold of one base-emitter drop. The 2SC2878 is a high gain transistor with a low emitter to base resistance. The sensitivity is such that current leakage between the digital input wire and analog input wires in the instrument's internal cable harness can be sufficient to make an open input register "high" on the input to the microcontroller when the analog input voltage is sufficiently high. If this is not desired, the input can be grounded or connected to ground through a 100k ohm resistor from the input to ground.
If selecting a substitute for the 2SC2878, check to make sure that the collector cut-off current of is lower than 500 nanoamps.
Undedicated Differential Amplifer
Figure 7. An undedicated differential amplifier may be used to condition either input or output signals when power is applied to the power input connector.
When power is applied to the external power input, an un-commited differential amplifier is available to condition either an input or the output. The common mode input range depends on the voltage applied to the external power input. The amplifier can also be used to shift the output of the DAC to an arbitrary DC level.
The common mode input range is determined by the volts applied to the external power connector. With 12 volts applied, I expect the common mode range to be from ground to + 13 volts.
The physical Assembly