Yes, it''s possible to use a DC motor with permanent magnets as a generator. If its output voltage is sufficiently high, it can charge a battery. But it''s also possible to destroy a battery when you charge it in such an uncontrolled manner. So, be careful. how would you