###### Abstract  
This paper deals with the digital implementation of a motor control algorithm based on a unified machine model, thus usable with every traditional electric machine type (induction, brushless with interior permanent magnets, surface permanent magnets or pure reluctance). Starting from the machine equations in matrix form in continuous time, the paper exposes their discrete time transformation, suitable for digital implementation. Since the solution of these equations requires integration, the virtual division of the calculation time in sub-intervals is proposed to make the calculations more accurate. Optimization of this solver enables faster runs and higher precision especially when high rotating speed requires fast calculation time. The proposed solver is presented at different implementation levels, and its speed and accuracy performance are compared with standard solvers. machine model; FOC; real-time; discretization; flux observer 20  
working on real controls [16]. First introduction of this method and preliminary analysis was introduced in [17]. The use of the unified electric model, as for other approaches, requires the solution of differential equations through integration of the flux, which can be a calculation heavy task. Moreover, to be effective, the estimation of the flux must be available as precise as possible at every PWM cycle, so that the inverter can supply the machine the best voltage to produce the expected performance at each cycle. The flux estimation is only one part of the control scheme that must be completed at each cycle which means that the integration process must use only a fraction of the total time, allowing the other functions such as Field Oriented Control, regulators, modulation and measurement to successfully be carried out. For machines that present low electric speeds, the integration complexities are not a critical feature, since the flux values change relatively slowly and a low PWM frequency can be used without great disadvantages, thus giving the DSP enough time to conduct calculations. However, in case of high electric speeds, PWM frequencies are kept very high to enable faster and more precise flux variations to extract more performance from the motor, such higher torque, lower ripple or higher dynamic response. In this case, more speed means higher PWM frequencies and less execution step-time and, often, the limiting factor is the DSP capability to perform the calculation necessary inside the available portion of the PWM cycle. If the calculation frequency is kept low because of hardware limitations, then it means that there are large variation of the machine states during the PWM cycle. Moreover, since the DSP works in discrete time, the discretization introduces intrinsic errors that must be evaluated and minimized. This paper describes the details of the discrete solver for flux estimation with the optimizations introduced to obtain the best trade off between computational requirements and model precision. Starting from the well known machine equations, execution improvements can be actuated and optimized for discrete-time solvers, such as the ones on Real-Time DSPs [18; 19]. The discretization used is the well know Euler backward method, which is simpler than others proposed in [20] such as the Tustin approximation or state-transition method. The trade off for simpler implementation is the accuracy, but this paper introduces a technique to improve it. By dividing the calculation step time in smaller virtual sub-intervals the application of the Euler method is more frequent and higher precision can be achieved without complicating the calculation using, for example, higher order Taylor approximations, such as in [21]. Given that the angular position and fluxes in high speed conditions can change a lot even in between single PWM cycles, the state calculated at the given step can be outdated when its results are actuated in the next cycle.