Difference between revisions of "CRITR/Arm Control gen2"

From Lofaro Lab Wiki
Jump to: navigation, search
(Replaced content with "== hi== == bye==")
Line 1: Line 1:
== hi==
+
=Microcontroller 1=
== bye==
+
* 8 potentiometers are connected, and has id number 1 through 6 of arm(analog pin 3 to 8 respectively)
 +
* Tx of Micro_controller_1 connects to Rx of Micro-controller_2
 +
int pos[8];
 +
char str[16];
 +
char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 +
void setup() {
 +
    Serial.begin(250000);
 +
    delay(100);
 +
}
 +
void loop() {
 +
  int i=0;
 +
  int id = 0;
 +
  for (int i=0; i<8; i++){
 +
    pos[i] = analogRead(i);
 +
    str[id++] = Base_36_Table[pos[i]/36];
 +
    str[id++] = Base_36_Table[pos[i]%36];
 +
  }
 +
  for(int i=0; i<16; i++){
 +
    Serial.write(str[i]);
 +
  }
 +
  Serial.println("");
 +
  delay(80);
 +
}
 +
 
 +
=Microcontroller 2=
 +
* 6 potentiometers are connected, and has id number 7 through 12 of arm(analog pin 1 to 6 respectively)
 +
* Rx of Micro_controller_2 connects to Tx of Micro-controller_1
 +
* Tx of Micro_controller_2 connects to Rx of Micro-controller_3
 +
int pos[8];
 +
char str[40];
 +
char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 +
void setup() {
 +
Serial.begin(250000);
 +
}
 +
void loop() {
 +
  int i=0;
 +
  if(Serial.available()){
 +
    while(Serial.available()){
 +
      str[i++] = Serial.read();
 +
      delay(1);
 +
    }
 +
  } 
 +
  i=0;
 +
  int id = 16;
 +
  for (int i=0; i<6; i++){
 +
    pos[i] = analogRead(i);
 +
    str[id++] = Base_36_Table[pos[i]/36];
 +
    str[id++] = Base_36_Table[pos[i]%36];
 +
  }
 +
  for(int i=0; i<28; i++){
 +
    Serial.write(str[i]);
 +
  }
 +
  Serial.println("");
 +
  delay(80);
 +
}
 +
 
 +
=Microcontroller 3=
 +
* This Micro-controller connects to field computer using FTDI-device
 +
* 6 potentiometers are connected, and has id number 13 through 18 of arm(analog pin 1 to 6 respectively)
 +
* Rx of Micro_controller_3 connects to Tx of Micro-controller_2
 +
 
 +
  int pos[8];
 +
  char str[40];
 +
  char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 +
  void setup() {
 +
  Serial.begin(250000);
 +
  }
 +
  void loop() {
 +
    int i=0;
 +
    if(Serial.available()){
 +
      while(Serial.available()){
 +
        str[i++] = Serial.read();
 +
        delay(1);
 +
      }
 +
    }
 +
    i=0;
 +
    int id = 28;
 +
    for (int i=0; i<6; i++){
 +
      pos[i] = analogRead(i);
 +
      str[id++] = Base_36_Table[pos[i]/36];
 +
      str[id++] = Base_36_Table[pos[i]%36];
 +
    } 
 +
    for(int i=0; i<40; i++){
 +
      Serial.write(str[i]);
 +
    }
 +
    //Serial.println("");
 +
    delay(80);
 +
  }

Revision as of 17:57, 8 December 2015

Microcontroller 1

  • 8 potentiometers are connected, and has id number 1 through 6 of arm(analog pin 3 to 8 respectively)
  • Tx of Micro_controller_1 connects to Rx of Micro-controller_2
int pos[8];
char str[16];
char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; 
void setup() {
    Serial.begin(250000);
    delay(100);
} 
void loop() {
  int i=0;
  int id = 0;
  for (int i=0; i<8; i++){
    pos[i] = analogRead(i);
    str[id++] = Base_36_Table[pos[i]/36];
    str[id++] = Base_36_Table[pos[i]%36];
  }
  for(int i=0; i<16; i++){
    Serial.write(str[i]);
  }
  Serial.println("");
  delay(80);
}

Microcontroller 2

  • 6 potentiometers are connected, and has id number 7 through 12 of arm(analog pin 1 to 6 respectively)
  • Rx of Micro_controller_2 connects to Tx of Micro-controller_1
  • Tx of Micro_controller_2 connects to Rx of Micro-controller_3
int pos[8];
char str[40];
char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void setup() {
Serial.begin(250000);
}
void loop() {
  int i=0;
  if(Serial.available()){
    while(Serial.available()){
      str[i++] = Serial.read();
      delay(1);
    }
  }  
  i=0;
  int id = 16;
  for (int i=0; i<6; i++){
    pos[i] = analogRead(i);
    str[id++] = Base_36_Table[pos[i]/36];
    str[id++] = Base_36_Table[pos[i]%36];
  }
  for(int i=0; i<28; i++){
    Serial.write(str[i]);
  }
  Serial.println("");
  delay(80);
}

Microcontroller 3

  • This Micro-controller connects to field computer using FTDI-device
  • 6 potentiometers are connected, and has id number 13 through 18 of arm(analog pin 1 to 6 respectively)
  • Rx of Micro_controller_3 connects to Tx of Micro-controller_2
 int pos[8];
 char str[40];
 char Base_36_Table[36] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 void setup() {
 Serial.begin(250000);
 }
 void loop() {
   int i=0;
   if(Serial.available()){
     while(Serial.available()){
       str[i++] = Serial.read();
       delay(1);
     }
   }
   i=0;
   int id = 28;
   for (int i=0; i<6; i++){
     pos[i] = analogRead(i);
     str[id++] = Base_36_Table[pos[i]/36];
     str[id++] = Base_36_Table[pos[i]%36];
   }  
   for(int i=0; i<40; i++){
     Serial.write(str[i]);
   }
   //Serial.println("");
   delay(80);
 }