dc generator working principle