Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Servo issues - Weird things happening!!

Servo issues - Weird things happening!!

Scheduled Pinned Locked Moved Troubleshooting
mysensorsservo
5 Posts 2 Posters 4.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mouridsen
    wrote on last edited by Mouridsen
    #1

    Hi guys,

    I tried to connect a servo to a Uno board and uploaded the standard sketch ServoActuator.
    It really does some weird things. It's almost like it runs too long to one side. And if I try to e.g. push "open" twice it runs in the other direction instead of to the same side again.
    I have tried to modify the max & min values but it still does the weird things.
    The communication to the gateway is fine and the values from the Vera are received with the correct values.

    It's connected to a 5V adapter and grounded to the Arduino.

    I have uploaded a video to show what's happening:

    http://youtu.be/awpe0I8m-R8

    I have tried to connect the servo motor without the Mysensors sketch and used the Sweep sketch. To make it respond correctly I had to modify the delay value to around 5 in the line:
    delay(15); // waits for the servo to get there
    Otherwise it did something similar.

    Any suggestions?? Hope you can help!

    slartiS 1 Reply Last reply
    0
    • M Mouridsen

      Hi guys,

      I tried to connect a servo to a Uno board and uploaded the standard sketch ServoActuator.
      It really does some weird things. It's almost like it runs too long to one side. And if I try to e.g. push "open" twice it runs in the other direction instead of to the same side again.
      I have tried to modify the max & min values but it still does the weird things.
      The communication to the gateway is fine and the values from the Vera are received with the correct values.

      It's connected to a 5V adapter and grounded to the Arduino.

      I have uploaded a video to show what's happening:

      http://youtu.be/awpe0I8m-R8

      I have tried to connect the servo motor without the Mysensors sketch and used the Sweep sketch. To make it respond correctly I had to modify the delay value to around 5 in the line:
      delay(15); // waits for the servo to get there
      Otherwise it did something similar.

      Any suggestions?? Hope you can help!

      slartiS Offline
      slartiS Offline
      slarti
      wrote on last edited by
      #2

      @Mouridsen Try this sketch I use to test servolimits. Just enter the position (percentage) you want in serial monitor. This will probably tell you if there's something wrong with your servo or if there's a problem with the sketch. I can't test the mysensors example with my TowerPro because my radios still haven't arrived.

      link text

      If this works as expected there's something in the example sketch that doesn't agree with your servo. But try this first.

      "One is never alone with a rubber duck"

      M 1 Reply Last reply
      0
      • slartiS slarti

        @Mouridsen Try this sketch I use to test servolimits. Just enter the position (percentage) you want in serial monitor. This will probably tell you if there's something wrong with your servo or if there's a problem with the sketch. I can't test the mysensors example with my TowerPro because my radios still haven't arrived.

        link text

        If this works as expected there's something in the example sketch that doesn't agree with your servo. But try this first.

        M Offline
        M Offline
        Mouridsen
        wrote on last edited by
        #3

        @slarti Sorry for my late answer! I did try your sketch but it's still the same. I really don't know what the issue can be. I have considered to try buying the motor that's on the mysensors page instead. I don't know what the difference is between the two. Any ideas what I could try with the current motors???

        1 Reply Last reply
        0
        • slartiS Offline
          slartiS Offline
          slarti
          wrote on last edited by slarti
          #4

          Sorry, no idea. I think your servo is faulty somehow.

          Here's my current sketch I use with my fake futaba 3003's which works fine with them. I got some TowerPro MG996R's but they don't move the whole 180 degrees for some reason. Went with the futabas and modified the TowerPros to continuous rotation.

          https://codebender.cc/sketch:79845

          "One is never alone with a rubber duck"

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mouridsen
            wrote on last edited by
            #5

            Just to let you know that I solved the issue.
            I found a library where you can control the speed and make sure it get to it's position.
            You can find it here: https://github.com/netlabtoolkit/VarSpeedServo
            I incorporated it in the Mysensor sketch and it works eventhoug it looks like it only goes like 90 degrees but it's enough for me :

            
            #include <MySensor.h>
            #include <SPI.h>
            #include <VarSpeedServo.h> 
            // #include <Servo.h> 
            
            #define SERVO_DIGITAL_OUT_PIN 3
            #define SERVO_MIN 0 // Fine tune your servos min. 0-180
            #define SERVO_MAX 180  // Fine tune your servos max. 0-180
            #define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
            #define CHILD_ID 10   // Id of the sensor child
            
            MySensor gw;
            MyMessage msg(CHILD_ID, V_DIMMER);
            VarSpeedServo myservo;  // create servo object to control a servo 
                                    // a maximum of eight servo objects can be created 
            // Servo myservo;  // create servo object to control a servo 
                            // a maximum of eight servo objects can be created Sensor gw(9,10);
            unsigned long timeOfLastChange = 0;
            bool attachedServo = false;
                        
            void setup() 
            { 
              // Attach method for incoming messages
              gw.begin(incomingMessage);
            
              // Send the sketch version information to the gateway and Controller
              gw.sendSketchInfo("Servo", "1.0");
            
              // Register all sensors to gw (they will be created as child devices)
              gw.present(CHILD_ID, S_COVER);
            
              // Request last servo state at startup
              gw.request(CHILD_ID, V_DIMMER);
            } 
            
            void loop() 
            { 
              gw.process();
              if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
                 myservo.detach();
                 attachedServo = false;
              }
            } 
            
            void incomingMessage(const MyMessage &message) {
              myservo.attach(SERVO_DIGITAL_OUT_PIN);   
              attachedServo = true;
              if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
                 int val = message.getInt();
                 myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val,255,true); // sets the servo position 0-180
                 // Write some debug info
                 Serial.print("Servo changed. new state: ");
                 Serial.println(val);
               } else if (message.type==V_UP) {
                 Serial.println("Servo UP command");
                 myservo.write(SERVO_MIN,255,true);
                 gw.send(msg.set(100));
               } else if (message.type==V_DOWN) {
                 Serial.println("Servo DOWN command");
                 myservo.write(SERVO_MAX,255,true); 
                 gw.send(msg.set(0));
               } else if (message.type==V_STOP) {
                 Serial.println("Servo STOP command");
                 myservo.detach();
                 attachedServo = false;
            
               }
               timeOfLastChange = millis();
            }
            
            1 Reply Last reply
            2
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            11

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular