How use a potentiometer to control the speed of a brushless motor?

So im using a ESC and brushless motor for my land robot. I built my own wireless controller with 2 joysticks. But the problem is that the range of the arduino joystick is small so the motor speeds up too quickly. I want to use a potentiometer to set a speed of the motor. For example, if i turn the potentiometer to 1023, the motor will run as fast as possible. and if i turn it to 0, the motor will turn very slowly or none at all. how can i code this so that i can control the speed with the potentiometer at any time?

Hi,
I gather your want to remove throttle control from the joystick to a pot?
If so, measure the resistance of the joystick pot and replace that part of the joystick circuit with a linear pot that you can put a knob on.

Tom... :slight_smile:

TomGeorge:
Hi,
I gather your want to remove throttle control from the joystick to a pot?
If so, measure the resistance of the joystick pot and replace that part of the joystick circuit with a linear pot that you can put a knob on.

Tom... :slight_smile:

no i mean i want to control the motor using a joystick. but i also want to constrain how fast the motor can go by using a potentiometer.

for example, if i turn the potentiometer to 1023, the motor is allow to travel as fast as it can go when i move the joystick up

if i turn the potentiometer to 512 (with is the middle value) the motor can only go as fast as 50% speed

if i turn the potentiometer to...lets say 1.... the motor can only travel..idk 1%ish?

like how could i do this? can u give me a small if statement or something?
vv

Use the trimming pot output (0-5V) to feed the positive leg of the throttle pot. The output of the throttle pot will only be max of what the trim pot feeds it.

I assume that you are using pwm to control your esc, right ?

Controlling ESC by using pwm, maximum pwm value is 255 and steering pot value is then 1023. Map another pot to map this maximum value, then you have capability to steer 100% and capability to adjust max pwm value.

Something like this idea might work:

...

byte maxPWMvalue = 0;
byte outputPWMvalue = 0;
int steeringPotValue = 0;
int adjustPotValue = 0;
int steeringPotPin = A0; //just an example
int adjustPotPin = A1; //just an example
int escControllingPin = 3; //just an example

...

steeringPotValue = analogRead(steeringPotPin); //read steering pot Value 
adjustPotValue = analogRead(adjustPotPin); //read adjusting pot Value 

maxPWMvalue  = map(adjustPotValue, 0, 1023, 0, 255); // mapping value of 100% pwm
outputPWMvalue = map(steeringPotValue, 0, 1023, 0, maxPWMvalue); //map esc controlling pwm

analogWrite(escControllingPin, outputPWMvalue);

...

TommiP

Hi,
Can you post a circuit diagram of how you have your joysticks connected, as justone has said, a trim pot on one end of the joystick pot will limit the maximum the output of the joystick can get to.

Tom... :slight_smile:

masterfo:
So im using a ESC and brushless motor for my land robot. I built my own wireless controller with 2 joysticks. But the problem is that the range of the arduino joystick is small so the motor speeds up too quickly.

Something to keep in mind if you are expecting low rpm control.

Sensorless motors always will have a jump while starting as they go through their start sequence. I find they can be slowed down considerably after starting but the initial start is always quite a jump in RPM. They have to spin a minimum rpm to function.

If if its a sensored motor the start is much smoother, Can run smoothly from zero RPM.