Giter Site home page Giter Site logo

linux-robot-arm's Introduction

Copyright (c) 2020 Damien Le Moal.

Linux 6-DoF Arm Demonstration

This simple program illustrates how to control servos with a Linux application, using a PCA9685 16-channels I2C PWM controller. The application demonstrated here controls a 6 DoF robotic arm. The servos iused are MG996R.

Compilation

For native compilation, make sure the ncurses library and its development headers are installed. Then simply execute make to compile the program.

Cross compilation is defined for RISC-V no MMU environment. To cross compile, run:

> make CROSS_COMPILE=riscv64-buildroot-linux-uclibc-
  CC main.c
  CC pca9685.c
  CC servo.c
Building demo

Execution

Simply run:

> sudo ./demo /dev/i2c-X

Where /dev/i2c-X is the I2C device file name of the master I2C device to which the PCA9685 controller is attached. To find out which device file to use, the i2cdetect command can be used.

i2cdetect -l
i2c-3	i2c       	i915 gmbus dpd                  	I2C adapter
i2c-1	i2c       	i915 gmbus dpc                  	I2C adapter
i2c-6	i2c       	AUX A/port E                    	I2C adapter
i2c-4	i2c       	CP2112 SMBus Bridge on hidraw0  	I2C adapter
i2c-2	i2c       	i915 gmbus misc                 	I2C adapter
i2c-0	i2c       	i915 gmbus dpb                  	I2C adapter
i2c-5	i2c       	AUX B/port B                    	I2C adapter

In the above example, the I2C master used is a CP2112 chip based USB-to-I2C bridge, represented as /dev/i2c-4. The demo application can list I2C adapters using the -l option.

> ./demo -h
Usage: ./demo [options] <i2c dev>
Options:
    -h: help
    -l: list i2c adapters
    -a <addr (HEX)>: i2c slave address

The demo application has an internal menu to control operations.

./demo /dev/i2c-4
Connecting i2c servo controller at 0x40, 50 Hz on /dev/i2c-4...
Resetting controller...
Moving to initial position...
Command ('h' for help): h

Commands:
    h: Help
    i: Interactive mode. Type servo number
       (0 to 5), then arrow up/down to move
    r: Reset to initial position
    d: Run demonstration
    q: Quit
Command ('h' for help):

Example

This video shows a 6-DoF robot arm in action with a tiny SiPeed K210 RISC-V board used as a host.

The Linux kernel tree for this board is available here, in the branch k210-sysctl-v12. The root FS was built using this buildroot tree.

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.