I'm helping someone build a static VAR compensator. We figure it'll be evident that the power factor is being corrected if there's a display that shows AC voltage and current waveforms, so one can see as they come into phase. For getting the mains voltage waveform on a TFT display, I used this circuit:
Only difference is I'm using a cheap 240V-12V transformer in place of the adapter. Also I'm using an LM358 in place of the LMV321.
The 'brain' is an Arduino Mega powered through a USB port, for now. The problem is each time I plug the transformer primary into mains, the Arduino resets but after that the waveform is displayed as expected, though it has some weird dips at the crest and trough. If I disconnect or something affects the plug's contact with the mains socket, the Mega resets again. And the thing is, it not only resets but I actually hear my PC make the tone of a disconnected USB device. At some point,
avrdude started acting up till I disconnected and reconnected the Mega.
Calculations and the TFT waveform show that the voltage at the analog input is within bounds. This seems like an issue of excessive current draw over USB but I'm not sure. I've also not gotten around to properly terminating the other op-amp in the LM358, if that's relevant to this issue. I would appreciate any suggestions as to the cause and a solution.