Comments (12)
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.
Hey @z13660,
have you had some time to investigate more the pwm signals?
from arduino-foc.
I will test it these days. The oscilloscope is at school. Please wait for a little longer. (^_^)
from arduino-foc.
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.
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.
Hey @z13660 ,
Can you elaborate a bit more about what do you mean that it is not a good waveform?
from arduino-foc.
from arduino-foc.
I don`t know if the phase shift will cause any problems. e.g. like causing the motor spinning less smooth.
from arduino-foc.
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.
Hey @askuric,
Thanks for your codes. (^_^)
from arduino-foc.
I'll leqve this issue opened for a bit. I'd like to get to the bottom of this. :D
from arduino-foc.
Included in the dev branch, and will be in the next release
from arduino-foc.
Related Issues (20)
- motor.run()
- [BUG] Strange behavior on ESP32 HOT 1
- [BUG] Fix KV initialization HOT 1
- [BUG] incorrect pins used in DRV8302 6-PWM example HOT 2
- [FEATURE] Two issues with MagneticSensorPWM HOT 3
- [FEATURE] Performance of setting the PWM duty cycles HOT 8
- [FEATURE] Add library.json to set libArchive? HOT 2
- [BUG] BLDCDriver6PWM issue with STM Nucleo HOT 14
- [BUG] OpenOCD init failed while using specific pin HOT 6
- Update KV estimation example to match new code
- [FEATURE] Allowing to choose SPI pins HOT 1
- Can't change PWM frequency - 550hz [BUG] HOT 8
- [BUG] Monitor downsampling cannot be disabled HOT 2
- 20bit magnetic encoder support
- [BUG] ESP32 current sensing readings not synced with PWM - Not reproducible HOT 2
- [BUG] Error in doc: initFOC() cannot be used in open loop mode HOT 1
- driverAlign() ignores gain sign, always "MOT: Success: 3" HOT 3
- [BUG] PlatformIO adding SimpleFOC requires to specify SPI and WIRE lib_deps to prevent compile errors HOT 5
- Support for the new ESP32 LEDC library API HOT 3
- Is this FOC suppot high speed BLDC(5000rpm)?[FEATURE] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-foc.