Hey guys, so with nothing to do while waiting for my Nucleo boards to come in, I decided to give a second chance to my bluepills which I thought were fakes. Turns out they’re real! I just had wrong configurations when flashing to get them to connect properly. After a bunch of troubleshooting, the board seems to be working great mostly.
I went through testing the functionality from the beginning with no issues, until now I’m at basically full FOC doing position testing. I’ve managed to get it working, but there’s two issues I came across and wanted to see if there was any ideas on how to help or improve things. My concerns are that the same code (minus the pin numbers) are almost exactly the same as I had working on my Arduino Uno / Nano.
The first issue was on compilation size. The same code compiles and uploads to my Arduino Uno / Nano without any issues. However on the STM32F103C8T6 using platformio, when compiling a barebones full FOC program, it gives me the error “region `FLASH’ overflowed by 5104 bytes”. The Nano / Uno should have 32KB flash memory, while the STM32F103C8T6 should have 64KB flash memory given. Is the compiled size expected to be this much larger or is there something I’m doing wrong?
I know there’s an extra 64KB hidden flash that is untested, so I was able to get it working by compiling using the bluepill_f103c8_128k board ini configuration, however that won’t upload from PlatformIO, instead I had to flash it using the STLink utility and it still works fine, so I’m able to keep testing.
The second, and more concerning issue is while it’s actually running I’m getting a strange noise which I’ll try to describe. When the motor is completely at rest, where position sensor is exact, there’s no noise. When the motor is trying to spin quickly to reach a new position there’s a high pitch whine that is normal, and I’ve heard the entire time. However when it reaches the position, but not exact (there’s some noise on my magnetic sensor) and it’s trying to do very small compensations, there’s a sort of high pitch scratchy noise. It’s not as high pitch as the motor running, and it’s not very loud, but it’s still very noticeable when you’re near and was not there with the same settings on my arduino boards at all.
I’ve searched through the community posts and have tried changing the PWM frequency from 15000 to 50000 and it doesn’t seem to make a difference. My motor settings code are as below if it may help.
driver.voltage_power_supply = 12; //driver.pwm_frequency = 15000; //tried between 15000 and 500000 driver.init(); motor.linkDriver(&driver); current_sense.init(); motor.linkCurrentSense(¤t_sense); motor.foc_modulation = FOCModulationType::SpaceVectorPWM; motor.controller = MotionControlType::angle; motor.phase_resistance = 0.0946; // [Ohm] motor.current_limit = 10; // [Amps] motor.PID_velocity.P = 0.5f; motor.PID_velocity.I = 10; motor.PID_velocity.D = 0; motor.LPF_velocity.Tf = 0.01f; motor.LPF_angle.Tf = 0.01; motor.P_angle.P = 20; motor.velocity_limit = 100;
It still runs fine, no apparent overheating, and the motion is actually smoother than my arduinos, but it still seems strange to experience this noise that wasn’t there before.
If anyone has any suggestions on these two issues, it would be much appreciated.