ATmega328 measure ac current and voltage - Page 1
Forum section: electronics / general

author: anishkgt
author_rank: Frequent Contributor
timestamp: September 16, 2017, 06:58:37 pm
content: 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

author: Kleinstein
author_rank: Super Contributor
timestamp: September 16, 2017, 08:29:52 pm
content: 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: September 16, 2017, 08:43:26 pm
content: 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 assumptionAdjustable gain would be an opamp with a negative feedback if am not wrong. (Again learning about them as well)Www.Georgehobby.wordpress.comEquipments: DSO104z, Hakko FX888D

author: anishkgt
author_rank: Frequent Contributor
timestamp: September 16, 2017, 08:51:02 pm
content: 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 herehttps://www.eevblog.com/forum/projects/measuring-3vac-amps-and-resistance/#9

author: Assafl
author_rank: Frequent Contributor
timestamp: September 16, 2017, 09:04:52 pm
content: Example code (and pretty easy to use):http://forum.arduino.cc/index.php?topic=179541.15If 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: September 16, 2017, 09:13:48 pm
content: 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.comEquipments: DSO104z, Hakko FX888D

author: Kleinstein
author_rank: Super Contributor
timestamp: September 16, 2017, 09:18:05 pm
content: 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.