Flactuating PWM output

Hello, I have a little issue related to a project I'm building.

It's a medical device called string phantom used for Quality Assurance of Ultrasound machines - blood flow velocity confirmation.
Construction is simple, a string travels between pulleys and mimics the fluid flow.

To build it I've used:

Generally, it works as intended, but I'm currently changing the control of the motor from ESC to PWM Board controller as I thought ESC was causing a little fluctuation in motor speed. By that I mean you can clearly hear it despite of PWM signal out of Arduino to ESC being locked.

I've changed ESC to mentioned board and I've noticed the same issue. I've recently acquired an oscilloscope (Hantek 1008C) and checked the PWM output from Arduino. It is slightly unstable according to my oscilloscope.

My questions:

  • is that just aliasing as my oscilloscope is not that good and the PWM signal is fine?
  • what is the reason for motor fluctuation and how can I fix it? Is it too weak power supply? or the fact that I'm using it to power up Arduino (power adapter input) and motor at the same time? What filters I can add to remove this phenomenon?

if you can't tell, I don't have much experience with electronics...


Show the signal on the oscilloscope

example of 20%. It will fluctuate between 19.9% and 20.0%

Mostly visible when duty is 50%

Post your code. Perhaps it calls the PWM code more than once, and that restarts the PWM sequence, causing what looks like jitter.

here is my test code

String odebraneDane = "";

double mapspeed = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(4, OUTPUT);

   Serial.begin(9600); //serial comm
   Serial.println("Time circuits activated!");  

void loop() {

   if(Serial.available() > 0) { 
   odebraneDane = Serial.readStringUntil('\n');
   mapspeed = odebraneDane.toInt();
  // put your main code here, to run repeatedly:
   analogWrite(4, map(mapspeed, 0, 100, 0, 255));

I've been reading a bit about PWM frequency required for BLDC control board I'm using. They expect 1-20kHz and most of the Arduino PWMs are 490Hz. I've changed from using pin 11 to pin 4 as that one is closer to 1kHz (slightly under) and behavior improved. I can now start the motor at a way lower duty cycle 13% instead of 21%. Anything under that value is a jitter.

Studying the datasheet they've also mentioned capacitors and resistors on the board - they might need adjustment to my particular motor, however so far I don't see a signal out of the BLDC motor board to the motor at low duty cycles of PWM, so I will leave that for later (I've requested supplier to provide more guidance on that as they mentioned some attachment in the datasheet that was not to be found).

I've tried to use library PWM which allows changing PWM frequency. I managed to crank it up to 20kHz and I can now start the motor at 8% duty cycle and it runs smoothly without any jitter from low speeds.

In summary, the issue was with the frequency difference between Arduino PWM and BLDC board required input. It seems that my oscilloscope reading was a bit noisy or the quality of it could be better.

Hope this might help anybody else having a similar issue. I will post the code later when I'm on my other laptop.


You would also get better control with some speed feedback from the motor shaft.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

Hi Tom,

I've ordered a motor with a hall sensor but it came without it, so I decided to make it with what I had... I measure RPM on my secondary pulley with a hall sensor. That is more important to me in calculating string linear speed.

The BLDC controller has speed signal output so I will connect that back to the Arduino to add some code to check slippage between the motor and the pulley.


0.1% deviation - what problem with that?
For most of measurements 0.1% accuracy is sufficient.


this one will stabilize RPM,

This kind of ESC are not for precise regulation .
Try this one,