GithubHelp home page GithubHelp logo

dawiddwornicki / adapterapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sapieron/adapterapi

0.0 0.0 0.0 6 KB

Provides python-based interface to control Step-motor-adapter-for-RPi

Python 100.00%

adapterapi's Introduction

AdapterAPI

Brief

Bring simple python-based API for interfacing Step Motor Adapter.

This software was developed on Raspberry Pi4 as a host machine.

Tools needed

Software

Hardware

Optional

  • RS232 converter to use as UART master interface if other target board is being used

Instalation

In order to download all neccesary libraries, a build_requirements.txt file has been created. In order to fetch run following command in terminal:

python3 -m pip install -r build_requirements.txt

It is also recommended to update gcc to newest version. On linux-based computers run:

sudo apt-get install gcc

Target port configuration (Raspberry Pi4)

It is necessary to configure your UART port first to be able to send frames.

Raspberry Pi4

As Adapter API is using Terminal /dev/ttyAMA0 add these two lines at the end of your config.txt file:

enable_uart=1
dtoverlay=miniuart-bt

Check official RPi documentation for details and on how to configure UART ports.

NVIDIA Jetson Nano

On NVIDIA Jetson Nano (assuming Jetpack SDK is installed) two steps are required:

  1. execute following three commands:
systemctl stop nvgetty 
systemctl disable nvgetty 
udevadm trigger
  1. Add your user to group dialout. Remember to logout and login for changes to take effect.

Credits:

Available commands

AdapterAPI class has following methods:

General methods

  • CMD_GetCurrentConfig() - Prints current port config to terminal.
  • CMD_CheckConnection() - Sends acknowledgement command and returns true if succedded.
  • CMD_ForceStopAll() - Forces to stop every movement of steppers, servos and pump

Stepper-specific methods

  • CMD_STEPPER_MoveToCoordinate(X, Y, Z) - Moves controlled cartesian coordinate system to specified position for 3 axis'. Takes 3 parameters, each meaning desired coordinate in [mm] of each axis. Parameters must be in range of -9999 to 9999.
  • CMD_STEPPER_Rotate(X, Y, Z) - Rotates stepper motors by a specified number of rotations at the same time. Takes 3 parameters, each meaning desired number of rotations for each axis. Parameters must be in range of -9999 to 9999.
  • CMD_STEPPER_SetCurrentPositionAsZero() - Sets current position of stepper motors to be zeroed. Useful after power-up.
  • CMD_STEPPER_ForceStopMovement() - Forces to stop every movement of steppers. Returns true if succedded, False if not succeeded.

Pump-specific methods

  • CMD_PUMP_RotateForMs(time) - Rotates pump for desired time in [ms]. Parameter must be in range of -9999 to 9999.
  • CMD_PUMP_FeedWater(mililiters) - Turns on water pump to pump desired amount of water in [ml]. Parameter must be in range of -9999 to 9999.

Food-dispenser-specific methods

  • CMD_DISPENSER_Rotate(FoodA, FoodB) - Rotates food dispensers by a set number or rotations. Parameters must be in range of -9999 to 9999.

Example usage

An example.py file has been written to demonstrate usage of all commands available in this library, it can be run as following:

python3 example.py

adapterapi's People

Contributors

sapieron avatar

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.