High Side Current Measurement - Page 1
Forum section: electronics / projects

author: azeeman
author_rank: Regular Contributor
timestamp: September 05, 2025, 01:09:56 pm
content: Here's a high side current measurement circuit using an optical switch chopper and transformer for isolation. The output of the chopper is fed into an AC amplifier with its output biased at half the ADC reference voltage and the ADC is used as a synchronous AC detector. This makes the circuit simpler and because synchronous detection is used, all the goodness of a lock-in amplifier is available.The circuit is phase insensitive so its easy to add more AC gain if needed. In this circuit the AC gain is relatively low and a single op-amp stage was sufficient. The second op-amp in the package was used to buffer the reference voltage and divide it in half to bias the ADC input.The signal noise was horrendous because this circuit was used in a self powered elliptical generator which has a very wide output range with the output regulated by simple on-off triac control and a MOSFET switch for controlling current to a magnetic brake so there was lots of spikes and other noise.The main takeaways are that it shows how easy it is to implement a lock in amplifier, how to implement an isolated chopper and how good lock in amplifiers are at extracting a signal deep in noise.The optical switches used have slow turn on and turn off times and the code introduces delays to make sure that both switches aren't on at the same time.Because of the high noise, a lot of averaging was required, but this is simple to do at the ADC level. The ADC is only 10 bits so if a 32 bit integer can be used to sum multiple ADC readings and then the calculations done on the summed readings. The average doesn't have to be explicitly calculated, instead it can be incorporated in the current calibration.The average is the sum of multiple readings divided by the number of readings, or it can be considered a multiple of the readings with that multiple then multiplied by the calibration constant. This eliminates a division operation.A lookup table is used for the sine and cosine values. Note that cosine is sine shifted 90 degrees so by shifting the lookup pointer by 90 degrees, one table will work with both sine and cosine.An even more interesting use of the isolated chopper is to connect it to the input of a sound card. The left and right sides of one input channel are almost perfectly phase matched and ideal for use in a lock in amplifier. The correlation is done by multiplying and summing the two channels sample by sample. The switching frequency doesn't have to be precise and randomness is a bonus because the signal correlation is always perfect even with a random signal. On the other hand, randomness in the signal cause less correlation with noise and improves signal recovery.The sound card can detect very low level signals with decent resolution, but don't expect more than about 12 to 14 bits of resolution. In the circuit an Arduino Nano is used to drive the switches and the code is attached. This is handy because it's a cheap and nasty way to make an isolated digitizer. The sound card internal voltage reference is very stable which makes the measurements very repeatable as long as all controls are kept at 0 dB. Incidentally, all the sound card controls are implemented in software. The microphone boost amplifiers are done in software. It's best to just set all controls to 0dB and then calibrate the card.The secret to lock in amplifiers is that by multiplying a signal by itself, the product contains a DC voltage directly proportional to the correlation and an AC signal corresponding to the lack of correlation. Averaging the output acts like a low pass filter. Because the correlation is DC, it's very easy to average a huge number of samples and reduce the bandwidth to arbitrarily low values making it very easy to extract the signal.The Nyquist criteria still holds and any noise that is a close match to the signal can be shifted down to DC. This can be mitigated by using a more random signal to drive the choppers. This is easily done with an Arduino as source, but the more random the signal, the greater the bandwidth required to amplify that signal. This makes the design of the AC amplifier a lot harder because it has to have very low phase and frequency error over that bandwidth. In the example, the Arduino is used only to add break before make capability to the switches.