troubleshooting ideas

Hi,

Im trying to build a homing robot using this project as a guide.

But i cant make it work as it should, and im trying to figure out what is wrong for about 2 weeks now, so im out of ideas and i hope someone here can come up with something new.

Ive build all the components like in the guide, antenna, antenna curcuit (that connects to the walkie talkie receiver) and tested them (working as they should).

What i did differantly is that im not using the Boe-bot chassis, ive build my own (from wood) and connected all of the components using a breadboard and arduino UNO to power the two 360 servos (with external power supply so it wont draw power from the arduino).

After calibration the robot searches the signal (spins around itself as in the video) but when i turn on the transmitter walkie talkie the robot starts to drive in a random direction.

If anyone have any idea what the hell im doing wrong i’ll appreciate it if you share it with me.

I’ve posted a more specific question in the general electronics forum, but this might be more productive in finding a solution.

Tnx!

Did you write your own code or use the code provided?

Used the code provided.

simondo:
I've posted a more specific question in the general electronics forum,

Don't double post - it just wastes time and annoys people

If you have a complex project that won't work you will have to reduce it to something simple that does work and then add back the other pieces one at a time. This probably means writing a series of short programs to try out different parts on their own.

Think about the process the original developer used to get the complete project together.

...R

The first post was a specific question about, how to ground a pin and this topic is a general question for what might be wrong with the robot i made, so i don't think its a double post.

If so i apologize.

Any way, i took the antenna-circuit-walkietalkie assembly to electronics technician and checked it, looks like the parts assembled and working the way it should on its own (without the Arduino).

That's why im asking for ideas what could be wrong here because im all out of them, and the guy who made the project is unable to respond to questions for the next 6 months.

I'll probably try to make a similar code but using 2 LED's to indicate the direction of the transmitter, to make it a bit simpler but i don't see how i can simplify it any further because the antenna assembly supposed to work as a single unit. So im left with 3 basic part the assembly, the Arduino and the servo motors, i can exclude only the servos.

As i asked at the beginning of the post, im looking for any idea what can be wrong.

simondo:
As i asked at the beginning of the post, im looking for any idea what can be wrong.

The short answer is "I don't know".

There is far too much stuff to read in that project link you posted. It would be like trying to build the project myself.

You say there is a separate "antenna-circuit-walkietalkie assembly".
How does that interact with the Arduino?
Can you write a short program just to check that the Arduino is receiving (or sending - which is it?) messages correctly.

...R

PS Having all the info about one project in a single Thread is usually best because it allows readers to see everything easily. If you look through the Forum you will find any amount of questions where the problem was nothing like what the OP thought it was and partial data led to a long and pointless discussion.

Basically it works like this:

  1. There is a transmitting walkietalkie that acts as home base

  2. The antenna assembly works as the receiver

  3. The antenna assembly is connected to the arduino, where the arduino powers the assembly and acts as the controller for the servos.
    Pin 8 supposed to power the antenna in a cycle, simulating a rotating antenna

This is the original code:

//Code written by Warner K. of www.robowarner.com
//Made for the Radio Direction Finding Robot at www.robowarner.com/robot/rdfbot
//You are free to modify, distribute and store this code. 
//
//USE THIS CODE AT YOUR OWN RISK!
//I am NOT liable for any harm that results from the use of this code. 
//
// Code is based off of the original BASIC for the robot, so it has room for improvement. :)

//Defines (Constants)
#define buffering 25 //what counts as straight ahead? If too small, the robot will jitter. If too large the robot will drive away from the transmitter
//pinout
#define ANT_WAVEFORM_OUT 8 // set output pin
#define SPEAKER_FROM_WALKIETALKIE A1 //set input pin
#define CALIBRATE_IN 11
#define SERVO1pin  9
#define SERVO2pin  10

//Variables
uint16_t caliset = 0;
uint16_t voltage = 0;


//includes
#include <EEPROM.h>
#include <Servo.h> 

Servo servo1;  // create servo object to control a servo 
Servo servo2;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 

//start program
void setup() {
analogReference(DEFAULT);
servo1.attach(SERVO1pin);  // attaches the servos
servo2.attach(SERVO2pin);  
Serial.begin(9600); //begin serial monitor output, remove if you don't want it
delay(15000); // I put this delay here so the robot won't move until the walkie talkie has had time to turn on.
pinMode(ANT_WAVEFORM_OUT, OUTPUT);
pinMode(SPEAKER_FROM_WALKIETALKIE, INPUT);
pinMode(CALIBRATE_IN, INPUT);
digitalWrite(CALIBRATE_IN, HIGH); // enable internal pullup resistor

//read calibration word from EEPROM
byte HByte =  EEPROM.read(1);
byte LByte =  EEPROM.read(2);
caliset = word(HByte, LByte);
Serial.print("EEPROM Calibration number: ");
Serial.print(caliset);
Serial.println(" If you haven't calibrated yet, you need to for it to work");

if (digitalRead(CALIBRATE_IN) == LOW){ // used for calibrating
delay(15000); // a wait so you can back away from the robot while it is calibrating
}
}

void loop(){
digitalWrite(ANT_WAVEFORM_OUT, HIGH);  //output antenna switching waveform
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, LOW);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, HIGH);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, LOW);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, HIGH);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, LOW);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, HIGH);
delay(1);
digitalWrite(ANT_WAVEFORM_OUT, LOW);
delay(1);
voltage = analogRead(SPEAKER_FROM_WALKIETALKIE); //read voltage from radio
if (digitalRead(CALIBRATE_IN) == LOW){           //if in calibrate mode, store voltage in EEPROM
caliset = voltage;
byte HByte = highByte(caliset);
byte LByte = lowByte(caliset);
EEPROM.write(1, HByte);
EEPROM.write(2, LByte);
delay(5000);
endprogram();
}

