Hi,
I am using a Bluepill board to drive a BLDC motor trough 3 PWM pins and hall sensors. Hall sensors are connected to interrupt and commutation is using hardware timer.
The motor runs smooth without sending data through i2c, but when I send 20 bytes every 50ms the motor stutters and are missing commutation steps.
The receiver is a 1284P running at 8MHz.
Is the Bluepill waiting for an ACK from there receiver, so it halts the program from continuing?
Martin
Bluepill i2c and BLDC commutation misses
-
- Posts: 502
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: Bluepill i2c and BLDC commutation misses
I’m using a DRV8323 with 3xPWM signal.
There is a SIN table that analogWrite uses to create sin waves for commutation.
No sure what core I’m running. Installed STM32Duino into the Arduino IDE.
I’ve attached the IDE setup
There is a SIN table that analogWrite uses to create sin waves for commutation.
No sure what core I’m running. Installed STM32Duino into the Arduino IDE.
I’ve attached the IDE setup
- Attachments
-
- ideSetup.png (14.24 KiB) Viewed 3427 times
-
- Posts: 502
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: Bluepill i2c and BLDC commutation misses
That seems to be the official STM core.
@fpiSTM will take care of this.
@fpiSTM will take care of this.
Re: Bluepill i2c and BLDC commutation misses
This fairly depends on your code.
I2C works with IT and I guess priority is higher than the one you used for the HALL sensor, that's probably explain why you have this issue.
I2C works with IT and I guess priority is higher than the one you used for the HALL sensor, that's probably explain why you have this issue.
Re: Bluepill i2c and BLDC commutation misses
Hi fpiSTM,
I have tried to find a way to set the hallsensor update to a higher priority than i2c.
What I have found and tried hasa not worked. Probalby because I have not implemented it correcty.
https://github.com/stm32duino/Arduino_C ... issues/472
The stutters happened only at higher speeds. I guess this is when i2c uses more time that the commutation period.
HardwareTimer* motorTimer = new HardwareTimer(TIM1);
This is where hallsensors position is gathered and a sin lookup table is used to set analogWrite
HardwareTimer* i2cData = new HardwareTimer(TIM2);
i2cData is the function where a single i2c request is made and a single i2c transmission.
Can the problem be that I am doing a i2c send/receive inside a HW timer?
I will try tomorrow to move it to the loop and use a "blink without delay" function.
Martin
Re: Bluepill i2c and BLDC commutation misses
It worked when removing i2c from TIM2 and use it directly in the loop.
I see now why there would be a problem with i2c inside TIM2.
Had to read the code again yesterday to see it.
Martin
I see now why there would be a problem with i2c inside TIM2.
Had to read the code again yesterday to see it.
Martin
Re: Bluepill i2c and BLDC commutation misses
If you use the I2C inside the Timer handler IRQ then I guess you are in a deadlock.