This topic is a description of how I record battery current and voltage and other information while driving my Toyota Prius. There are numerous things I'd like to learn by doing this, for example:
Of course, none of this information is necessary to own, drive or enjoy a Prius. However, enquiring minds want to know and why my mind wants to go to this extreme is for discussion between me and my mental health specialist (that is, my cat). You might find this topic interesting, entertaining or just pathetic, but I do have a life so don't worry on that count.
The first step in acquiring electrical data is usually to make sure a data acquisition system of some kind is to hand. This is a box of electronics that takes samples of electrical signals, analog and/or digital, at a regular rate and records them somehow for future examination. At first, I thought I would have to spend a lot of time constructing and programming this thing for myself. Then I fired up the Google search engine and looked for something ready-made. I found LabJack. The LabJack U12 is a box smaller than a paperback novel that connects to your computer via a USB port. It has four differential analog inputs of 12-bit resolution (or eight single ended), two 10-bit analog outputs, 20 digital inputs or outputs and a counter. Although limited in many ways, for example in sample rate and the ability to use features in combination, it will serve my purpose and you just can't beat $100 for something like this. It comes with some great software and support is excellent. So, I bought a LabJack U12 and using this I will collect data and record it in my computer. On to the next problem.
The battery current signal, I have found, is far from smooth and steady. There are components in the signal at twelve times the spin rate of the large motor/generator, MG2 (these can be explained by the motor structure, but this is outside of the scope of this discussion). MG2's spin rate, in rotations per second, is nearly the same as the vehicle speed in miles per hour. So, at 50 m.p.h. when MG2 spins at 50 revs per second (3,000 r.p.m.) I expect a signal at 600 Hz on the battery current. Now, I could follow this if I sampled the signal at above 1,200 samples per second. However, if I collect samples that fast I will just fill up the computer more quickly and have more processing to do to find out what they mean. I want only tens of samples every second. For this to work, I have to get rid of the high frequency signals. If I don't, the samples I take could fall anywhere on these high frequency signals and could be far from the steady level underneath that I want to record. To remove the high-frequency signals, a low-pass filter is necessary. My circuit is shown at above right.
This is, for those to whom this will make sense, a second-order, Salen-and-Key active low-pass filter with Butterworth response (Q = 0.71) and a DC gain of one. For the values shown, the corner frequency is at about 10 Hz, but by changing the resistors I can get other corner frequencies (e.g. about 24 Hz for 100 kohm). At half the corner frequency, the input signal is barely disturbed. Signals at twice the corner frequency are reduced by a factor of four. At four times the corner frequency, signals are reduced by a factor of sixteen. My plan is to sample at least at four times the corner. So, for example, with 220 kohm resistors and a corner frequency of a little over 10 Hz, I will sample at 50 samples per second. Any high frequency signals that might then disturb or "alias to" the slow, smooth signal I'm looking for will be reduced in strength by a factor of 16 to 20. The operational amplifier is the "other half" of the TL082 that acts as the differential amplifer for the voltage hookup. A second TL082 serves to condition the signal from the built-in current sensor.
The Prius has a built-in sensor for the high-voltage battery current in the System Main Relay (SMR). I have a display of the battery current rigged up on the dash, so I have described elsewhere how to attach wires to this sensor and won't repeat it here.
To measure the voltage, it is merely necessary to connect to the battery terminals. Yeah, right. With 300 volts and a fraction of an ohm resistance, you can unleash a lot of damaging or even deadly energy if you get this wrong. My main concern in making a voltage-measuring connection to the battery was safety. I designed a simple circuit with resistors to prevent any dangerous voltages or currents from getting onto my wires. This is connected to the output of the SMR behind the rear seat as shown in the picture at right (click on it for a bigger one). The orange wires are the ones that run out of the bottom of the car and forward to the inverter/converter under the hood. My circuit picks off the voltage at each wire via high value resistors, which you can see clearly in the larger picture. I will develop the details below, so you'll probably want to refer back to this picture. The terminals are, of course, normally covered up and what you're looking at is with the cover removed. You can see my current sensor wire running down the picture from a hole into the trunk above the SMR and going behind the white plastic tube into which the orange wires pass. Both this and the voltage signal wire are tucked out of sight under the seat and then under the plastic sill trim and reappear under the driver's seat.
The high-voltage battery is not connected to the car chassis at either end (or anywhere else). I need to measure the difference in voltage between the two battery terminals, not the voltage of one terminal with respect to chassis. Although the LabJack data acquisition unit has differential inputs, for reasons explained below I need to pass the voltage signal through a low-pass filter before applying it to the LabJack. So, I need my own differential amplifier circuit to convert the battery terminal voltage difference to a "single-ended" signal with respect to the car chassis. The built-in current sensor outputs a voltage with respect to the car chassis. Therefore, my signal conditioning circuitry, the LabJack and the attached computer use the chassis connection as their "ground" potential. This is why the voltage signal must also be referenced to chassis.
After some thought about the safety and differential amplifier issues, I came up with the circuit at right. The four resistors to the left are primarily for safety and mount close to the battery terminals where they leave the SMR. A wire then runs where the squiggly lines are shown to the circuit at right. This takes the difference in voltage of the two sides of the battery and produces an output with respect to the circuit ground, which is the car chassis.
The 10 Mohm resistors prevent any dangerous current from getting out of the battery. If you grabbed their right-hand ends when the SMR was on, the current could be no greater than 0.015 milliamps. I'm pretty sure this is harmless. But, maybe you could feel it. So, the 220 kohm resistors are there to reduce the voltage in the wire to something you couldn't feel unless you licked it (and then barely). With the SMR on, the voltage between the wires going to the right-hand circuit can be no more than 6.6 volts. Wiring these resistors to the car chassis also limits the voltage of the wires with respect to the chassis. I can't say what the voltage will be because I don't know how the battery voltage will sit relative to chassis. It does seem reasonable to assume that neither end will be more than 300 or so volts away from the chassis so, again, the voltage on the wire can be no more than 6.6 volts. This is a safe input signal for the operational amplifier when powered from ±9 V.
The operational amplifier and two 100 kohm resistors turn the whole arrangement into a differential amplifier with a gain of 0.01. The output is one hundredth of the voltage difference between the battery terminals, now referenced to circuit ground (the car chassis). Interestingly, the 220 kohm resistors don't figure in calculating the gain of this circuit. Although I used resistors of 2% tolerance, I have calibrated the whole circuit by comparing the LabJack reading with a direct measurement of the battery voltage with a multimeter. The operational amplifier, by the way, is a TL082 from Radio Shack. You get two amplifers in a chip for a couple of bucks. I power it from a couple of 9V batteries which, so far, I've remembered to switch off after the experiment.
The picture at above right (click for a larger one) shows the "safety" circuit before assembly to the car at the SMR terminals. The 10 Mohms resistors are at the top, well insulated with heat-shrink tubing. The 220 kohm resistors stand vertically with the chassis connection at the bottom and the green wire leading down and right. The wire to the rest of the voltage sensor circuit is at the left. Its shield connects to chassis and two color coded conductors connect to the junctions of each pair of 10 Mohm and 220 kohm resistors. As I've done my best to explain, no voltages appear on this wire that you couldn't find on household batteries.
Having calibrated the built-in battery current sensor with my clamp-on current probe, it is free to use for something else. A fairly obvious canditate is to measure the current in one of the windings of MG2, the big "traction" motor/generator. Since this is alternating current (AC), I can't acquire it directly at the low sampling rates I want to use, so I have the challenge of converting it to a DC signal first. The frequency of the AC is, however, directly related to the spin rate of the MG and hence to the axles and ultimately vehicle speed. If I also acquire the frequency, I will have a record of vehicle speed along with everything else.
The circuit at right is an AC-coupled amplified followed by a precision full-wave rectifier. The input signal comes from my Amprobe CT600 clamp-on current probe which is clamped around one of the cables to MG2 under the hood of the car. The capacitor blocks any DC signal, which means I don't have to carefully adjust the probe for zero output at zero current. Signals down to around ten hertz are passed without much attenuation so I can use the circuit down to speeds of a few miles per hour. The potentiometer lets me adjust the bias voltage of the op-amp that forms the amplifier. I found that it is necessary to zero the DC output of this op-amp so that small AC signals are rectified properly and produce a clock to the counter, below. The amplifier gain is 11. This is an odd figure, but I can't get 2% tolerance resistors in values other than 10, 22, 47, etc. and I can compensate for any gain I like during calibration. The 680 pF capacitor reduces the gain to unity at high frequencies (starting at a corner frequency of just over 1000 Hz) and prevents false triggering of the counter due to interference. From the first 100 kohm resistor to the right is the precision full-wave rectifier. The output is the AC signal presented to the first 100 kohm resistor with the negative half cycled folded up to become positive. For this to work really well, the op-amps would have to be of a low input offset type or have their offsets trimmed. It is possible I've not chosen the best op-amp for the job with the TL082.
To measure the frequency of the MG2 winding current, I add the circuit at right to the above recision full-wave rectifier circuit. Its input is connected to point X in that circuit, at the output of the middle op-amp. The signal at that point is an AC signal but as it crosses zero volts it makes a jump to turn one diode off and the other on. These exagerated zero-crossings are obviously what attracted me to this signal as a source of the counter clock. Two transistors in an emitter-coupled arrangement both increase the magnitude of the signal and convert it from the analog supply voltage swing to a 0 to 5 volt digital signal. At logic zero, it does go a bit below zero volts as during saturation the second transistor collector drops below the base voltage. This does not seem to have any ill effect. The 220 kohm resistor provides a small amount of positive feedback to provide some immunity to noise on the analog input as it crosses the switching point. The LED helps with adjusting the DC offset that I mentioned earlier. With no input signal to the amplifier stage, I adjust the bias voltage until the emitter-coupled transistors are close to their switch-over point. In other words, I adjust one way until the LED comes on, go back until it turns off and then try to set the potentiometer midway between these two points.
None of the circuits shown have provision for calibration. This is because the software that comes with the LabJack can scale and shift data samples before storing them on the computer. I use this to convert my sensor signals to real-world currents and voltages in amperes and volts.
It took quite some effort to discover the built-in current sensor output in volts per amp (you're really interested?). The figure I ended up with was 0.027 volts per amp. Therefore, I simply instruct the LabJack software to divide the samples, in volts, by 0.027 and I have the current in amps. This does not account for any offset and I'm still working on that. I set the LabJack for a gain of 8 for this channel so its range was ±2.5 V. The maximum current I can read is thus 92.6 amps. Occasionally I see discharge currents that hit this limit for a fraction of a second but I don't find this a problem.
Calibrating the voltage signal was easier, assuming my multimeter is trustworthy. I connected the LabJack and took some samples with the car off and a wire shorting the SMR terminals (if the car had been on, I'd be typing with bandaged hands). The samples were around -0.0043 volts, so I tell the LabJack software to subtract this (add 0.0043 volts) to the samples. Then (removing the shorting wire) I turned the car on. Trying to take readings while the ICE was running and charging the battery was just too difficult so I waited until the ICE stopped. This proved to be a good idea for another reason, my multimeter read low when the ICE was on, probably due to the strong high-frequency signals. After the ICE stopped, the battery voltage fell very slowly and I recorded the voltage at the SMR terminals with the multimeter and noted the LabJack sample values. For example, the multimeter started to read 298 volts when the samples were 2.9567 and continued with this reading until 2.9467, when it dropped to 297. Taking the average, 2.9517 volt samples equal 298 volts at the battery, so I instructed the software to multiply by 101.0. Looked at another way, my voltage probe circuit was reading 1% low, which is within expectations for 2% resistors. To sample a signal at around 3 volts, I set the LabJack for a gain of 4 for this channel so its range was ±5 V.