Jump to content

How to measure current "Amplitude" with Arduino?


Jaco De Jongh

Recommended Posts

Good day

I need to know when the current's wave in an AC circuit is negative or positive.  What kind of CT or device can I use that will give me negative Volts output for negative wave form and a positive volt reading for a positive wave form. 

Once I can find an instrument to do that, I can use an Op amp to do the rest?

Any advice?

Link to comment
Share on other sites

10 hours ago, Jaco de Jongh said:

Good day

I need to know when the current's wave in an AC circuit is negative or positive.  What kind of CT or device can I use that will give me negative Volts output for negative wave form and a positive volt reading for a positive wave form. 

Once I can find an instrument to do that, I can use an Op amp to do the rest?

Any advice?

Hi Jaco.
I would like to know if I understood. When you refer to negative AC, do you mean AC Export of a Hybrid Power Inverter to the Grid and AC Positive Import from the Grid?
If so, I can think of a solution.

Link to comment
Share on other sites

1 hour ago, Cef said:

AC Export of a Hybrid Power Inverter

That is the part I am interested in. With Arduino not being able to measure negative voltage, i was playing around with a couple of ideas. 

Made some progress tonight, figured out a way to show the Positive as well as the negative halves as positive. Now I can start with a little program to test my idea. 

This is the Amps. (Still have to see if I can smooth it out a bit)

Amps.thumb.PNG.de06c3b57afa4f69909b6473cece155a.PNG  

And the Volts

Vlolts.thumb.PNG.51031f6170d81886d69de011d9b6ec6e.PNG

Link to comment
Share on other sites

2 hours ago, DeepBass9 said:

What are you wanting to do?

I just need to detect reverse current fast. There is Energy meters on the market that has build in Reverse current detection , but at almost 7k before importing costs are added. 

I want to try and build a "very lightweight" unit to do that. Something that only looks at 2 conditions between 4 pins to indicate when current  is flowing in (Export) reverse, not in normal Alternating Current reverse. I hope to have a pretty high scan rate as there will effectively be 4 values to monitor and 4 comparisons to be made. The faster i can scan, the faster i can act on reverse current. 

 

Link to comment
Share on other sites

43 minutes ago, phil.g00 said:

Here's the specs, it would seem a CT is needed and the minimum trip time is a second. It does seem fairly sensitive though.

I think we looked at this before. The issue is that it trips at minimum 2% of 5A, so 50mA or just over 20W. That's without a CT (so limited to 5A max). If you add a CT to scale that up to 50A or so (make the math easy), now the smallest amount we can trip on is 200W. Not good enough in this application 🙂

The idea I had so far (and @Jaco de Jongh and I also discussed this offline), is to start with both a voltage signal and current signal.

For the current signal, you use that SCT013 with a 100 ohm burden resistor. That gets you roughly 2.5VAC for a 50A load, which is nicely within the capabilities of your average 5V microcontroller.

Now take both your voltage and current signals, and put them through precision rectifiers (op-amps that compensate for the 0.6V drop you normally get with a diode, because 0.6V correspond to about 12A with this CT/resistor combination!). This can be a half-wave rectifier, it doesn't matter, at least I don't think it does.

So now you got two little mole-hill signals that either align or not.

Put both signals into schmitt triggers, that changes them into square waves. Feed the two square waves into an AND-gate. The output will be a PWM signal.

When current and voltage is exactly in sync, the mark/space ratio will be 50%. As the phase shifts, the ratio will change. Some experimentation will be required, but I suspect that at a 25% ratio you're beginning to feed back.

If the current-rectifier is inverting (as it will be in the simplest implementation), just flip the logic around here.

This setup will not give you an accurate measure of how much power is going in any direction. The schmitt triggers lose that information. But if all you want to do is switch a relay when you exceed some minimum out-of-phase current value for long enough, it might work.

The problem is now reduced to measuring the ratio of the PWM signal. And I believe a capacitor of the right value will make a voltage out of a PWM signal, so now you can measure it with an ADC.

Disclaimer: Not an electronic engineer. Hobbyist.

Edited by plonkster
Link to comment
Share on other sites

Some  bi-directional energy meters provide two independent pulses stream import and export.

Some cheapies provide only import, but you can reverse the CT's.

They are very sensitive.

Then all the V/I phase comparison has already been done, and you're looking at a counter, No?

Edited by phil.g00
Link to comment
Share on other sites

