Bluepill i2c and BLDC commutation misses

Post here first, or if you can't find a relevant section!
Post Reply
martin321
Posts: 3
Joined: Mon Nov 23, 2020 2:22 pm

Bluepill i2c and BLDC commutation misses

Post by martin321 »

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

stevestrong
Posts: 390
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 7
Location: Munich, Germany
Contact:

Re: Bluepill i2c and BLDC commutation misses

Post by stevestrong »

martin321 wrote:
Mon Nov 23, 2020 2:34 pm
Is the Bluepill waiting for an ACK from there receiver, so it halts the program from continuing?
In the Libmaple core it will affect the main loop. But the interrupts should not be affected.
Which core do you use? Any schematic available?

martin321
Posts: 3
Joined: Mon Nov 23, 2020 2:22 pm

Re: Bluepill i2c and BLDC commutation misses

Post by martin321 »

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
Attachments
ideSetup.png
ideSetup.png (14.24 KiB) Viewed 213 times

stevestrong
Posts: 390
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 7
Location: Munich, Germany
Contact:

Re: Bluepill i2c and BLDC commutation misses

Post by stevestrong »

That seems to be the official STM core.
@fpiSTM will take care of this.

User avatar
fpiSTM
Posts: 851
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 33
Location: Le Mans
Contact:

Re: Bluepill i2c and BLDC commutation misses

Post by fpiSTM »

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.

martin321
Posts: 3
Joined: Mon Nov 23, 2020 2:22 pm

Re: Bluepill i2c and BLDC commutation misses

Post by martin321 »

fpiSTM wrote:
Wed Nov 25, 2020 12:46 pm
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.
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

Post Reply

Return to “General discussion”