My MacBook Air won't charge correctly : the light is green instead of orange I have a 2009 MacBook Air (MacBookAir2,1)

I have a compatible MagSafe and a Apple one.

Sometimes (almost most of the time), when the computer is running and not in sleep, if I plug the MagSafe, it goes orange for a few minutes then goes back to green. It says that the computer doesn't use battery but it doesn't charge it.

I have tried with both chargers and it is the same.

Now I have also tried to shut the computer down and charge it : it works, it remains orange and charges the battery.

I must admit that I have changed the battery to a compatible one because mine was too old. 

Do you think the fact that it is a compatible battery makes the computer thinks it is fully loaded and stops charging ?  Is there a way to prevent that instead of stopping the computer to charge ?

Thanks
The first thing I would do is an SMC Reset.  According to Apple, one of the reasons to reset your SMC is...



To do a reset


Shut down the Mac.
Plug in the MagSafe or USB-C power adapter to a power source and to your Mac.
Using the built-in keyboard, press Shift Control Option on the left side of the keyboard, then press the power button at the same time.
Release all keys, then press the power button again to turn on your Mac


If you continue to have problems, I would then run an Apple Hardware Test and see if you can obtain any diagnostic info.