Author Topic: ATmega328 measure ac current and voltage  (Read 2704 times)

0 Members and 1 Guest are viewing this topic.

Offline anishkgtTopic starter

  • Frequent Contributor
  • **
  • Posts: 769
  • Country: qa
    • George Hobby
ATmega328 measure ac current and voltage
« on: September 16, 2017, 06:58:37 pm »
Hi All,

I've been searching around the internet to see if there would be any way to measure ac voltage and current with an ardouino. My load is a MOT (Microwave oven Transformer), secondary rewound with a 2AWG wire for spot welding 18650 cells.

At the moment the MCU senses the peak of a sine wave and triggers the SCR to switch on the MOT at the peak of every sine wave. All works well but i wish to know there is any possibility to measure the Amps and voltage put out at the secondary with the MCU. I could use a bridge and a filter cap and then read but how accurate would it be ? Down the path from the ac to the dc conversion there would be some voltage drop. The MOT would on max for 1Second and least would for 20ms. If the max time is too high could go down to 500ms also.

Thanks in advance

 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14203
  • Country: de
Re: ATmega328 measure ac current and voltage
« Reply #1 on: September 16, 2017, 08:29:52 pm »
It works surprisingly good to use the ADC to sample the AC voltage and to RMS calculation in software. It needs some computational time, but not that much. Something like 1-4 MHz of clock frequency. Like with other AC-DC conversions it does not work as good with low amplitude (e.g. less than 5% of full scale) - so it would be a good idea to have an adjustable gain if the range is large. The µC internal ADC is fast enough to capture frequencies up to about 5 kHz, usually sufficient for line frequency.

For the short pulses, I would still sample the waveform and not use a separate AC to DC conversion.
With AC voltages it is easy to do amplification, as there are less offset problem. Thus the voltage drop on shunts can be smaller than with DC.
 

Offline anishkgtTopic starter

  • Frequent Contributor
  • **
  • Posts: 769
  • Country: qa
    • George Hobby
Re: ATmega328 measure ac current and voltage
« Reply #2 on: September 16, 2017, 08:43:26 pm »
Thank you kleinstein !

I am just starting with MCU and electronics and this is my second version of the project.

So from what you've suggested I understand that sending the bare ac signal would be ok ? I heard that negative voltage would damage the arduino, is it the arduino board itself , the other components or the only atmega IC or was false assumption

Adjustable gain would be an opamp with a negative feedback if am not wrong. (Again learning about them as well)


Www.Georgehobby.wordpress.com

Equipments: DSO104z, Hakko FX888D
 

Offline anishkgtTopic starter

  • Frequent Contributor
  • **
  • Posts: 769
  • Country: qa
    • George Hobby
Re: ATmega328 measure ac current and voltage
« Reply #3 on: September 16, 2017, 08:51:02 pm »
my load voltage on open circuit is about 2vac aprox but for 20ms its about .29vac and amps is 3,186 which i had discussed here https://www.eevblog.com/forum/projects/measuring-3vac-amps-and-resistance/#9
 

Offline Assafl

  • Frequent Contributor
  • **
  • Posts: 600
Re: ATmega328 measure ac current and voltage
« Reply #4 on: September 16, 2017, 09:04:52 pm »
Example code (and pretty easy to use): http://forum.arduino.cc/index.php?topic=179541.15

If your signal is around 0v you can rectify it, shift it up approximately 2.5v (as in the above example) so it fits within the 5V input to the Arduino, or, if the signal is symmetric, fake the bottom half (x2). Since the input is protected by a diode, you can use a resistor between the source an the Atmel and do fine.

 
« Last Edit: September 16, 2017, 09:10:53 pm by Assafl »
 

Offline anishkgtTopic starter

  • Frequent Contributor
  • **
  • Posts: 769
  • Country: qa
    • George Hobby
Re: ATmega328 measure ac current and voltage
« Reply #5 on: September 16, 2017, 09:13:48 pm »
Thank you assafl.

I did come across that but wasn't sure how the wiring would go. Would you be having a schematic of it.


Www.Georgehobby.wordpress.com

Equipments: DSO104z, Hakko FX888D
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14203
  • Country: de
Re: ATmega328 measure ac current and voltage
« Reply #6 on: September 16, 2017, 09:18:05 pm »
The AVRs can directly only measure positive voltages. However one can shift the DC level. The simple way is using an capacitor for so called AC coupling towards a divider that provides a DC level about mid way of the ADC range. There are alternative methods too, that can be better suited for pulse currents, that might contain an DC component.

One can protect an input from to high or to low a voltage.

For the voltage, AC coupling and maybe a little division to reduce the voltage a little (2 V RMS is about 5.6 V from peak to peak and thus a little too much for a 5 V Voltage range of the ADC.

For the current reading from a shunt (e.g. voltage drop), one would need amplification. This amplification could provide the right DC level. One might need AC coupling to counteract DC offsets of the amplifier anyway.

Current measurement with a current transformer would be even easier, as the output voltage can be chosen and is isolated. So the DC level is easy to choose from the other side.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf