Code Monkey home page Code Monkey logo

bldc's Issues

Polarity Issue

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
/* Set Idle state to Reset for all FETs, so break can be used for neutral */
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;

Let's give the below configuration a try and see if it gets us what we want.

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
/* Set Idle state to Reset for all FETs, so break can be used for neutral */
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;

Incorrect Phase Angle Estimation

#ifdef PHASE_PREDICTION
uint16_t currentTimerCount = motorSpeedTimerOverrun ? TIM13_PERIOD : TIM13->CNT;
uint16_t estimatedPhasePrediction = (((uint32_t)currentTimerCount * 100 * 60) / motorSpeedCount) / 100;
#else
uint16_t estimatedPhasePrediction = 60;
#endif
int16_t quadratureAxisAngle = checkAngleOverflow(directAxisAngle + 60 + estimatedPhasePrediction);

The above code incorrectly drives the quadrature angle 60 degrees ahead of the direct angle when PHASE_PREDICTION is enabled. To fix this issue the below changes are recommended:

#ifdef PHASE_PREDICTION
    uint16_t currentTimerCount = motorSpeedTimerOverrun ? TIM13_PERIOD : TIM13->CNT;
    uint16_t predictedPhaseAngle = (((uint32_t)currentTimerCount * 100 * 60) / motorSpeedCount) / 100;
#else
    // half of the hall effect resolution, so that active torque region is centered around max torque point
    uint16_t predictedPhaseAngle = 30; 
#endif


    int16_t quadratureAxisAngle = checkAngleOverflow(directAxisAngle + 90 + predictedPhaseAngle);

Wrong period

timerPeriod = (uint16_t)(((uint32_t)SystemCoreClock / 2 / PWM_FREQ_HZ) - 1);

should be

timerPeriod = (uint16_t)(((uint32_t)SystemCoreClock / PWM_FREQ_HZ) - 1);

This is to account for the fact that we are no longer doing center aligned mode.

Wrong Polarity

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;

should be

TIM_OCStruct.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCStruct.TIM_OCNPolarity = TIM_OCNPolarity_High; 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.