Compared with the tradition software development process, the model based design method is more efficient. By using the model based design method, the harmonic detection algorithm based on instantaneous reactive power theory is realized successfully. This paper expounds the configuration process of the model based design method.The C code generated automatically is tested at SIL and runs successfully in the DSP. Finally on the shunt active power filter, the code of the harmonic detectoin generated by the method is verified. The results show that the code of the harmonic detectoin generated by the method is reliable and easy to transplant which eliminates the cumbersome process of artificial code and greatly improves the development efficiency.