Hey everyone, got my setup:
4s battery
147KV Turnigy
Vesc
I’m trying temporarily to control the speed of my motor with an Arduino and a potentiometer. The code should work and I’ve tried also to manually input the speed, and always getting the same speed from the motor.
It is set to PPM which should work and I didn’t change any unconventional settings in BLDC.
When I use the keyboard to control the motor it works fine.
Not sure where these are located, but I think that the batteries ran out on this last attempt unfortunately… I will charge them and try again tomorrow.
Thought about connecting a power supply I have, but it gives only 1.5 amp, so not sure of what good it will bring…
Just because it can all be powered at 4s doesn’t mean it’s a good idea. Your top speed on 4s with that kv motor is going to be negligible. Get it up to at least 10s…
True, this is exactly what I’m using it for, just for setting it up. Since charging is a bit combersome at the moment… Eventually will use a 12s to run it.
You should use myservo.writeMicroseconds and not myservo.write.
When you attach a servo and do not define the range the PWM signal for 0 degrees is 544 microseconds and 180 degees is 2400 microseconds by default. RC controllers only have a range of around 1000 microseconds.
Also with your code you are setting the mid point @ 40 but the range for the servo is 0 to 180 so 90 is actually your mid point, 180 is your max. You also don’t need the delay in the void setup ()
Here is a bit of code I modified to move a servo back and forth at a fixed rate. (don’t forget to add the include servo at the beginning). I’m trying to learn to code without the use of Delay as that function stops the Ardunio from doing anything while it is active but I don’t have the time to change it right now.
Servo myservo; // create servo object to control a servo
double pos = 0; // variable to store the servo position
int delayTime = 15; // this variable sets the delay time between each step
void setup() {
myservo.attach(9, 1000, 2000); // attaches the servo on pin 9 to the servo object
myservo.writeMicroseconds(1500); // sets the servo to mid point
Serial.begin(9600);
}
void loop() {
for (pos = 1000; pos <= 2000; pos += 10) { // goes from 1000 microseconds to 2000 microseconds
// in steps of 10
myservo.writeMicroseconds(pos); // tell servo to go to position in variable ‘pos’
delay(delayTime); // delays the time before moving to the next position
Serial.println(pos);
}
for (pos = 2000; pos >= 1000; pos -= 10) { // goes from 180 degrees to 0 degrees
myservo.writeMicroseconds(pos); // tell servo to go to position in variable ‘pos’
delay(delayTime); // delays the time before moving to the next position
Serial.println(pos);
}
}
Thank you for the comprehensive answer, can’t wait to try it. At the moment it is all on hold since I am waiting for a battery charger to arrive…Unless… I assume a PC power supply could be able to provide enough amps for everything to work and maybe I could connect it to the 12 volts just for the settings. Is there a risk in doing that? Has anybody tried it successfully?
All I’m doing is letting you know what I have found out. The code works but I have not tried it with an ESC, only with a servo. Oh, you must make sure that the Arduino and VESC share a common ground BTW otherwise its not going to work at all.