0
\$\begingroup\$

I am designing a solar charger controller for a solar panel to charge a 12v battery. I am using arduino uno for this project. Till now I am just checking the circuit on breadboard first. For testing purpose I have plugged in power supply in replace of a solar panel. This power supply has potentiometer so output voltage can vary from 10-14v. Now following is the circuit I am using :

enter image description here

For testing purpose I am giving input voltage and checking this at analog pin A0 of arduino. If it is greater than 12.0 volts then turn on a output PIN6. If the voltage is less than 11.0 volts, turn off PIN6. SO when PIN6 is ON, MOSFET will give 12v and I am giving this 12v to voltage divider circuit where I am measuring the voltage using A1 pin of the uno.

Following is the code

solarScale = analogRead(A0);  
batScale = analogRead(A1);
solPinVolt = solarScale * (4.279/1023.00);
solVolt = solPinVolt * (10 + 2.2)/2.2; 
batPinVolt = batScale * (4.279/1023.00);
batVolt = batPinVolt * (10 + 2.2)/2.2; 

if(solVolt >= 12.0)
{
  digitalWrite(6,HIGH);
}
if(solVolt <= 11.0)
{

  digitalWrite(6,LOW);
}

I am getting the exact voltage which I am applying. Problem occurs as soon as PIN6 is on. When voltage is above 12.0v, PIN6 is ON, so mosfet is on but dont know why at serial terminal is show 13.45v while in actual it is 12.23v. Why the voltage is increasing when digital output gets turned on. Please help. Thanks

\$\endgroup\$
2
  • \$\begingroup\$ I have figured out the issue. I am using 4.279v as a reference from the arduino. But as soon as the PIN6 is ON this voltage drops to 3.865v due to which it shows wrong values of voltage. Can anyone tell me why is this voltage getting drop in arduino.? \$\endgroup\$
    – S Andrew
    Sep 7 '16 at 12:45
  • \$\begingroup\$ Q1 is a P-Channel MOSFET and seems that it's connected wrongly. You turn on and off the MOSFET by its gate-source voltage, not gate-drain voltage. So, source and drain should be exchanged. \$\endgroup\$ Oct 3 '16 at 9:06
1
\$\begingroup\$

I have resolved the issue by reading the arduino voltage. Arduino has this great feature where you can read the current voltage. If anyone is facing the similar issue use the below code to read the voltage:

long readVcc() 
{
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1125300L / result; // Back-calculate AVcc in mV
  return result;
}

Above code will return the voltage of the arduino.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.