Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Help with this!

  1. #1
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Help with this!

    Alright, I've got this program down pat for my servo controller:

    Code:
    // Controlling a servo position using a temperature sensor 
    // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 
    // edited 5-12-2010 by Will Lyon to include base setting for servo if voltage not detected on pin 7
    
    #include <Servo.h> 
    #define CONTROL 7
    
    Servo myservo;  // create servo object to control a servo 
     
    int temps = 0;  // analog pin used to connect the temp sensor
    int val;        // variable to read the value from the analog pin
     
    void setup() 
    { 
      pinMode (CONTROL, INPUT);  // sets the control pin to input
      myservo.attach(9);         // attaches the servo on pin 9 to the servo object 
       
    } 
     
    void loop()   
    {
      val = digitalRead(CONTROL);             //read input of pin 7 and store it
      if (val == HIGH){                       // reads whether or not 5v is present on pin 7, if 5v present, continue:
      val = analogRead(temps);                // reads the value of the temp sensor (value between 0 and 1023) 
      val = map(val, 350, 700, 75, 105);      // scale it to use it with the servo (value between 0 and 180) 
      myservo.write(val);                     // sets the servo position according to the scaled value 
      delay(25);                              // waits for the servo to get there 
    } else {
      if (val == LOW);                        // if no voltage present on pin 7, continue
      myservo.write(50);                      //sets servo position to 50 if no voltage is detected on pin 7
    }
    }
    when I take power away from pin 7 the servo is to go to a preset position. It does this, but it jitters before it goes. once its there its ok. anyone have any ideas?

  2. #2
    If you can't hack it, you don't own it! Oneslowz28's Avatar
    Join Date
    Mar 2007
    Location
    Aiken, Sc
    Posts
    5,084

    Default Re: Help with this!

    Its not in the code. Is it normal servo jitter that you see on some RC servos?

  3. #3
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Help with this!

    it almost seems like it, but that is the ONLY time it does it. It hasn't done it once during normal operation, or even when it's parked at its base point. Only right before it goes to base

  4. #4
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: Help with this!

    Quote Originally Posted by SXRguyinMA View Post
    Alright, I've got this program down pat for my servo controller:

    Code:
    // Controlling a servo position using a temperature sensor 
    // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 
    // edited 5-12-2010 by Will Lyon to include base setting for servo if voltage not detected on pin 7
    
    #include <Servo.h> 
    #define CONTROL 7
    
    Servo myservo;  // create servo object to control a servo 
     
    int temps = 0;  // analog pin used to connect the temp sensor
    int val;        // variable to read the value from the analog pin
     
    void setup() 
    { 
      pinMode (CONTROL, INPUT);  // sets the control pin to input
      myservo.attach(9);         // attaches the servo on pin 9 to the servo object 
       
    } 
     
    void loop()   
    {
      val = digitalRead(CONTROL);             //read input of pin 7 and store it
      if (val == HIGH){                       // reads whether or not 5v is present on pin 7, if 5v present, continue:
      val = analogRead(temps);                // reads the value of the temp sensor (value between 0 and 1023) 
      val = map(val, 350, 700, 75, 105);      // scale it to use it with the servo (value between 0 and 180) 
      myservo.write(val);                     // sets the servo position according to the scaled value 
      delay(25);                              // waits for the servo to get there 
    } else {
      if (val == LOW);                        // if no voltage present on pin 7, continue
      myservo.write(50);                      //sets servo position to 50 if no voltage is detected on pin 7
    }
    }
    when I take power away from pin 7 the servo is to go to a preset position. It does this, but it jitters before it goes. once its there its ok. anyone have any ideas?
    Code:
    // Controlling a servo position using a temperature sensor 
    // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 
    // edited 5-12-2010 by Will Lyon to include base setting for servo if  voltage not detected on pin 7
    
    #include <Servo.h> 
    #define CONTROL 7
    
    Servo myservo;  // create servo object to control a servo 
     
    int temps = 0;  // analog pin used to connect the temp sensor
    int val;        // variable to read the value from the analog pin
     
    void setup() 
    { 
      pinMode (CONTROL, INPUT);  // sets the control pin to input
      myservo.attach(9);         // attaches the servo on pin 9 to the servo  object 
       
    } 
     
    void loop()   
    {
      val = digitalRead(CONTROL);             //read input of pin 7 and  store it
      if (val == HIGH){                       // reads whether or not 5v is  present on pin 7, if 5v present, continue:
        val = analogRead(temps);                // reads the value of the temp  sensor (value between 0 and 1023) 
        val = map(val, 350, 700, 75, 105);      // scale it to use it with the  servo (value between 0 and 180) 
        myservo.write(val);                     // sets the servo position  according to the scaled value 
      }
      else if (val == LOW){                        // if no voltage present on  pin 7, continue
        myservo.write(50);                      //sets servo position to 50 if  no voltage is detected on pin 7
      }
      delay(25);                              // waits for the servo to get there
    }
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  5. #5
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Help with this!

    no go. I see the change and it makes sense.

    When I take the voltage away, it takes an average of 18 seconds before the servo starts to move to the set position, and it jiggles for about 2 seconds, then goes to its set point. once its there it's still. I'll take a vid and show you

    I took a vid, and of course this time it didn't wait 18 seconds, but it did the same jitter lol. I'm uploading it now

  6. #6
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: Help with this!

    Code:
    void setup() 
    { 
      pinMode (CONTROL, INPUT);  // sets the control pin to input
      myservo.attach(9);         // attaches the servo on pin 9 to the servo  object 
       digitalWrite(CONTROL, LOW);     // ensure internal pullup resistor is disabled.
    }
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  7. #7
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Help with this!

    hasn't changed a thing - vid is processing

    :EDIT:
    had it twitch on me once while the 5v signal was unplugged. it shouldn't move at all

  8. #8
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: Help with this!

    Circuit diagram please
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  9. #9
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Help with this!

    alright here's the vid. It's still processing so it may be a few. It starts with the signal wire unplugged. when I plug it in, the servo instantly goes to wherever the temp reading puts it. when I unplug it, the temp sensor still controls it for 10-20 seconds, then it jiggles and goes to the set position


  10. #10
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Help with this!

    Quote Originally Posted by crenn View Post
    Circuit diagram please
    as you wish


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •