To efficiently operate electromechanical systems powered by two energy sources, it is necessary to determine the instantaneous power split between sources in order to minimize the energy consumption of the whole system. In this work, this problem is posed as a nonlinear finite horizon optimal control problem with control and state constraints and is solved using a direct transcription approach. The problem is fully discretized in time and the resulting finite dimensional optimization problem is solved using a nonlinear programming code. This paper describes the application of direct transcription to the case of the hybrid electric vehicle (HEV) being developed in the Applied Electronics Group (GEA) at the University of Río Cuarto. The statement and discretization of the control problem, the setting for using the nonlinear programming code and several examples and comparisons with those obtained by other approaches are described.