Hello all.
I'm a relatively new Arduino user, and my experience with electronics is questionable at best. Currently, I am trying to use an Arduino to control the speed of a brushless DC motor with the help of an encoder to build a test stand. Currently, I'm just trying to read the speed of the encoder when the motor is run at a certain power level. Unfortunately, once I get above 15% motor power with the encoder plugged in, the motor will accelerate to what looks like maximum power, suddenly stop, then beep in the A tone for the motor. Resetting the target power to 0% then changing the target power repeats the previous action. The Serial, which I'm using to monitor things, also appears to hang up when this happens.
This only happens when the encoder is plugged in to the 5V and ground on the Arduino. The motor spins up and down from 0% - 100% fine when the encoder is not plugged in.
Any idea what could be causing this and how I can try and fix it? Thanks
What speed is the problem occurring at (RPM)?
What speed is your encoder capable of?
What is the encoders output frequency at the problem RPM?
Can you change the PPR of your encoder?
Yeah, those encoder pin names were basically just a holdover from my last project that used an encoder. I have tested the encoder just on its own, and looking at it right now it looks like I didn't set the PPR correctly, so I need to fix that. Otherwise, it looks like the encoder is working fine.
The problem is occurring at 15% motor power. I unfortunately can't get the RPM since the serial monitor seems to pause then the motor stops, giving me no encoder reading, and I have no idea if 15% of maximum theoretical motor RPM would be a good estimate.
At 2048 PPR, the encoder is capable of 7500 RPM, and at the intended PPR of 512 it's capable of 15000 RPM. The encoder does have changeable PPR.
Based on the ESC manual, I think that beeping in the A tone means the ESC somehow entered throttle range calibration, or it's receiving strange controller signals from the Arduino, but I may be completely wrong on that.
I have a delay of DT ms in the loop, and that function is called once per loop. Kinda a lazy way to do it, and honeslty may be part of the problem. I don't guarantee that the time interval is constant, I kinda just assume it's roughly constant with that delay.
It looks like my 4 switch in the encoder doesn't work properly, so I can't actually set the encoder to a PPR capable of 15000 RPM. Would spinning the encoder too fast for it's rated velocity cause the encoder to wig out the Arduino?
After recording the motor spinning, my best estimate for the RPM that the problem is happening at is 1200 RPM. This corresponds to a pulse rate of about 15.2 kHz for the output frequency, assuming the frequency is just RPM * PPR. I also recorded a video of the problem which is now in the main post.
Alright, I think I found my solution. From what I could tell, the encoder was pulsing too fast for the Arduino, which I think caused the the PWM signal controlling the motor to stutter or something, causing an invalid signal to be sent to the ESC. This is what caused the motor to play the tones it did; the ESC received an invalid controller signal. I decreased the PPR of the encoder to 192, and it seems to be working fine. Thank you Tom for asking what the encoder frequency was at the RPM the motor was running at, as that was what allowed me to figure this out.