if (voltage > (caliset - buffering) && voltage < (caliset + buffering)) { //drive forward

//motor control code for FORWARD here
//code for a continuous roating servo is included below
servo1.write(180);
servo2.write(0);
}

if (voltage > (caliset + buffering)){ //turn

//motor control code for TURNING here (right or left depends on antenna config.)
//code for a continuous roating servo is included below
servo1.write(180);
servo2.write(180);
}
if (voltage < (caliset - buffering)){  //turn the other way

//motor control code for TURNING the OTHER DIRECTION here (right or left depends on antenna config.)
//code for a continuous roating servo is included below
servo1.write(0);
servo2.write(0);
}
delay(5); //just a simple wait
Serial.print("In, Cal\t");
Serial.print(voltage);
Serial.print("\t");
Serial.println(caliset);
}

void endprogram(){
  Serial.print("Calibrated to: ");
Serial.print(caliset);
  loopy:
  goto loopy;
}

Im not 100% sure how everything works so that’s why im asking help here, maybe someone can figure out where something can get wrong.

PS the project i posted isn’t that long or complicated in its build, most of it is pictures for guide and the rest is a bit of explanations what is going on in the picture.

simondo:
Basically it works like this:

  1. There is a transmitting walkietalkie that acts as home base

  2. The antenna assembly works as the receiver

  3. The antenna assembly is connected to the arduino, where the arduino powers the assembly and acts as the controller for the servos.
    Pin 8 supposed to power the antenna in a cycle, simulating a rotating antenna

That seems to suggest that the only thing the Arduino does is cause the antenna to rotate.

However I suspect it is more complicated. Perhaps you can continue the description so we have all the info.

...R

Hi you have calibrated it right?
Are the values you getting correct?

Well it is getting signals because as you said

but when i turn on the transmitter walkie talkie the robot starts to drive in a random direction.

I need to know how you have mounted your servos, if you could add a pic please because in your code you have the servos turning in the same direction which is wrong but depends how you mounted them.

In the original code on the site there is a error as well with the turning of the servos.

M...........

Robin2:
That seems to suggest that the only thing the Arduino does is cause the antenna to rotate.

However I suspect it is more complicated. Perhaps you can continue the description so we have all the info.

...R

Apart from pin 8 (that cycles the antenna) there is pin A1 that is connected to the positive wire of the speaker, which probably receives the output of the antenna assembly from with the sketch calculates the direction of the transmitter.

Just to put it all together:
There are 5 pins in use, 5v and GND to power the antenna, pin 8 that cycles between the positive and negative wires of each of the dipole antennas and pin A1 that reads the values from the antenna.
Everything else is done by the sketch.

Undermentioned:
Hi you have calibrated it right?

I think so, i did exactly what the guy showed in his video.

Undermentioned:
Are the values you getting correct?

I was really frustrated last time i checked through the serial monitor do i didn't pay much attention, but if im not mistaken i think it looked the same as in the guy's calibration values, i'll check again tomorrow.

About the servos, i'll post a picture as soon as i have the chance, but if you could explain what do you think is wrong with the sketch?

The only difference between my sketch and his, is that i changed the delay value for the calibration (so i have more time to tune to the right channel) and the delay time for when the sketch starts running. Everything else is exactly the same as the original code.

Until i post the photo of the servos i'll explain how i mounted them.
I use 2 MG955 360 servos, they are mounted one on each side of the chassis (the drive shaft sticks to the side) and the wires of the servo are pointing backwards.

But i don't see how the mounting position can effect the behavior of the robot, if i get it right in the worst case (assuming that the sketch isn't wrong) the robot will go to the opposite direction from where it should go.

Hi,
Have you got them mounted so that they turn the same way that the original unit does.
If you have turned a servo upside down, then you will have reversed the way it reacts to commands.

Tom... :slight_smile:

simondo:
Apart from pin 8 (that cycles the antenna) there is pin A1 that is connected to the positive wire of the speaker, which probably receives the output of the antenna assembly from with the sketch calculates the direction of the transmitter.

That sounds simpler than I had imagined.

Am I correct in thinking that pin A1 gets an analog signal whose amplitude guides the program to adjust the direction of the antenna.

Can you write a short program to print the analog values on the Serial Monitor and see how they vary when you turn the antenna manually?

...R

ok

You can try something like this to see where it wants to go when you turn your antenna :

if (voltage > (caliset - buffering) && voltage < (caliset + buffering)) { //drive forward

Serial.print("Forward");
Serial.println();

}
if (voltage > (caliset + buffering)){ //turn

Serial.print("Turn left");
Serial.println();

}
if (voltage < (caliset - buffering)){  //turn the other way

Serial.print("Turn Right");
Serial.println();
}

If you are not getting any information then you will have to do as robin said and serial print your variables values to see what they are.

You can do something like this :

ResultMinus = (caliset - buffering);
ResultPositive = (caliset + buffering);

Serial.print("ResultMinus");
Serial.print(ResultMinus);
Serial.println();
Serial.print("ResultPositive");
Serial.print(ResultPositive);
Serial.println();
Serial.print("voltage");
Serial.print(voltage);
Serial.println();
delay(200);

M…