0
\$\begingroup\$

I'm designing an amplifier to read currents using a CT from 10 mA to 30A with a STM32 with no FPU. I have the following data:

  1. CT turns ratio = 1000:1
  2. Burden resistor = 10 ohms
  3. ADC reference = 3.3 V
  4. DC shift = 1.65V (2048 adc count)
  5. Amplifier gain from 10 mA to 10A = 8
  6. Amplifier gain from >10A to 30A = 2

Let's say I want to read 10 mA:

  • Secondary current = 10 mA/1000 = 10 uA
  • Vburden = 10 uA * 10 = 100 uV
  • Vpeak = 100uV * 1.41 = 141.42 uV
  • Vadc_in (amplified) = Vpeak * 8 = 141.42 uV * 8 = 1.13 mV
  • Vshifted = 1.13 mV + 1.65V = 1.65113V
  • Adc_count = (Vshifted*4095)/3.3 = 2048.90 = 2049

I can also say:

  • Vadc_in(pk-kp) = 1.13 mV * 2 = 2.26 mV (peak to peak)
  • Adc_span = (2.26 mV * 4095)/3.3 = 2.8 ~ 3

So if I have 3 counts for a 10 mA primary current,

  • 1 count = 3.33 mA
  • OR 3.33 mA/ADC count

Now, let's say I want to read 15 mA

  • Secondary current = 15 mA/1000 = 15 uA
  • Vburden = 15 uA * 10 = 150 uV
  • Vpeak = 150uV * 1.41 = 211.5 uV
  • Vadc_in (amplified) = Vpeak * 8 = 211.5 uV * 8 = 1.692 mV
  • Vshifted = 1.692 mV + 1.65V = 1.651692V
  • Adc_count = (Vshifted*4095)/3.3 = 2049.6

Doing the same calculation for 10 A, I get 2.78V peak at the ADC input, and 2749 count.

Is this approach right? Could I do RMS calculation in the micro with this method considering the micro doesn't have FPU? Also, look at the case of 10 mA and 15 mA, the ADC count is almost identical, i.e., 2049. If I do the DC shift subtraction by software, that is, 2049-2048 = 1. There would be a lack of precision I think. I would get the same values for 10 mA and 15 mA. Please, correct me where I'm wrong.

\$\endgroup\$
  • \$\begingroup\$ Is the signal frequency known? (say, 50 Hz). What is the ADC sample rate? (say, 1 kHz). DC accuracy will be a problem, so process the samples to eliminate it. For example measure both positive and negative peaks, knowing they are 10 ms apart for 50Hz, to eliminate the DC component..What accuracy do you need at low currents? You may need a higher gain than 8... \$\endgroup\$ – Brian Drummond Apr 16 at 21:46
  • \$\begingroup\$ "Could I do RMS calculation in the micro with this method considering the micro doesn't have FPU?" - what sort of 'rms' do you want to do - true rms, or just the rms equivalent of a sine wave peak? \$\endgroup\$ – Bruce Abbott Apr 16 at 21:50
  • \$\begingroup\$ Frequency is 50/60Hz. Sample rate is still to be determined. The accuracy of my CT is about +/- 1.5 mA. I don't need much precision, so that's why I was thinking of sensing the peak. Since the CT give pure sine wave I may no need to do true RMS. \$\endgroup\$ – Blue_Electronx Apr 16 at 22:05
  • \$\begingroup\$ The application is to measure earth fault currents. \$\endgroup\$ – Blue_Electronx Apr 16 at 22:15
1
\$\begingroup\$

Your C.T. reliably provides an average voltage of zero. That's good.
Your offsetting resistors, amplifier and ADC all add offset and other non-linearity. That's bad

You can likely improve precision by cranking up the ADC sanpling rate. Ideally, sample rate would be some integer multiple of line frequency (60 Hz? 50 Hz?).

Take @BrianDrummond example: 50 Hz input sinewave, sample rate 1000 samples-per-second. At ten-sample intervals, you can get peak-to-peak values, but you do not know phase. At 5-sample intervals, phase shifts by 90 degrees...

  • Save the 15 most-recent samples in a buffer.
  • subtract: most-recent minus 10th-most-recent = A
  • subtract: 5th-most-recent minus 15th-most recent = B
  • calculate p-p: \$ peak-to-peak = \sqrt{A^2 + B^2}\$

This method automatically takes care of offsets. If you are concerned about the math overhead (having no FPU) use the CORDIC algorithm, which uses only add, subtract, and arithmetic shifts...it does the nasty \$ \sqrt{A^2+B^2}\$ fairly quickly using integer math. Be aware that CORDIC method has gain: it will scale-up the peak-to-peak values by about 1.6
If you save the result of these calculations, you can improve resolution by averaging many p-p values.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.