42 minutes ago, phil.g00 said:

Some  bi-directional energy meters provide two independent pulses stream import and export.

Carlo Gavazzi meters have a pulse output. I wonder how fast they are. I know the internal modbus registers only update maybe every 500mS, and then you still have the overhead of reading them, which makes that process quite slow. Pulse outputs are 0.001kWh (aka 1Wh or joule) per pulse. That's insane. You make a very very good point here.

It seems (if I read the protocol documentation correctly) that you can't use the pulse output and serial comms at the same time. I was hoping you could somehow configure the pulse output to indicate reverse energy, then you could use the same meter that is already in many systems. But looks like that is a dead end.

Nevertheless... a very promising angle!

Edited by plonkster
Link to comment
Share on other sites

3 hours ago, plonkster said:

Carlo Gavazzi meters have a pulse output.

Right. So it turns out there are different models of meter. Some have modbus, some have something called M-bus, and some have a pulsed output. Can't have all the options in the same meter.

Looking at the leaflet of my EM24 meter (this meter is rather too expensive... though it is cheaper than the 7k mentioned earlier), you can configure the pulse output to pulse either for positive or negative energy. So a pulse-output EM24 would do the job.

I also see the EM110 meter is a single phase meter and it also has a pulse output. What I can't figure it is if you can configure the direction and if it distinguishes, but maybe it doesn't matter. That meter should be somewhere between R500 and R1000. Can't seem to find a place to buy it.

Then again, that at least shows that the possibility exist. Maybe find something cheap from Banggood? 🙂 I remember the single-phase Eastron meters were quite affordable... no idea if they can do pulses.

Edit: Yes, it looks like an EM110 will do it. It can sense "wrong current direction", so it is probably reasonable to assume it will not pulse for wrong-way current.

Edited by plonkster
Link to comment
Share on other sites

7 hours ago, Jaco de Jongh said:

I just need to detect reverse current fast. There is Energy meters on the market that has build in Reverse current detection , but at almost 7k before importing costs are added. 

I want to try and build a "very lightweight" unit to do that. Something that only looks at 2 conditions between 4 pins to indicate when current  is flowing in (Export) reverse, not in normal Alternating Current reverse. I hope to have a pretty high scan rate as there will effectively be 4 values to monitor and 4 comparisons to be made. The faster i can scan, the faster i can act on reverse current. 

Ok Jaco. You have read my post about the Energy measurements of the Grid Side and the Load side.
An Eastron SDM 230 Meter is cheap and quite accurate.
From the Tests I did, and as Plonkster said, you can read the changes between exported, 0, or imported energy using MODBUS in about 500 ms. with a very low CRC error count.
You do all the calculations you need and you can, if you need it, add and handle a solid state RELAY board with ARDUINO and make decisions according to the logic you program, adding about 200ms to 500 ms more by interacting with a connection RELAY by cable (not wirelessly).
Total, approximately in 1 (one) second..

Link to comment
Share on other sites

OK, maybe a pulse input is not the way to go, how about an optical input.

I have a 3ph meter on the bench at the moment. ( See pics of the meters at Iammeter.com )

It connects via wifi and registers in the app in Wh, which as you've stated is way too coarse.

The thing is I have 230A CT's with the meter and I only have a single phase supply where I am now.

The meter is powered off the phase voltage(s), so I hooked my 1ph house supply from a domestic plug to L3 & N.

(I used L3 and N because they were adjacent, I don't know if I could've used another phase to power up the meter).

There is nothing on the load output terminals, but the meter's wifi connection is running.

All I did was clip the 230A CT I around the phase voltage wire so the meter was measuring its own power draw.

It clocks up 1Wh every 6hrs, that gives you some indication of the meter's current draw.

Say 600J/h or  10J/s , however you want to slice it.

But that isn't my point.

My point is it has a "REV" led on it. If I reverse the CT it takes less than a second for that LED to light for the meter's own draw.

If you're just looking for an opamp input from a photo-sensitive device,  this must represent extreme sensitivity.

(There is no indication that this is the limit of its sensitivity, its just the smallest practical load I had to hand).

Incidentally, I am trialing the 3 ph meter which is listed as a rather coarse 800imp/kWh, the 1ph meter on offer is 3200imp/kWh. Which implies that the 1ph meter (which also has the REV LED) should be more sensitive.

