Showing results for 
Search instead for 
Did you mean: 

Clark and Park implementation code


This is the first time I have to implement a PMDC motor control system.

There are 3-phase sine currents need to be converted into d-q components using Clark and Park.

I don't have the motor to test yet, so with the DAC I created three 120° phase-shifted sine waves that I need to convert into d-q components. This is an example of the code I wrote:


My questions are:

1) Is this code sufficient for conversion?

2) Is there an implementable library that performs these calculations? I found only this, but it is not clear to me what it can do

Can anyone, in general, give me some more information on how to proceed?

cedric H
ST Employee

Dear @luke514,

ST provides a complete implementation of FOC algorithm available here. Feel free to download the MCSDK and generate a simple project for your hardware (select one of the provided motors if you don't have one). A lot of documentation is provided with the MCSDK,

We unfortunately do not have the bandwidth to provide feedback on user's code. I let the community answer.