Giter Site home page Giter Site logo

bldc-motor-control-foc's People

Contributors

eferu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bldc-motor-control-foc's Issues

Model init won't run

hello Emanuel i want to use your model and the model init give me this error with a missing file and i have a question can i mdify this work to be able two run on another hub motor with a 17inch 48v and 1500 watt rated power ? thanks for help
Capture

Edit: i edit the motor parameters in model init and then it ran successful and i ran the simulink model i get this result in figure and it seems all wrong can you please guide me with steps to be able to match this model with my motor specs :
Capture

Generate Code error - Matlab_R2019b

Hi,
I am getting the following error when trying to generate code from Simulink model, could you please help me with this? I am using Matlab_R2019b version

Generating code into build folder: /Users/mac15/Downloads/BLDC/Matlab/bldc-motor-control-FOC-master/01_Libraries/02_Plant/BLDCmotor_FOC_R2017b_fixdt_ert_rtw

Build procedure for model: 'BLDCmotor_FOC_R2017b_fixdt' aborted due to an error.

Error in S-function 'BLDCmotor_FOC_R2017b_fixdt/BLDC_model_closed/BLDC_model_sfcn': S-Function 'BLDC_model_sf' does not exist
Component:Simulink | Category:Block diagram error
Error in S-function 'BLDCmotor_FOC_R2017b_fixdt/PWM_gates/PWM_generator1/PWM_generator_sfcn': S-Function 'PWM_generator_sf' does not exist

Acceleration with Cruise Control enabled

Hello Emanuel!

I have discovered an issue with using the input target value to temporally increase the speed when the cruise control is enabled. Steps to reproduce the issue:

  1. Set FOC control method and VLT mode
  2. Apply some input value (r_inpTgt) for the motor to spin, but not at the full speed
  3. Enable Cruise Control (b_cruiseCtrlEna = 1) with current speed used as a target speed (n_cruiseMotTgt)
  4. Increase the input target value (r_inpTgt) until the motor starts to accelerate (cruise control speed stabilization is overridden by the input target)
  5. Gradually decrease the input target

The expected behavior is that the motor should slow down to the cruise control target speed, and once this speed is reached, input target value should be ignored. Actually the speed can go below n_cruiseMotTgt. Cruise Control engages again only when the input target is set to 0 (or, maybe, some small value) by releasing the accelerator.

After analyzing the Simulink model, I think I've found the problem. The anti-windup circuit in the PI controller ( PI_clamp_fixdt ) is implemented in the wrong way. This implementation works fine when satMin and satMax have the opposite signs (satMin < 0 < satMax), and usually this condition is met, but with the Cruise Control enabled both min and max values can have the same sign.

Clamping_circuit should take into account not the sign of preSat, but the actual limit (min or max) which has been hit. The integrator should be disabled (Clamp = true) when the following condition is met:

((preIntegrator > 0) && hitMax) || ((preIntegrator < 0) && hitMin))

I don't have a Matlab/Simulink installation, so I modified the code in BLDC_controller.c manually and replaced this:

  /* Signum: '<S66>/SignDeltaU3' incorporates:
   *  Sum: '<S65>/Sum1'
   */
  if ((int16_T)tmp < 0) {
    tmp_0 = -1;
  } else {
    tmp_0 = (int16_T)((int16_T)tmp > 0);
  }

with this:

  if (rtb_UpperRelop_l) {
    tmp_0 = -1;
  } else {
    tmp_0 = rtb_LowerRelop1_l;
  }

inside PI_clamp_fixdt_l() (this function is used for FOC speed mode) and two similar PI controller functions. With this modifications the input target can be used to temporally increase the speed when the Cruise Control is enabled without any problems, and the speed never goes below n_cruiseMotTgt.

I also have a question about Cruise Control and the input target. When using torque mode, the input target is used to set Iq. But with Cruise Control enabled the input target sets the lower limit for Vq. I see a potential issue here: if some Vq value causes the motor to spin faster when the same numerical value of Iq, the speed will be instantly increased after the Cruise Control is enabled, because the input target is now considered as a voltage target, not a current target. This may be not convenient for driving. Am I missing something here?

Note: I'm using your FOC BLDC controller for my custom electric scooter based on the wheels and the main board from an hoverboard. A lot of modifications have to be done to the code from hoverboard-firmware-hack-FOC in order to integrate it with the rest of the e-scooter's system (it contains some custom boards and other non-standard stuff), so I decided to write the code from scratch. The only things I'm using from your code are the BLDC controller itself and the idea on how to use MCU's peripherals (DMA, timers, etc.) for motor control. Because of that I'm opening this issue here, not in the hoverboard-firmware-hack-FOC repository.

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.