This paper presents the design and implementation of a versatile digital directional overcurrent relay. The problem of approximating the time-current characteristic curves of an overcurrent relay is addressed. These curves are approximated by piecewise quadratic polynominals whose coefficients are calculated using a weighted least-squares curve-fitting technique. The magnitude of the fundamental component of the current signal is estimated using a Fourier algorithm. The design of a highly flexible digital overcurrent relay with features such as adjustable pickup and time-dial settings, various time-current curves, directional capability and multiple channels is presented. A detailed description of the relay algorithms used and their software implementation is given. The relay implementation is carried out on a low-cost single TMS320 digital signal processor and the real-time test results are included.