Skip to content

About

C implementation of the Park and Clark transforms. Requires <math.h> for sin() and cos().

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Park_Clarke_Transforms_C

C implementation of the Park and Clark transforms, as well as their inverses.

Requires <math.h> for sin() and cos().

The Clarke transform converts three-phase vectors in the time domain to a stationary two-phase vector.
The Park transform rotates the two-phase stationary vector into a rotating reference frame.

I developed this as part of a field-oriented control BLDC motor project.

Functions

int vector_normalize(double *Vector, int n)

This function normalizes an input vector to have a magnitude of 1.

Inputs:

  • Vector is the pointer to the first element of the vector (type double) to be normalized. When the function is complete, the same vector will contain the normalized values.
  • n is the size of the vector.

Returns:

  • 0

int clarke_trsfm(double *InputVector, double *OutputVector)

This function performs the Clarke transform to transform a three-phase vector to a two-phase quadrature vector.

Clarke Transform:

$$\left[\begin{matrix}\alpha\\\beta\end{matrix}\right]=\frac{2}{3}\left[\begin{matrix}1&\tfrac{-1}{2}&\tfrac{-1}{2}\\0&\tfrac{\sqrt3}{2}&\tfrac{-\sqrt3}{2}\end{matrix}\right]\left[\begin{matrix}u\\v\\w\end{matrix}\right]$$

Inputs:

  • InputVector is the pointer to the first element of the 3-element double vector to be transformed.
  • OutputVector is the pointer to the first element of the 2-element double vector that contains the quadrature result of the vector.

Returns:

  • 0

int inv_clarke_trsfm(double *InputVector, double *OutputVector)

This function performs the inverse Clarke transform to transform a two-phase quadrature vector to a three-phase vector.

Inverse Clarke Transform:

$$\left[\begin{matrix}u\\v\\w\end{matrix}\right]=\frac{2}{3}\left[\begin{matrix}1&0\\\tfrac{-1}{2}&\tfrac{\sqrt3}{2}\\\tfrac{-1}{2}&\tfrac{-\sqrt3}{2}\end{matrix}\right]\left[\begin{matrix}\alpha\\\beta\end{matrix}\right]$$

Inputs:

  • InputVector is the pointer to the first element of the 2-element double vector to be transformed.
  • OutputVector is the pointer to the first element of the 3-element double vector that contains the three-phase result.

Returns:

  • 0

int park_trsfm(double *InputVector, double theta, double *OutputVector)

This function performs the Park transform to rotate a quadrature 2-phase stationary vector to a rotated reference frame.

Park Transform:

$$\left[\begin{matrix}d\\q\end{matrix}\right]=\left[\begin{matrix}\cos{\theta}&\sin{\theta}\\-\sin{\theta}&\cos{\theta}\end{matrix}\right]\left[\begin{matrix}\alpha\\\beta\end{matrix}\right]$$

Inputs:

  • InputVector is the pointer to the first element of the 2-element double vector to be transformed.
  • theta is the type-double angle to rotate the vector in rad.
  • OutputVector is the pointer to the first element of the 2-element double vector that contains the quadrature result of the vector.

Returns:

  • 0

int inv_park_trsfm(double *InputVector, double theta, double *OutputVector)

This function performs the inverse Park transform to rotate a quadrature 2-phase vector to a stationary reference frame.

Inverse Park Transform:

$$\left[\begin{matrix}\alpha\\\beta\end{matrix}\right]=\left[\begin{matrix}\cos{\theta}&-\sin{\theta}\\\sin{\theta}&\cos{\theta}\end{matrix}\right]\left[\begin{matrix}d\\q\end{matrix}\right]$$

Inputs:

  • InputVector is the pointer to the first element of the 2-element double vector to be transformed.
  • theta is the type-double angle to rotate the vector in rad.
  • OutputVector is the pointer to the first element of the 2-element double vector that contains the quadrature result of the vector.

Returns:

  • 0

About

C implementation of the Park and Clark transforms. Requires <math.h> for sin() and cos().

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages