Giter Site home page Giter Site logo

encoder-tracker's Introduction

encoder-tracker

Tracks up to four quadrature encoder signals, encoder counts can then be transmitted via SPI to another microcontroller.

Originally developed for the Farmduino controller to offload resource intensive encoder tracking to a seperate microcontroller. The STM32 microcontroller with its general purpose timers are ideally suited to tracking multiple quadrature signals at once.

Communication Protocol

After CS is enabled, slave awaits 8 bit command from master, slave then transfers data of variable length depending on command

Chip select pin D22 (PA0)
CPOL 0
CPHA 0
Master Arduino Mega
Slave STM32
Format 8 bit command byte + (optional data from slave) (MSB first)

STM32 function

STM32 will use its onboard general purpose timers to simultaneously keep track of all 4 encoder signals. Positional information for each encoder will be stored as 32bit signed integer.

Reset Behavior

On a power-on reset, the STM32 will initialize all 4 encoder positions to 0. When a motor moves forward, its corresponding position increments; when the motor reveres, the position decrements.

Position Overflow

In the unlikely case of a positional overflow, (0x7FFFFFFF + 1 or 0xFFFFFFFF - 1), the positional information will wrap around (2,147,483,647 + 1 = -2,147,483,648 and vice versa)

Reset Position Command

The slave will reset the position of selected encoders to zero, encoders are selected by setting its corresponding bit in the most significant 4 bits of the command. No subsequent data is transferred from slave.

Bit 0-3 Bit 4-7
0b0000 bit4 = X1, bit5 = X2, bit6 = Y, bit7 = Z

Read Position Command

The slave will transfer the positional data of selected encoders to the master after the 8bit command. Encoders are selected by setting its corresponding bit in the most significant 4 bits of the command. Positional data for each encoder is 32bit wide so the length of the subsequent data transfer depends on how many encoders are selected. For example, if 1 encoder is selected, 4 bytes will be transferred, if 2 encoders are selected, 8 bytes will be transferred, etc. The order of the transfer is fixed, so X1 will be transferred first then X2, then Y, then Z - any unselected encoders will simply be skipped.

Bit 0-3 Bit 4-7
0b1111 bit4 = X1, bit5 = X2, bit6 = Y, bit7 = Z

encoder-tracker's People

Contributors

cneshi avatar maxwellxia avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

encoder-tracker's Issues

Compiled firmware for flashing

It would be nice if a compiled firmware file (in .hex format) for the Farmduino project is available here. It could be used for flashing the STM32 MCU used in Farmduino board. Thanks in advance.

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.