Friday, 6 November 2015

Prototype Control System: Complete

This is the documentation for the custom animatronic control system:

Hardware:

Arduino
Wires
Servo
R.C Control
2 x Relay
Potentiometer

Script:

#include <Servo.h>

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

int pos = 0;    // variable to store the servo position
int sensorValue = analogRead(A2);

int mouthmode=1; //this is remote control      2 will be auto control
int targpositionservosensor=0;
int currentpositionservosensor=0;


int outcount=0;

void setup()

{
  Serial.begin(9600);
  myservo.attach(A0);  // attaches the servo on pin 9 to the servo object
  pinMode(10,OUTPUT);  //turn OFF for user control --- remember to turn the other off (first)
  pinMode(11,OUTPUT); //turn OFF for arduino control  --- remember to turn the other off (first)
  myservo.write(90);

   digitalWrite(11,HIGH);
     digitalWrite(10,HIGH);
     delay(50);
}

//insert old script for mouth controls in mode 1. Use I pod output for audio trigger instead of laptop. set time for interval
//between audio off to relay back to mode 2.  
//  

void loop()
{
  if(mouthmode==1){
    digitalWrite(11,HIGH);
     digitalWrite(10,LOW);
 
   currentpositionservosensor=analogRead(A2);
   targpositionservosensor=analogRead(A2);
   outcount++;
   if(outcount>20000){
     Serial.println("going into mouthmode 2");
    mouthmode=2;
    outcount=0;
     digitalWrite(11,HIGH);
     digitalWrite(10,HIGH);
  }
  }

  if(mouthmode==3){
     digitalWrite(11,LOW);
     digitalWrite(10,HIGH);
      Serial.print("Targ:");
     Serial.print(targpositionservosensor);
      Serial.print(" Current:");
       Serial.println(currentpositionservosensor);
    if(targpositionservosensor>currentpositionservosensor){
   
      pos=pos-1;
       currentpositionservosensor=analogRead(A2);
   
    }
 
     if(targpositionservosensor<currentpositionservosensor){
   
      pos=pos+1;
       currentpositionservosensor=analogRead(A2);
   
    }
 
    //use audio trigger
     if(targpositionservosensor==currentpositionservosensor){
      Serial.println("going into mouthmode 1 - user control");
     mouthmode=1;
   
    }
 
    myservo.write(pos);
    delay(5);
 
  }

  if(mouthmode==2){
   // outcount=0;
     digitalWrite(11,LOW);
     digitalWrite(10,HIGH);
 
  Serial.println(sensorValue);
  delay(1);

  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);
sensorValue = analogRead(A2);
 currentpositionservosensor=analogRead(A2);
 //long r=random(1000);
 outcount++;
  if(outcount>1000){

     Serial.println("going into mouthmode 1");
    mouthmode=1;
    outcount=0;
     digitalWrite(11,HIGH);
     digitalWrite(10,HIGH);
  }


Serial.print("Angle");
Serial.print(pos);
Serial.print(" Sensor:");
Serial.println(+sensorValue);

// tell servo to go to position in variable 'pos'
    delay(70);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {

 //long r=random(1000);
 outcount++;
  if(outcount>1000){
     Serial.println("going into mouthmode 1");
    mouthmode=1;
    outcount=0;
    digitalWrite(11,HIGH);
     digitalWrite(10,HIGH);
  }


    myservo.write(pos);              // tell servo to go to position in variable 'pos'
 
   sensorValue = analogRead(2);
    currentpositionservosensor=analogRead(2);
Serial.print("Angle");
Serial.print(pos);
Serial.print(" Sensor:");
Serial.println(+sensorValue);
 
 
    delay(50);                       // waits 15ms for the servo to reach the position
  }
  }


}

Treatment:

The concept of this control system was to develop a framework that would allow seamless transition between automated control (Arduino programmed control) and manned operation (r.c). The problem that needed to be addressed concerned measuring the angle of the servo in Arduino when the R.C control was initiated as this disconnected the signal from the Arduino control (Relay 1= Arduino Control; Relay 2 = R.C) The operation of the relay system is as a switch between the two control methods however the potentiometer mounted on the servo allows for constant measurement of the servo angle in Arduino. The position of the potentiometer  can then be set as the signal point for the Arduino (auto) control meaning that transition would be smooth between the two control methods, to test this I used a simple 'judder' for the automation and the r.c would then have to switch seamlessly between the quick movements.

This system addresses the issue of seamless transition between automative and manned control frameworks.


(The operation of the system in this format is to recreate autonomous functions associated with human physical/cognitive disorders in this case facial ticks - as outlined in my chapter on embodiment)

Map

There is no icon for r.c transmitter..so I used a joystick symbol instead.



Feelings: I am really happy with how this control system works, it has taken a good while to get it running exactly how I described it in my theoretical work. That said it was certainly worth the effort and will hopefully add further depth to the character. 

Evaluation: It has taken me a while to get in to uni and document this element of the project but everything sort of hit me at once and I needed to attend to more pressing matters as they came into focus. I really think there is a future for high variable systems such as this example in the future of animatronic characters. I think with further refinement and testing a framework can be developed that will bring a whole new dimension to the idea of automation and puppetry. The idea of creating a system that incorporates improvisational elements also gives the character a greater sense of personality and life. I would eventually like to further this system by incorporating more expressional factors into the program loop, this would allow for unpredictability similar to that of working with an animal. 

Analysis: the current situation of the project makes sense, it is nice to be back in uni and working on a few pieces in a study environment. One of the issue I have found doing a masters via research is that it can be a very singular and personal experience. This approach is all very well for concentration and structure but it can become very lonely at times and been back in uni and getting to chat with other pgr students is really nice. 

Conclusion: In conclusion I am really happy with how the control system performs and I think the video makes it really easy to see how the different parts function as a whole. 

Action Plan: The action plan is to new get the project over to uni and take things from there. Once the mechanical parts are secured at uni I will be able to program and adapt things from there. I think doing all this in uni is the best way of going about this process as I also have access to work books and my tutor is close by if I get stuck at any stage. Doing this at home would be a little more difficult as at times it can be hard to sort of explain what I am trying to achieve with the scripture over email in comparison to in person. Plus it is a lot simpler to deal with any errors when you have a second pair of eyes looking over what you are typing. 

No comments:

Post a Comment