Voltage measurement up to 60 VDC shows voltage spikes

I have the following function

void voltage_battery()
{
   float R1 = 11000.0; //  
   float R2 = 1000.0; // 
   const float V_offset = -0.35;
   int val = analogRead(V_BPin); // voltage from battery (max. 60 VDC)is connected to voltage devider with 1k + 11k 0.6 W Resistors
   delay(20);
   V_Bat = ((val*5.0)/1024.0*(R1+R2)/R2)-V_offset;
   Serial.print("V_bat = ");
   Serial.println(val);
   String V_BatTXT= String(V_Bat,1); //Will show 1 decimal place
   memset(buffer, 0, sizeof(buffer));
   V_BatTXT.toCharArray(buffer,10);
    if (strcmp(buffer, buffer_voltage)) //compares buffer with previous set buffer_voltage. If it differs buffer_voltage will be updated
     {
       t4.setText(buffer);
       strcpy(buffer_voltage, buffer);
     }
}

If I apply a voltage at the Analogue input it displays the correct voltage. However, sometimes I observe voltage spikes which are larger than the real voltage. Now I am not sure about the reason for this.
I think the delay after analogRead is long enough. The circuit is a simple voltage devider. Maybe the resistor values were not chosen properly.

Hi,
Are you reading any other analog inputs?
Do you have 0.1uF cap from analog input to gnd?
How have you got your gnds connected to the 60V source?
What model Arduino are you using?

Does the val values jump? That is the raw analog input values.

Thanks.. Tom.. :slight_smile:

Are you reading any other analog inputs?
YES

Do you have 0.1uF cap from analog input to gnd?
No, should this be the case at every analog input?
Is it used for stabilizing the input?

How have you got your gnds connected to the 60V source?
As common gnds. Both together. The battery is used for powering the Arduino via DC DC converter.
Should it be decoupled?

What model Arduino are you using?
It is the MEGA 2560

I forgot to mention that I use a Zener diode ZD5.1 together with a 10k resistor as overvoltage protection. the resistor is switched in series with the diode and connected to GND. The diode is connected with the analog input. Maybe this causes the fluctuation.

Hi,
Yes a 0.1uF on each analog input will help suppress any noise or spikes that may be induced into the input circuit.

The zener should not cause a high voltage spike.

Does the val values jump? That is the raw analog input values.

Tom... :slight_smile:

Yes the raw value jumps up and down

Perhaps the voltage spikes are real.

Is the voltage source connected to motors, servos, relays or other coils?

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a picture of your project?

Thanks.. Tom... :slight_smile:

Measured voltage depends on two things.

  1. Voltage on the analogue input (100n cap to ground makes that voltage more 'solid' for the A/D to sample from).
  2. The reference voltage (the ruler that measures it).

If the reference voltage (5volt) dips, then readout goes up.
Common on e.g. USB supply, or when other loads (relays) are switched on/off.
A solution could be to use the more stable buildin 1.1volt Aref (or 2.56volt Aref for a Mega).
But that depends on the rest of the code (which you didn't post).

Protection zeners and diodes should not be needed.
They don't work when the Arduino happens to be off,
and they could introduce temp/voltage related errors.
Leo..