Hi. I am new to arduino and I want to create an rc remote control for a nitro buggy. In the car are 2 servo motors: a turnigy hv767 and a tower pro mg995 digi high speed. I use two arduino nano, two nrf24L01+pa+lna. My problem is that the turnigy doesn`t move, the towerpro is moving. I have removed the towerpro from channel pins and putted the turnigy on them. The only difference from the two servos that I found is that towerpro is analog and turnigy si digital. I have to put the turnigy on a certain pin? Thank you
Please post your circuit and code. This is the starting place for fault finding.
for the receiver i used this code:
#include <SPI.h>
#include <RF24.h>
#include <Servo.h>
RF24 radio(9, 10);
const byte rxAddr[6] = "00001";
//SErvo control
Servo yaw;
//Servo pitch;
//Servo roll;
Servo thr;
//Joystick ARray
int joystick[6];
void setup()
{
for(int i = 2; i<=4; i++){
pinMode(i,OUTPUT);
}
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setAutoAck(false);
radio.openReadingPipe(0, rxAddr);
radio.startListening();
//Servo attachments
thr.attach(3);
yaw.attach(6);
//pitch.attach(4);
//roll.attach(5);
delay(50);
}
void loop()
{
if (radio.available())
{
bool done = false;
while (!done)
{
// Fetching the data payload
radio.read( joystick, sizeof(joystick) );
done = true;
int val0=map(joystick[0],0,1024,0,180);
int val1=map(joystick[1],0,1024,0,180);
//int val2=map(joystick[2],0,1024,0,180);
//int val3=map(joystick[3],0,1024,0,180);
thr.write(val0);
yaw.write(val1);
//pitch.write(val2);
//roll.write(val3);
//for serial observation
Serial.println(val0);
Serial.println(val1);
//Serial.println(val2);
//Serial.println(val3);
}
}
else{
Serial.println("Data not received");
}
delay(50);
}
for the transmiter I used this code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10);
const byte rxAddr[6] = "00001";
int sendingdata[6];
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setAutoAck(false);
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
delay(50);
}
void loop()
{
int in1 = analogRead(A1); //Right Stick Up and Down
int in2 = analogRead(A2); //Right Stick Left and Right
// int in3 = analogRead(A2); //left Stick Up and Down
// int in4 = analogRead(A3); //Left Stick Left and Right
//int in3 = 22; //left Stick Up and Down
//int in4 = 22; //Left Stick Left and Right
sendingdata[0]=in1;
sendingdata[1]=in2;
//sendingdata[2]=in3;
//sendingdata[3]=in4;
radio.write( sendingdata, sizeof(sendingdata) );
Serial.print("RY =");
Serial.println(sendingdata[0]);
Serial.print("LY =");
Serial.println(sendingdata[2]);
delay(50);
}
My problem is that in the SAME pin(D3), one servo is responding to joystick command and the other doesn`t.
Digital/analog makes no practical difference. But the other differences are that the HV767 is bigger, more powerful and designed for higher voltage and current.
How are your servos powered?
Steve
The motor are powered by a li-ion 7.4v, 2000mah
With the standard receiver/transmitter are working fine. But they are on 27mhz, and have a range of 60m. I am building them hopping for more range
raptorel, we need to see a wiring diagram. MarkT asked for it in reply #1 when he asked for your circuit. slipstick asked how the servos are powered.
You answered with the power source. Good info but not quite what we are looking for.
Get a pen or pencil and paper. Draw a wiring diagram. Draw out how the servos are connected. Where is the signal connected? Where is the ground connected? Where is the positive wire connected? Where is the battery connected? include the wires for the nrf24L01 too.
Take a picture of the paper.
Post the image here.
Since the vast majority of servo problems lay in how they are powered, we want to see how you did it.
Towerpro on pin d3 working
Towerpro on pin d6 working
Turnigy is not working on d3 and d6
If you tried the servos on the same pin and one works and the other does not work, then the non working servo could be bad, or there may be a bad connection somewhere with the non functioning servo. Does the non functioning servo show any signs of life, like vibrating or getting warm?
The non working servo, is working fine with the orginal 27mhz transmiter/receiver that came with de rc car. In the new circuit with arduino is moving once at 90 degree when I power the circuit, it returns to 0, and not moving on joystick command. The other servo works wonderfully
Any thoughts?
"Any thoughts?"
Below is some simple servo test code that you might use to trouble shoot the servo using the serial monitor.
// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.attach(9);
}
void loop() {
while (Serial.available()) {
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(3);
}
}
if (readString.length() >0) {
Serial.println(readString);
int n = readString.toInt();
Serial.println(n);
myservo.writeMicroseconds(n);
//myservo.write(n);
readString="";
}
}
I have done the tests with both servos. When I have opened the serial monitor the "not working" servo, made a 90 degree move, and when I have entered de value 10, he slowly returned to position 0, and didnt move until I have closed de serial monitor, and repeated de process. With the "working servo", when I have opened the serial monitor he didn
t move until I have given a command, he made a 90 degree move, and didn`t moved until I have reopened the serial monitor, and repeated de process
I found on net this code and gived a try:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(6);
}
void loop()
{
myservo.write(10);
delay(1000);
myservo.write(170);
delay(1000);
}
The "working servo" is moving left-right, the "non working" doesn`t move at all. OK !!!! If it is a bad servo, why is it working with the standard traxxas receiver?
Just out of curiosity - what size battery are you using?
Can you take some pictures of your project and post them here?
"If it is a bad servo, why is it working with the standard traxxas receiver?"
Well, it is probably not a bad servo if it works with a proper RC setup. You probably have a flawed assumption in your hardware setup. I suspect you do not have good connections and possibly small wires causing too much resistance in the power supplies to the servos. The power supply is also suspect. You are assuming everything in your setup is ok, but it appears not to be. People often use inadequate batteries, small DuPont wire jumpers, and bread boards that do not work well with larger servo current requirements.
Hi. I used for power up the all system 4 battery 18650 serial and paralel with a total of 7.4v and I believe 3000mah. Today I bought 2 new 18650, with 2200mah per battery, conected them for 7.4v, but I got same result. One is working the other one doesn't