PS: A quick look on the WWW and there are other (cheaper) meters that have a REV power LED as well.

 

 

 

Edited by phil.g00
Link to comment
Share on other sites

What you need to do is add a DC offset on your opamp so the entire waveform that the arduino sees on it's ADC is positive. Then in software you can measure the average and subtract it from each sample to get a waveform that is around 0. To detect negative power is not the same as negative current, since the current is AC. What you need to do is measure the voltage and the current and multiply them together at each sample (after removing the DC offset). The resultant power waveform will be negative when exporting and positive when importing power. You need to react on the average of one 50Hz cycle though because reactive loads can cause negative power for some parts of the cycle, although the average over one full cycle will still be positive.

Link to comment
Share on other sites

18 minutes ago, Stanley said:

What you need to do is measure the voltage and the current and multiply them together at each sample

Essentially integrating over U(t)*I(t) where t runs from 0 to 2*pi (or 360 degrees), but by doing it using samples you approach the actual value using "numerical integration".

That was the difference between analytical math and applied math in my training. In applied math we were allowed to hack it with samples 😛

 

Link to comment
Share on other sites

Since he wants to do it using an Arduino (the same would be true for any microcontroller) he will be using an ADC to sample the voltage and current waveforms at regular intervals and digitize them, so there is no choice but to use samples unless you want to go completely analog and do the multiplication in hardware. Using a high enough sample rate and a should give you decent accuracy (I guess a few kilo-samples per second should be fine for measuring 50Hz signals with a few harmonics). The ADC should also have a good enough resolution for what you want to measure. You can work out the theoretical resolution of you know the maximum current you need to measure and the no. of bits the ADC has. For example if you want to measure a maximum of 63A RMS (assuming you have a 63A main breaker) that will give you a peak current of 89A. Since you need to measure the positive and negative cycles, you need a peak to peak measurement of 178A. Assumin you scale this with opamps so that this 63A RMS signal covers the full range of the ADC then a 10 bit ADC will have a resolution of 178/1024 A = about 174mA. Although noise and other factors will make it a little worse in practice. Obvioulsy a better ADC will have better resolution, so a 12 bit ADC will have a resolution of about 44mA which is obiously much better if you need it to be sensitive.

Link to comment
Share on other sites

On 2019/09/24 at 6:51 AM, DeepBass9 said:

What are you wanting to do? I have been thinking along  those lines to make a servo or stepper assist to my generator throttle to keep the hz as close to 50 as possible under varying load.

I suspect that for a speed control you should measure the output frequency rather than the load and react to changes in frequency. You may struggle to get the control just right so it doesn't do strange things. You will probably need to implement PI control and play with the control gains quite a bit to get it stable.

Link to comment
Share on other sites

26 minutes ago, Stanley said:

The ADC should also have a good enough resolution

The one in the ATMega328 (used in the Arduino) is a 10-bit ADC. There is also only one ADC on the chip, it is shared/multiplexed between any pins you configure as an analog input. And it takes several cycles to read a value. It is however fast enough to get a fairly decent reading, but I don't know if it will go down low enough, because what is needed is to measure reverse current as low as 20W, or 80mA RMS, 120mA peak.

I don't think it is too much of a deal breaker. You actually don't care about the whole 80A range, so you can easily just clamp the signal at 5A (or whatever) and use your limited ADC on the smaller range.

The openenergymonitor project has some code for reading this stuff from an arduino. They do everything in code. The CT sits on a voltage divider, so it swings around a 2.5V centerpoint, and the ADC literally samples enough times to get an idea of the magnitude.

I used a smaller CT (25A) once with that code. It did not measure very well below 20W.

Link to comment
Share on other sites

1 minute ago, plonkster said:

I don't think it is too much of a deal breaker. You actually don't care about the whole 80A range, so you can easily just clamp the signal at 5A (or whatever) and use your limited ADC on the smaller range.

Yes, that would be the way to go if you are only interested in a small range around 0W, Just make the opamp gain high so that it 'clips' at a few amps. You won't be able to measure very much power but you will be very accurate at low power.

Link to comment
Share on other sites

You could even take this one step further and just make the voltage and current into square waves. Then you could measure their states with digital inputs. If you make a logic 1 a positive value and a logic 0 a negative value then just multiply 'samples' at regular intervals and average the result. If the result is negative then you have exported power, This should be incredibly sensitive and could even be done entirely in hardware.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...