Menu

Moving a servo 270deg

2022-01-18
2022-01-20
  • Andrew Wall

    Andrew Wall - 2022-01-18

    Hello,

    I managed to get everything working but the servo will only move a maximum of 180deg. I need it to move 270 deg. When I purchased the DS3218MG servo, I had ordered the 270deg version as I need the flap to rotate to rest against the side of the telescope. When inputting different numerical values from 0 to 270 the motor still only moves to a maximum of 180deg.

    //adjustable variables
    unsigned int openPos = 0; //speed servo opens at
    unsigned int closePos = 270; //speed servo closes at

    Default Values 90 OpenPos and 180 ClosePos only moves the servo 90deg as I would expect.

    Is there a way to test the servo to do it's full rotation of 270deg? I am not convinced I do have a 270deg servo now, there are no markings on the servo besides the voltage and type.

    I had thought of the possibility of a mechanical way to turn 180deg to 270deg but I thought I would try the servo first.

    I have seen this code but not tested yet do you think this would be worth looking at? I noticed the use of VarSpeedServo.h instead of just Servo.h

    #include <VarSpeedServo.h>
    #include <EEPROMWearLevel.h>
    
    #define EEPROM_LAYOUT_VERSION 1 //EEPROMWearLevel Version
    #define AMOUNT_OF_INDEXES 4 //EEPROMWearLevel number of variables to store
    #define EEPROM_LENGTH_TOUSE 1023 //EEPROMWearLevel Max EEPROM address usage
    #define SAVED_COVER_STATE 0 //EEPROMWearLevel Index
    #define SAVED_PANEL_VALUE 1 //EEPROMWearLevel Index
    #define SAVED_BROADBAND_VALUE 2 //EEPROMWearLevel Index
    #define SAVED_NARROWBAND_VALUE 3 //EEPROMWearLevel Index
    
    VarSpeedServo myservo; //create servo object to control servo
    
    const byte lightPanel = 3; //assign to pin
    const byte motor = 9; //assign to pin
    
    //----- USER-DEFINED VARIABLES -----
    long serialSpeed = 9600; //values are (default 9600) 19200 38400 57600 115200 230400
    boolean lightInstalled = true; //true if using EL Panel
    byte maxBrightness = 255; //max brightness level (max:steps between) 17:15, 51:5, 85:3
    
    //adjustable variables
    unsigned int openPos = 273; //Angle at open position
    unsigned int closePos = 3; //Angle at closed position
    long stabilizeTime; //set delay to give light time to settle
    long maxMoveTime = 30000; //30s max time before error reported that panel hasn't completed opening/closing
    

    regards,

    Andrew.

     
  • Nathan Woelfle

    Nathan Woelfle - 2022-01-18

    Hi Andrew,

    Glad to hear you've got your project up and running, for the most part. I also tried initially using a 270 degree of motion servo to get the panel to lay flat but returned it because I found it wouldn't move the entire distance. So for my personal project, I ended up using a 360 servo and installed a couple of reed switches to detect the open and closed positions. I plan to redo this project one day using a stepper motor instead.

    To answer your questions.

    "Default Values 90 OpenPos and 180 ClosePos only moves the servo 90deg as I would expect.

    Is there a way to test the servo to do its full rotation of 270deg? I am not convinced I do have a 270deg servo now, there are no markings on the servo besides the voltage and type."

    You can test using the built-in Servo Sweep example. I don't have a 270 servo to experiment with, but I did a quick search, and according to Arduino, https://forum.arduino.cc/t/270-degree-servo-motor-code/567897, using values between 0 and 180, 180 would be considered 270. So you should still be using 0-180 for the open and close positions.

    "I noticed the use of VarSpeedServo.h instead of just Servo.h"

    You could use the VarSpeedServo library; that'll make the servo move more slowly depending on the values you use. You'll need to add the library and replace Servo myservo; with VarSpeedServo myservo;.

    I hope that helps. Please let me know if there is anything else I can do.

     

    Last edit: Nathan Woelfle 2022-01-18
  • Andrew Wall

    Andrew Wall - 2022-01-19

    Thanks for the reply Nathan, appreciate it. It looks to me I was sent the wrong servo since it will only move 180deg. I am looking into reprogramming the digital servo to see if it is possible to make it do what I want. Not liking my chances but worth a shot. I am actually putting 2 servos side by side so I have two holding the dustcap, but only 1 of them will move the other has a gear removed to act as a dummy servo. Need the extra support for the 8" scope and possibly larger in the future. I will try reprogramming, if that doesn't work I will see about getting a 360deg servo. I guess using a 360deg servo I would be able to get the 270deg by entering something like 135 instead of 180. But I like the idea about using the reed switches as an extra measure. Will see how I go.

     
  • Nathan Woelfle

    Nathan Woelfle - 2022-01-20

    Sorry to hear your existing servo isn't correct.

    "I guess using a 360deg servo I would be able to get the 270deg by entering something like 135 instead of 180."

    Unfortunately, with a 360 servo, it's not as simple as entering in the angle. With a 360, you will have to use sensors or switches to tell the system when to stop.

    "I like the idea about using the reed switches as an extra measure. Will see how I go."

    I used hall sensors instead of reed switches for better reliability. Good luck; let me know if you need help.

     

Log in to post a comment.