In this paper, an Optimal Trajectory Generation Algorithm (OTGA) is developed for generating minimum-time smooth motion trajectories for serial and parallel manipulators. OTGA is divided into two phases. The first phase encompasses derivation of minimum-time optimal trajectory using cubic spline due to its less vibration and overshoot characteristics. Although cubic splines are widely used in robotics, velocity and acceleration ripples in the first & last knots can worsen manipulator trajectory. The second phase includes changing cubic spline interpolation in the first and last knots of optimized trajectory with 7th order polynomial for having zero jerk at the beginning and end points of trajectory. Performing this modification eliminate undesired worsening in the trajectory and provide smoother start and stop of joint motions. Particle Swarm Optimization (PSO) is chosen as optimization algorithm because of its easy implementation and successful optimization performance. OTGA has been tested in simulation for PUMA robot and results are compared with algorithms proposed by earlier authors. In addition, a discrete-time PID control scheme for PUMA robot is designed for comparing energy consumption of OTGA with algorithms developed by previous authors. Comparison results illustrated that OTGA is the better trajectory generation algorithm than the others.