Coder Social home page Coder Social logo

Comments (12)

askuric avatar askuric commented on May 10, 2024

Hey @z13660
It doesn't look like space vector owl indeed. Did you enable it in code?
motor.foc_modulation =FOCmodulationTtype::SpaceVectorPWM
By default it's sinusoidal pwm, and in the scope it looks like sine owl to me :)

from arduino-foc.

askuric avatar askuric commented on May 10, 2024

Hey @z13660,
have you had some time to investigate more the pwm signals?

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

I will test it these days. The oscilloscope is at school. Please wait for a little longer. (^_^)

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

I tested it. Add motor.foc_modulation =FOCmodulationTtype::SpaceVectorPWM, the waveform did change a little, but still not the standerd SVPWM. In SVPWM MODE the waveform will bounce around at the Edge.
https://user-images.githubusercontent.com/23288802/117557701-78a4e980-b0a8-11eb-80b0-0ccf2f6b7bac.mp4

// Open loop motor control example
#include <SimpleFOC.h>


// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(5);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8);



// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }

void setup() {

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  driver.init();
  // link the motor and the driver
  motor.linkDriver(&driver);

  // limiting motor movements
  motor.voltage_limit = 3;   // [V]
  motor.velocity_limit = 5; // [rad/s] cca 50rpm
  motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
  //motor.foc_modulation = FOCModulationType::SinePWM;
  // open loop control config
  motor.controller = MotionControlType::velocity_openloop;

  // init motor hardware
  motor.init();

  // add target command T
  command.add('T', doTarget, "target velocity");

  Serial.begin(115200);
  Serial.println("Motor ready!");
  Serial.println("Set target velocity [rad/s]");
  _delay(1000);
}

void loop() {

  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit
  motor.move(0.5);

  // user communication
  command.run();
}

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

OK I think I figure it out. Is it the timer2 problem? Changed the pin BLDCDriver3PWM(9, 10, 5, 8); and it work perfectly. Again if I use BLDCDriver3PWM(9, 10, 3, 8); pin3 still output the wrong waveform. It seem that we can not use Timer2

SVPWM.correct.mp4

from arduino-foc.

askuric avatar askuric commented on May 10, 2024

Hey @z13660 ,
Can you elaborate a bit more about what do you mean that it is not a good waveform?

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

1
2

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

I don`t know if the phase shift will cause any problems. e.g. like causing the motor spinning less smooth.

from arduino-foc.

askuric avatar askuric commented on May 10, 2024

Hey @z13660,

Yes, I see what you mean. This is true, and if you look more closely you'll see that even in the image above pin3 is not perfectly aligned. This is due to the fact that the pins do not belong to the same timer. So far in the library, at least for arduino we did not do the timer synchonisation, mostly because arduinos are very limited in their capabilities and a lot of standard features do not even exist for them.

The shifted phase will not do much harm, at least if the shift is not too severe and if the pwm frequency is high. So that is why we did no see many complaints so far. But you're right that we should dig into this more carefully.

I've tested a quick code that was posted in this site and it worked for me:
http://www.openmusiclabs.com/learning/digital/synchronizing-timers/index.html

So basically add this code right after your driver.init():

  // use only one of the following 3 lines
GTCCR = (1<<TSM)|(1<<PSRASY)|(1<<PSRSYNC); // halt all timers

// place all timer setup code here
// do not do any timer setup before this section

// set all timers to the same value
TCNT0 = 0; // set timer0 to 0
TCNT1H = 0; // set timer1 high byte to 0
TCNT1L = 0; // set timer1 low byte to 0
TCNT2 = 0; // set timer2 to 0

GTCCR = 0; // release all timers

This code should sync all the timers.

from arduino-foc.

z13660 avatar z13660 commented on May 10, 2024

Hey @askuric,
Thanks for your codes. (^_^)

from arduino-foc.

askuric avatar askuric commented on May 10, 2024

I'll leqve this issue opened for a bit. I'd like to get to the bottom of this. :D

from arduino-foc.

askuric avatar askuric commented on May 10, 2024

Included in the dev branch, and will be in the next release

from arduino-foc.

Related Issues (20)

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.