Code Monkey home page Code Monkey logo

servoproject's Introduction

ServoProject

by Adam Bäckström

Getting the most out of your hobby servo

Robot

Video demo of project

Demo video

Additional documentation for the project

Theory

Dependencies

Build instructions

Legacy build instructions

Project structure

ArduinoSketch

This folder contains the Arduino project for the Adafruit ItsyBitsy M0 Express boards.

Easiest way to program and configure the servos is through the configurationWizard.py script. Just run python3 ./ArduinoSketch/configurationWizard.py to get started. The script will ask if it should install any missing dependencies.

PLEASE NOTE! Windows users must use MSYS2 due to the the PyGObject package, see https://pygobject.readthedocs.io/en/latest/getting_started.html. After installing MSYS2 run the script with:

C:\msys64\mingw64\bin\python.exe ArduinoSketch\configurationWizard.py

Manually compiling the Arduino sketch

When compiling, the active configuration is selected by modifying the #include "*.h" line in the config/config.h file to include the desired config file. The configSelector.py script can be used to simplify the config selecting process by giving a drop-down list with all configs in the config folder.

The folder also holds a Makefile which can be used to compile and transfer the project. One benefit of using the Makefile is that the configSelector script is always executed prior to compiling. To be able to use the Makefile you must first install arduino-cli.

Arduino sketch dependencies:
  - Adafruit DotStar `source:` Arduino Library List
  - Eigen `source:` Arduino Library List

ArduinoLibrary/ServoProjectController

Arduino library for communicating with the servos.

View Example Arduino sketch

C++/Library

Holds the C++ library for communicating with the servos.

Dependencies:
  - GNU Make >= 4.2.1
  - gcc >= 9.3.0
  - boost >= 1.71.0

C++/Demo

Minimal c++ demo project.

View Example Code

C++/Example6dofRobot

Example 6dof robot project.

View Example Code

To compile run make. This creates the program ./executable with the following options.

Allowed options:
  --playPath            play the path defined in createPath()
  --gui                 open jogging gui
  --output arg          data output file
  --simulate            simulate servos

Dependencies:
  - Eigen >= 3.4.0
  - gtkmm-3.0 >= 3.24

CadFiles

Holds all .stl and the original Freecad files

PcbDesignes

Holds all KiCad projects for the electronics

Python/Demo

Python demo project.

View Example Code

Python/ServoProjectModules

Holds all python modules for the project.

Communication bus setup for demo projects

ONLY CONNECT THE SERVO TO 3.3V LOGIC!!!!

Robot

PLEASE NOTE! The bus controller needs to have a low latency to get fast communication with the servos. Most standard USB to Serial converters buffer the data and only transfers every 10 ms or so. This becomes a problem since the communication protocol will wait for the response from each servo before moving on to the next, adding huge delays.

To get the best communication speed it is recommended to use an "Adafruit ItsyBitsy M0 Express" (or similar ARM based Arduino) as the USB to Serial converter. Just program the Arduino with the usbToSerial.h configuration in the ArduinoSketch to get started. In usbToSerial.h you can also configure any regular servos you want to control together with the ServoProject modified ones.

How to switch to PWM interface version

ONLY CONNECT THE SERVO TO 3.3V LOGIC!!!!

Using the PWM interface is not recommended due to low resolution and high noise, but it is possible by modifying the configuration file. To enable PWM control replace the getCommunicationHandler() function with the version below.

    static std::unique_ptr<Communication> getCommunicationHandler()
    {
        Serial.begin(115200);
        auto com = std::make_unique<Communication>(SerialComOptimizer(&Serial));
        uint8_t pwmPin = 0; // Rx pin, ONLY CONNECT TO 3.3V LOGIC!!!!
        uint8_t controlSpeed = 14;
        uint8_t backlashControlSpeed = 2;
        float scale = 2.0f; // 2 units per us (4096 units == 360 deg)
        float offset = 1024.0f; // move to 1024 units (90 deg) for 1500 us pwm signal
        com->addCommunicationNode(
                std::make_unique<DCServoCommunicationHandlerWithPwmInterface>(1,
                    createDCServo<SetupConfigHolder>(controlSpeed, backlashControlSpeed),
                    pwmPin, scale, offset));
        return com;
    }

License

Open Source License

ServoProject is free software. You can redistribute it and/or modify it under the terms of Creative Commons Attribution 3.0 United States License.

To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/

servoproject's People

Contributors

adamb314 avatar antonevmenenko avatar cydget avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

servoproject's Issues

No current sensor?

What a great project!
I noticed that previous versions had current sensors and corresponding control codes。
However, in the latest version, there is no current sensor on the circuit diagram. However, there is still a current sampling part in the code. Is that right?

Brushed servos

For building the robot you mention to use 3x coreless modified servos + 3x micro modified servos. Brushed servos are not required? Finding ATSAMD21G18A-A at a reasonable price for a custom PCB is very difficult this days. So, can we build the robot just with off the shelf boards?

Accuracy achievable

Hi Adam,
An awesome project. I was looking greater accuracy in servos for my automatic turret. Can you please tell me how accurate are the modified servos in degrees ?

Compatibility with DS3218 servos

Hi adam,

First congratulations for your work, your results with theses cheap servos are really impressive

i'm verry interested in building five of them but before checkout on JLCPB, i would like to have your opinion about the PCB compatibility with DS3218 servos.

i think its ok because the only difference with 3225 servos seems to be height , and obviously the final torque.

what do you think ?

Regards,

Alternative boards and code

Hi
My questions are regarding how to make the servo without custom pcb as given in coreless servo build.
How many boards are required to control 2 servos?
How exactly do we connect the board and use which software ?
And can we use the original potentiometer instead of the magnetic encoder ?

Further explanatory materials anywhere?

Excuse me, this is an absolutely excellent project, but while the documentation is great for using the completed system as you have produced it (great work), it doesn't give a detailed description of th underlying theory. Might you be able to provide some links to where you learnt the excellent PID and control techniques* you've employed here, or otherwise some further description of how the double-encoder feedback loop works (more detailed than the diagram presently shown for comparison to classical hobby servo control loops, but more explanatory that just trying to interpret source code)? Any links on where to learn this stuff and truly undertand it would be really welcome, and could help others in applying the core principles of this brilliant project to a wider variety of servo types and geometries.
Thank you

*particularly how you manage to make a DC motor behave as if it were proportional despite the fact that they typically won't move at all until some threshold PWM level is crossed and then they suddenly start moving quite fast

Does motor polarity matter?

I've gone through all the photos and your videos to see if motor polarity was indicated anywhere but couldn't find it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.