element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Single-Board Computers
  • Products
  • Dev Tools
  • Single-Board Computers
  • More
  • Cancel
Single-Board Computers
Forum control of 360 degree servos
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Single-Board Computers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 12 replies
  • Subscribers 57 subscribers
  • Views 2326 views
  • Users 0 members are here
  • beaglebone_black
  • single-board-computers
Related

control of 360 degree servos

Former Member
Former Member over 12 years ago

Hi

 

i wonder how i would control a 360 degree servos from a python script?

 

there are lot of guides on 180 degree servos

 

most of them from adafruit... have nothing against them but i like to not be dependent on external libs

 

 

i'm going to use this in a fully automatic tracker.... the tracker will be used to track high altitude baloons (30+ km)

 

 

/bo

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 12 years ago

    yes i have....

     

    but the Q is not about the servos... its on how to control it.... ie python code

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to Former Member

    Bo Herrmannsen wrote:

     

    yes i have....

     

    but the Q is not about the servos... its on how to control it.... ie python code

     

    I understand. But you didn't supply enough information to give an answer. Hence the request for that URL.

     

    You can use the same Python code as you would for a 180 degree servo. According to that URL, the pulse width needs to be between 800 and 2200usec for a rotation of 2160 degrees. So, the center position would be at 1500usec pulse width, and if you changed the pulse width by up to +- 116.6 usec then the servo would rotate by +-180 degrees, giving you a controlled rotation of 360 degrees.

    The existing Python code most likely uses values of 1000us to 2000uec to control the servo, with the center being 1.5msec, which matches the calculations for your desired servo (1500usec).

    So, you can continue to use the existing code, but don't instruct the servo to adjust more than +-116.6usec, whereas a normal 180 degree servo would be controlled by up to +-500usec to get the span from 1000usec to 2000usec.

     

    So, the existing Python code/library will work. Just don't expect good granularity.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to shabaz

    ok, what do you mean by excisting code? i have yet to find even that...

     

    i dont want to rely on a librart

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to Former Member

    Without a library, you will need to spend some time  to write your own library for the processor that you've chosen.

    Once you have decided on a processor, you'll need to research what PWM facilities exist for that processor (often there is an integrated peripheral inside the chip) and look up the register config (all this will be in the processor reference guide) and write your own driver/library that will control the PWM based on the custom interface that you may write.

     

    That's just a quick summary of the process; some experience may be needed in writing driver code. You may get lucky and find the config needed to set up the PWM peripheral on the Internet, for your particular processor. Or, you may be able to see the source code of an existing PWM library for your processor and re-write, if you don't want to rely on any existing library.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to shabaz

    processor = Beagle Bone Black

     

    and i dont have the skills to code from scratch

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to Former Member

    Writing a Linux driver for PWM will need some experience. Another way is to use the PRU inside the chip, but that will take some studying too. The latter is not difficult, but expect to spend at least a day or more reading up on it and experiementing before you'll be able to write something useful, and it won't be in Python, but C and assembler. For now, it may be best to rely on the adafruit example code for the BeagleBone Black until you're confident to write a driver.

     

    EDIT: this web page looks very good, it has a Linux PWM driver and a link to the source code, and how to compile the kernel if the built driver is outdated. So, although you'd still be using a driver,  you can see the source code.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to shabaz

    hi

     

    i got back to this.. i opted for the adafruit lib

     

    what excatly do i need to do so i can just tell it a angle between 1 and 360 ?

     

    you said something about "the pulse width needs to be between 800 and 2200usec for a rotation of 2160 degrees" ??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 12 years ago in reply to shabaz

    hi

     

    i got back to this.. i opted for the adafruit lib

     

    what excatly do i need to do so i can just tell it a angle between 1 and 360 ?

     

    you said something about "the pulse width needs to be between 800 and 2200usec for a rotation of 2160 degrees" ??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • shabaz
    0 shabaz over 12 years ago in reply to Former Member

    It means just use approx one fifth of the range, since the span +-116usec is approx one-fifth of +-500usec.

    I've not used the adafruit library or tried to control a servo with the BBB.

    If you library (say) takes a value between 0 and 180 to represent 180 degrees of a normal servo (with a value of 90 being the center), then for your servo you need to use a value between about 72 to 108 to represent 0 to 360 degrees.

    Notice this is not very granular (as mentioned in post#1, it won't be very high-res with such a servo).

    If you wanted it more granular you'd need to delve into the driver code and adapt to use a higher-res PWM (e.g. 10-bit or more) - I don't know what the adafruit library uses.

    Furthermore, even if you did this, I doubt you'd get much better granularity because the servo has hysteresis.

    I suspect getting anything remotely close to 1 degree resolution with that servo will not be possible - I'm just guessing though, I've not tried it.

     

    EDIT: This randomly chosen servo has a dead band specification of 8usec. So, if the pulse width has a possible span of 1000usec for 0 to 180 degrees, you can see that the actual granularity that you can use to position this random servo is not much.. (ok for RC models of course).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube