Go Down

### Topic: Master Slave Robot Troubles (Read 741 times)previous topic - next topic

#### 13walkec

##### Oct 31, 2016, 08:53 pm
Hello All.

Quick background.   I'm working for my universities Research and Development Lab, we currently have a master slave robot that students have been working on for the past 4 or 5 years.  This wouldn't normally be a problem but the class that works on it is a semester long class so basic math tells me that there have been at least 8 different groups that have worked on this robot.  Needless today its not functional and its my job now to get it back to a state that the next group can focus on the "fingers" of the machine (the part that they can use to pick stuff up).  So I am re-wiring the robot and writing the code to get it to move in the X, Y, and Z axis based on the orientation of the slave robot.

Any way I have two of the three joints working and now I'm stuck on the rotational axis.  The problem I'm running into, or at least the problem I think I'm having is that the rotational axis has a continuous potentiometer and the pot that I am using to control it isn't a continuous pot.

The base only moves about 4 to 5 degrees in either direction.  Now if I hold the master pot at 1024 for a little bit the master will eventually "break away" from that narrow movement of 4 to 5 degrees and swing full 360 until it reaches that same 4 to 5 degree section again.

I'm watching the Serial Monitor and while the robot is swinging around it passes the value the master pot is as but keeps going and doesn't stop like it is supposed to.

When the slave robot is in that 4 to 5 degree sweep it goes from 0 to 1024 on the serial monitor, so that is why I think it is because of the continuous pot.  below is code

Code: [Select]
`int xpot = A2;int xvalue = 0;int mastx = A3;int mastxvalue = 0;int pwm2 = 10;int dir2 = 8;int xvalue1 = 0;void setup() {  // put your setup code here, to run once:  Serial.begin(9600);  pinMode(pwm2,OUTPUT);  pinMode(dir2,OUTPUT);}void loop() {  // put your main code here, to run repeatedly:  xvalue = analogRead(xpot);  mastxvalue = analogRead(mastx);  Serial.print(xvalue); Serial.print("\t"); Serial.println(mastxvalue);  delay(1);  if (xvalue < (mastxvalue))  {    analogWrite(pwm2,100);    digitalWrite(dir2,LOW);    }    else if(xvalue > (mastxvalue))    {      analogWrite(pwm2,100);      digitalWrite(dir2,HIGH);      }      else if (xvalue == (mastxvalue))      {        analogWrite(pwm2,0);        digitalWrite(dir2,LOW);        }        else;}`

#1
##### Oct 31, 2016, 09:13 pm
Get rid of the extra ( ) around mastxvalue, and the extra else;
Code: [Select]
`if (xvalue < (mastxvalue))else if(xvalue > (mastxvalue))else if(xvalue == (mastxvalue))  >> this has to equal just 1 number from 0 to 1023,  maybe broaden it to allow mastxvalue +/-5 or 10, and take away the same from the others?if (mastxvalue <=5){ mastxvalue = 5;} // keep it from going negativeif (mastxvalue >= 1018){ mastxvalue = 1018;} // keep it from going too positiveif( (xvalue <= (mastxvalue-5)) ||  { // so can't compare to less than 0else if(xvalue >+ (mastxvalue+5)) { // so can't compare more than 1023else if( (xvalue >= (mastxvalue+5)) || (xvalue >= (mastxvalue-5)) { // 5 to 1018 range`
Or something like that.

Don't need this
else;

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up