element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
Arduino
  • Products
  • More
Arduino
Arduino Forum Servo control with Firmata: different response than using the Servo library
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 4 replies
  • Subscribers 391 subscribers
  • Views 678 views
  • Users 0 members are here
  • firmata
  • robotics
  • control
  • movement
  • servo
  • servo_driver
  • arduino
Related

Servo control with Firmata: different response than using the Servo library

balearicdynamics
balearicdynamics over 10 years ago

I have a function to control the move of a couple of servos. This function - almost the same - has been written for Arduino and in Java using Firmata. The problem is that when the function runs inside a sketch the servo makes all the available path (between 0 and 120 Deg) while when the same calls (a servo write to the connected pin) passing through Firmata the servo accept all the values in sequence but follow only the path. The effect is that from Firmata the movement seems that 160 steps only moves the servo for 90 Deg.

 

The strange that happens is that this occur only with one of the two servos while calling the function (I mean the same code) with the second servo the problems does not occur. Obviously when I upload the sketch again on the Arduino board both servos works as expected.

 

I am suing the digital write value in Deg to the servo pin and I have not tried to use the write millis alternative - as it is more precise and the movement can be controlled better - because I have not found a similar method to manage the servos from Firmata library.

 

The two servos are exactly the same and for your information I attach the datasheet. The servo is powered by a regulated external source +5V to avoid any interference with the Arduino power line and give the sufficient power to the engine.

 

Thanks in advance to all that has a suggestion.

 

Message was edited by: Enrico Miglino

Attachments:
imageMicroservo-2.pdf
  • Sign in to reply
  • Cancel
Parents
  • balearicdynamics
    balearicdynamics over 10 years ago

    Update to the post

     

    I have done more tests and discovered that the strange thing (occurring on one of the two identical servos only) is that when it is connected with the Arduino board the servo has differente orientation than when it is controlled by Firmata. In both cases it works anyway:

     

    1. position the middle of the servo to the middle reference point with Arduino sketch loaded.
    2. make a different steps sequences full-scale from left to right and vice-versa. All works fine.
    3. upload Firmata to the Arduino
    4. power-on the board from the PC pogram (java controlling firmata on Arduino
    5. the mid point is shifted and there is no way to get a correct orientation
    6. physically unscrew the servo shaft holding the component and put if again in the new mid-point
    7. test the same rotation (left-right-left) and all works fine.: the servo has a new mid point and new min and max limits

    ??? Someone has an idea of this behaviour ???

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • balearicdynamics
    balearicdynamics over 10 years ago

    Update to the post

     

    I have done more tests and discovered that the strange thing (occurring on one of the two identical servos only) is that when it is connected with the Arduino board the servo has differente orientation than when it is controlled by Firmata. In both cases it works anyway:

     

    1. position the middle of the servo to the middle reference point with Arduino sketch loaded.
    2. make a different steps sequences full-scale from left to right and vice-versa. All works fine.
    3. upload Firmata to the Arduino
    4. power-on the board from the PC pogram (java controlling firmata on Arduino
    5. the mid point is shifted and there is no way to get a correct orientation
    6. physically unscrew the servo shaft holding the component and put if again in the new mid-point
    7. test the same rotation (left-right-left) and all works fine.: the servo has a new mid point and new min and max limits

    ??? Someone has an idea of this behaviour ???

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • screamingtiger
    screamingtiger over 10 years ago in reply to balearicdynamics

    Have you put an oscilloscope on the PWM out pins to see what PWM you are reading?

    Typically 1.5ms it the mid point and 1 to 2 is the min/max.

     

    Different software may define that differently.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to screamingtiger

    Hi Joey, thank you for the response. Sorry if I have not put this discussion as a question but I have no idea on how I can correct it after posted image

     

    I have no oscilloscope so I can't do this test, not in moments. But the consideration is correct, and this may depends just on this factor. What sounds strange to me - I had not yet had time to inspect in depth the firmata code but will do for sure in next days - but what sounds strange is that in both cases it is always the same hardware to control them. Not only but I supposed that Firmata also uses the servo library as it is used by the sketch. The difference is that I see possible if that Firmata may use the servoMillis instead of the bare movement of the bare digitalWrite to the servo pins.

     

    Beside this I am asking to my self if the servos can only moved by 1 deg at a time or it is possible to send more previse and small values (e.g. tenth of degrees).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • screamingtiger
    screamingtiger over 10 years ago in reply to balearicdynamics

    What servos are they?  The amount they can turn in increments is called the "resolution" of the servo.  Some servos have poor resolution and may only turn in 10 degree increments.   Some servos designed for RC helicopter rotors will be very fast and have great resolution.

     

    If you don't have an oscilloscope you can use another arduino .  Hook the PWM pin output to a digital input pin.  A quick sketch and you can have the "pulse" in ms (PWM) spit out the serial port.

    If you only have one arduino you'll have to modify the code of the sketch you are uploading to read the PWM.

     

    Let med know if you need a sketch to read PWM I've done it several times!

     

    It will only give you the PWM timing and not the same information as an oscilloscope.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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