Table tennis robot

Hi folks, I need help please.
I building up table tennis robot with one feed servo and one main brushless motor with 30A ESC(both are managed by potentiometer). But I have problem. If I try control one or another motor, everything is great. But if I try to control both,only the servomotor chaotically works. There is my program and thank you for help..

#include <Servo.h>

Servo servo1; //feed servomotor
Servo motor1;  // main brushless motor
int potpin1 = A0;  // potenciometer for brushless motor
int potpin2 = A3; // potenciometer for feedservo
int val1 ;     //brushless
int val2;    // servomotor

void setup()
{
  motor1.attach(9);  // attaches the servo on pin 9 to the servo object
servo1.attach(3);  // 
}

void loop() 
{ 
val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 2000, 500);
servo1.write (10);
delay (500);
servo1.write (180);
delay(val2);
val1 = analogRead(potpin1);           
val1 = map(val1, 0, 1023, 70, 170);  
motor1.write(val1);                  // sets the servo position according to the scaled value 
delay (1);
}

First, get rid of those delays. Look at the Blink Without Delay example in the IDE.
Second, how are you powering the motors and how is it wired up?

Hi,

Can you please go back to your first post and add code tags please?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

How big is the motor?
And as Pauly asks, what is your power supply?

Tom.... :slight_smile:

So the main brushless motor is for 11,1V and it is powered by 12V from computer ATX and goes through ESC. The servo motor is powered by 5V from ATX too. Now it is going well, but I have some problem when I connect both potentiometer to arduino. They are slow reacting and when the potentiometer(for servofeed) is on maximum, it doesnt give me delay 500 but i think that it is more than 1000.
There in the program:
val2 = map(val2, 0, 1023, 2000, 500);
servo1.write (10);
delay (500);
servo1.write (180);
delay(val2);

But if I dissconect one of the potentiometers, the servo works well with the program and on maximum it has 500milisec delay..
It doesnt matter even if I change code to 200. Arduino is no powered because there goes 5V from ESC. It is correct ?

Servo servo1; //feed servomotor
Servo motor1;  // main brushless motor

or

Servo feeder;
Servo launch;
// No useless comments needed.

Arduino is no powered because there goes 5V from ESC. It is correct ?

It's not even comprehensible. The Arduino can NOT power a servo or an ESC. If that is what you are doing/expecting, the results you are seeing are perfectly understandable.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom...... :slight_smile:

The both motors work now, but I have problem with the potentiometers ,that are slow reacting a the problem with control the feedservo. Please help me, thanks :slight_smile:
Here is the picture

HI,
What resistance value are your potentiometers?

Tom....... :slight_smile:

I finnally got it, thanks for everything :slight_smile:

Hi,
What was the problem?

Can you edit the subject to this thread and add [SOLVED], this will help greatly.

Tom.... :slight_smile:

I have there some sequence with led and there was another two delays what did the 1second delay in feedserrvo