Updates from November, 2008 Toggle Comment Threads | Keyboard Shortcuts

  • Yury Gitman 11:54 pm on November 30, 2008 Permalink | Reply  

    antisocial cat_ servo prototype 

    Prototype 005
    Materials: PIC16F88, breadboard, servo, pot
    Notes:
    – The servo could keep turning left and right, but I couldn’t control its speed and directions.
    – I found that Arduino has a servo library that is easy to use for controlling servos. So I decided to switch to Arduino board.

    http://vimeo.com/moogaloop.swf?clip_id=2297781&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
    servo test from maze on Vimeo.

    Prototype 006
    Materials: Arduino, servo, breadboard, IR sensor
    Notes:
    – In the very beginning, the range of IR sensor was too small. Thus the servo only moved when I almost touched the sensor. Here I scaled the value of IR sensor from 0-1023 to 0-179.
    Img_1905_2

    – The servo had a problem of drawing too much current.

    Picture_1_3

    – So I did iteration by separating power supply for the servo, but joined the grounds of the two power supplies. I also added decoupling capacitors to stabilize my voltage regulator.

    Img_1911

    Img_1912

    Img_1916

    Img_1917

    http://vimeo.com/moogaloop.swf?clip_id=2391917&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
    prototype_arduino+servo+ir sensor from maze on Vimeo.

    – Here is the code:
    ——————————————————————————————————–
    #include <Servo.h>

    Servo myservo; //create servo object to control a servo
    int sensor = 0;  // analog pin used to connect the sensor
    int motorPin=11;
    int val;    // variable to read the value from the analog pin

    void setup()
    {
      myservo.attach(11);
      myservo.setMaximumPulse(2200);
     
      Serial.begin(9600);           // set up Serial library at 9600 bps
      pinMode(sensor, INPUT);
      //pinMode(relay, OUTPUT);
      pinMode(motorPin, OUTPUT);
      myservo.setMaximumPulse(2000);
      myservo.setMinimumPulse(700);

      Serial.print("Ready\n");
    }

    int getSensor() {
      val = analogRead(sensor);            // reads the value of the potentiometer (value between 0 and 1023)
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)

      val=max(val,5);
      val=min(val,180);

      return val;
    } //end of getSensor

    /*
    int moveFoward() {
      analogWrite(motorPin, getSensor());
      delay(1000);
      digitalWrite(motorPin, LOW);
      delay(1000);
      //digitalWrite(relay, HIGH);
      //Serial.println(getIR());
      delay(1000);
    }

    int moveBackward() {
      analogWrite(motorPin, getSensor());
      delay(1000);
      digitalWrite(motorPin, LOW);
      delay(1000);
      //digitalWrite(relay, LOW);
      //Serial.println(getIR());
      delay(1000);
    }
    */

    void loop()
    {
    /*
        val=getSensor();
        if (val<140){
            val=180;
            myservo.write(val);                  // sets the servo position according to the scaled value
            delay(15);                           // waits for the servo to get there
        }//end of if

      while(getSensor()>30){
        myservo.write(getSensor());
        Serial.println(getSensor());
        delay(15);
      }//end of while
    */
        myservo.write(getSensor());
        Serial.println(getSensor());
        delay(15);

      //moveFoward();
      //moveBackward();
      Servo::refresh();
    }
    ————————————————————————————————-
    – I tried to pause the servo after every time it turns by expanding the delay time of myservo.write(). However, its movement became unpredictable. Then I tried moveFoward() and moveBackward() above, but they didn’t work well either.
    – Another problem I have is the click sound of servo. I was wondering if extreme turning angles like 179 or 180 caused those noise.

     
    • M Bethancourt 8:51 am on December 2, 2008 Permalink | Reply

      Your Servo is probably fine. The USB Over Current notice means that there is a short somewhere in your circuit.

    • M Bethancourt 8:53 am on December 2, 2008 Permalink | Reply

      ps
      That’s a damn cute anti-social cat you’ve got up there.

  • Yury Gitman 8:03 pm on November 30, 2008 Permalink | Reply  

    How May I Help You?: Code 

    The code is very simple.  Take a look by clicking the following link.

    (More …)

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel