It's in the Engine Computer and has an extremely low failure rate. For intermittent charging, suspect worn brushes in the alternator. If you have the little silver Nippendenso alternator, repair is very easy, and in some cases can be done without removing the alternator from the engine. Too verify the cause, measure the voltages on the two small wires on the back of the alternator while the engine is running. One will have full battery voltage. The other one must have less but not 0 volts. Let me know what you find on that second wire.