Giter VIP home page Giter VIP logo

Comments (2)

sim- avatar sim- commented on September 17, 2024

Hello! The protocol is pretty simple, and is implemented to be compatible with MikroKopter brushless ESCs ("BL-Ctrl") version 1 and 2. You can see host-side implementation here: http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.74d%2Ftwimaster.c

Basically, the input follows the same path as PWM and UART inputs. You need to arm the ESC by sending 0 at power-up at a rate high enough to satisfy the pulse timeout (at least ~20Hz). Then, the simplest control is simply a byte from 0 (off) to 247 (full power). Search for "evaluate_rc_i2c:" to see the bottom half of the i2c interrupt, where the input is processed to form a PWM duty. The protocol version 2 adds a few more bits, three usable, in the second byte, giving you a resolution of about 11 bits, assuming there is enough bandwidth to do so.

Finally, there is some more advanced configuration structure stuff that allows various things to be read and set. The only thing implemented at the moment is reversing the direction of rotation (through MikroKopter Tool).

from tgy.

gurupras avatar gurupras commented on September 17, 2024

Thank you for the links!
With the help of those, I'm able to use the i2c interface to drive motors in one direction. However, I don't quite understand how to send in the second byte to reverse direction..
Currently, I'm using this function from i2c-dev.h
static inline __s32 i2c_smbus_write_byte(int file, __u8 value)

My control loop is structured roughly as follows

while(1) {
    i2c_smbus_write_byte(i2c_dev_fd, cur_speed);
    usleep(1000);
}

Should this 'second byte' just be another i2c_smbus_write_byte() call inside the loop?

from tgy.

Related Issues (20)

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.