Development of Vehicle-to-Grid Control Algorithm