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
Electronic Toys
  • Challenges & Projects
  • Project14
  • Electronic Toys
  • More
  • Cancel
Electronic Toys
Blog ARBot #2 : Connecting the Angle Sensor to the Servo Motor
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Electronic Toys to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dubbie
  • Date Created: 28 Aug 2019 4:33 PM Date Created
  • Views 2160 views
  • Likes 10 likes
  • Comments 7 comments
  • mkrzero
  • bn0055
  • mkr zero project
  • ai
  • ai project
  • augmented reality
  • electronictoych
Related
Recommended

ARBot #2 : Connecting the Angle Sensor to the Servo Motor

dubbie
dubbie
28 Aug 2019
image

Electronic Toys

Enter Your Electronics & Design Project for a chance to win a Grand Prize of a SNES Classic and $200 Shopping Cart of Product!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

 

The next step in my augmented reality for the Project14 electronic toy challenge, after checking that I do seem to be able to display the Pixy cam processed image onto a display, is to create a headset that will detect rotation and tilt and transfer that information to the servo motors controlling the pan and tilt of the Pixycam.

 

To confirm that all the parts seem to be working and to obtain some feel for the way the system will operate I have just used one output from the rotation sensor connected to one servo motor. The sensor I am using is a BN0055 IMU from Adafruit and to start with I am only using the X rotation angle which varies between 0 and 360 degrees. The particular servo motor I am using rotates in the opposite direction to the value provided by the sensor so I have just subtracted the sensor value from 360 to create an angle that matches the servo motor direction. Also, the servo motor will only rotation 0 to 180 degrees so for a quick fix I have just limited the value sent to the servo motor to 180 degrees if the sensor rotation angle is greater than 180 degrees. This does create a problem in that the sensor produces angles continuously where 0 is adjacent to 360 degrees and is a modulo 360 value. This means the servo suddenly changes from 180 degrees to 0 degrees when rotating past 360 degrees. I'll have to think how best to fix that problem.

 

I have used the example program provided by Adafruit for their sensor so there is nothing much special about it. I have listed the statements converting sensor angle to servo angle below.

 

while (1)
  {
    imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);

  /* Display the floating point data */
    Serial.print("X: ");
    Serial.print(euler.x());
    servo_angle = 360 - euler.x();
    Serial.print(" Servo: ");
    Serial.print(servo_angle);
    Serial.print(" Y: ");
    Serial.print(euler.y());
    Serial.print(" Z: ");
    Serial.println(euler.z());
//    Serial.print("\t\t");

    if (servo_angle > 180) servo_angle = 180;
    scan_servo.write(servo_angle);

 

I will need to calibrate the servo motor as currently it only rotates between 20 and 122 degrees in order to avoid entangling with bits of the mobile robot chassis. As I will have to make a better two axis servo motor mechanism at some point I didn't bother messing about with it currently.

 

Below is a video showing this first stage of testing which I hope the system working mostly. There does seem to be some problem with the calibration of the BN0055 sensor as the angle does seem to change for some reason I have not yet identified. I will have to do some more tests on it.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Dubbie

  • Sign in to reply

Top Comments

  • DAB
    DAB over 6 years ago +3
    Nice test. It looks like the servo tracked well with the sensor translation. Have you calculated the accuracy that you need or are you just going with rough correlation? Cool project. I look forward to…
  • DAB
    DAB over 6 years ago in reply to dubbie +3
    Hi Dubbie, You might want to try putting some paper cylinders around the ultrasonic sensor. That will narrow its field of view so you only get reflection back from what is specifically in front of it.…
  • genebren
    genebren over 6 years ago +2
    Dubbie, Nice update on your project. It is pretty cool how you can control the camera position from your tilt sensor. Perhaps you could steer both your camera and robot platform in response to the tilt…
  • clem57
    clem57 over 6 years ago

    Your demo was kind of moving for me.image Keep up the great blogging. I am enjoying this a lot.

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 6 years ago in reply to dubbie

    Hi Dubbie,

    You might want to try putting some paper cylinders around the ultrasonic sensor.

    That will narrow its field of view so you only get reflection back from what is specifically in front of it.

    Since you are scanning anyway, it should improve your detection performance.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 6 years ago in reply to DAB

    I'm mostly going with the try and see approach. I have done some measurements and these indicate that the yellow Lego man is probably only detectable within a maximum distance of about 60 - 70 cm, so not a great range. This makes the angles on the camera much larger and therefore much simpler to implement. What I am not sure about is the lag between the camera and the headset, as well as jitter in the servo movements. I have thought of implementing a smoothed acceleration/deacceleration element into the control of the servo motors (it's something like arcsine or asine or splines or something, using a lookup table.) I have done this before and it does produce really smooth servo motor movements, but it will be if time permits. I would rather have a jittery, unreliable but complete sort-of-working system than superior sub-systems not fully integrated together.

     

    Dubbie

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 6 years ago in reply to genebren

    Gene,

     

    I did think of trying to combine the two types of control (camera positioning and mobile robot control) into the AR headset, but it just seemed a step too far, so I'm sticking to just controlling the camera. Thinking some more about this this morning, I might even not have time to implement control of the mobile robot and I might have to make it follow a pre-planned path, probably a straight line through the environment, as there is much to do and little time to do it in. A bit like work, but different, as being retired, if I don't want to do, I just go outside and sit in the sun, because there's always tomorrow.

     

    Dubbie

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • three-phase
    three-phase over 6 years ago

    This is a great demonstration of the movement Dubbie. Really looking forward to see how you get on with the rest of the build.

     

    Kind regards.

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