-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange SVPWM waveform using atmega328p #71
Comments
Hey @z13660 |
Hey @z13660, |
I will test it these days. The oscilloscope is at school. Please wait for a little longer. (^_^) |
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.
|
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 |
Hey @z13660 , |
I don`t know if the phase shift will cause any problems. e.g. like causing the motor spinning less smooth. |
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: So basically add this code right after your // 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. |
Hey @askuric, |
I'll leqve this issue opened for a bit. I'd like to get to the bottom of this. :D |
…raible frequency either 4kHz or 32kHz #97 328/2560
Included in the dev branch, and will be in the next release |
motor running at open_loop_velocity_example.ino,motor can spin like normal,but when I connect to the oscilloscope, it is not a standard svpwm waveform I tried to change several atmega328p s,but the same.
https://user-images.githubusercontent.com/23288802/116771035-d028d100-aa7a-11eb-9048-c2614f32f1c7.mp4
The text was updated successfully, but these errors were encountered: