Hello everyone, I am trying to measure ac current provided an AC voltage of 400mV at 100hz with an offset of 600 mV to make sure the signal never goes below ground. this is the circuit I am implementing. I can measure Vh clearly with arduino but Vl is only 50 Hz noise.
int signalPin1 = A0; // Pin where the first signal is connected
int signalPin2 = A1; // Pin where the second signal is connected
void setup() {
Serial.begin(9600);
}
void loop() {
int readValue1 = analogRead(signalPin1);
int readValue2 = analogRead(signalPin2);
float voltage1 = readValue1 * (5.0 / 1023.0) * 1000; // Convert ADC value to mV
float voltage2 = readValue2 * (5.0 / 1023.0) * 1000; // Convert ADC value to mV
float drop = voltage1 - voltage2; // Voltage drop in mV
// Calculate current assuming the shunt resistor is 10 ohms
float current = drop / 10.0; // Current in mA
// Print current value for Serial Plotter
Serial.println(voltage2);
delay(10); // Sampling interval, adjust as needed (100 samples per second)
}
@bene64, you did forget to mention that you did lift the signal. It's important for those that try to help else the first reply will be that you can not measure AC as you do.
You should have added that in your schematic ! As well as other details that became clear in your other topic. It would have saved @rsmls the time to ask the questions.
I'm asking because the photos don't clarify all that much, I'ma fraid. I do recognize that you're the same person struggling with the soldering and the probably destroyed sensor in another thread.
Do you have the GND connection of the coil circuit connected to the Arduino GND in any place?
Vl is the voltage across the coil, it may well be 50Hz noise but as I said it will also appear on Vh. So the voltage across the resistor will be Vh-Vl and the noise will cancel out.
You should if you intend to do the measurement as you indicated in the revised schematic. The Arduino needs to have the same ground reference as the measured circuit. You may in fact damage the Arduino if you fail to connect the GNDs together.
I am providing the following voltage +-400mV with an offset of 500mV to have all the range positive
with the probe in the location showed by the schematics i read this signal
+-100mV with an offset of 280mV.
there is a huge difference even if i should be measuring the imput signal
And with aduino i am reading a singal +- 90 with an offset of 230mV
Looks fairly close. I agree it's off a bit, but your dodgy wiring/soldering probably accounts for part of that.
The main thing you're probably running into now is that you're likely feeding the signal generator into an impedance that's lower than what it's designed for, resulting in a lower output than anticipated. If you disconnect the signal generator from your circuit and measure it directly with your scope, is the output correct?
If you're measuring a 100Hz signal, you'll have to sample at at least twice that frequency. I'd sample much more often in fact because you likely have all manner of noise that will throw you a curve ball.
Having said that, the problem with your A1 pin is likely that it's not really connected to anything. The oscillating readings suggest a floating input. Could be one of the dodgy connections in your circuit.
PS: why did you delete the waveform generator settings from the thread as well as the earlier scope photograph? It doesn't really help if you start removing critical information left and right. I was about to look into the waveform as sampled on your scope, but you removed it. Could you please put it back in?