NGConnect and Encoders

Important thing I forgot to include in program archive is encoders firmware, which has been tested with ATTINY2313. It allows to connect up to 6 encoders of 2 different types: standard and gray code. The first type also requires hardware debouncing.

Download encoders firmware here

You will need Atmel studio and your favourite programmer to upload firmware to device (Google says, that you can also use Arduino board for device programming – I’ve never tried that). This firmware is intended to be used with 16Mhz crystal, so the fuses to be used are:

LOW 0xFF
HIGH 0xDF
Extended 0xFF

Below is drawing with generic ATTINY2313 circuit and one encoder connected (without debouncing circuit). Standard and gray code encoders are connected the same way.

tiny2313-encoders

As seen from schema tiny uses serial method to communicate with Arduino. Tiny’s RX goes to Arduino TX and TX goes to RX. Do not use RX0/TX0 on Arduino (they are used for USB connection).

In module configuration put serial port number (1-3 for Mega2560) into Serial Field.

Type field must contain 8-bit integer value. Each of the first 6 bits is for single encoder. 1 means gray code, while 0 is for standard type. The first encoder is in the least significant bit. For example, 0b00000010 means, that 2nd encoder is gray code and you have to put 2 in Type field. Other example: 0b00100010 means, that 2nd and last encoders are gray code, so that you have to put 34 in Type field.

encoder-type-graphics

Encoder offset pin mapping (ATTINY2313):

PB0 – PD6 0
PB1 – PD5 1
PB2 – PD4 2
PB3 – PD3 3
PB4 – PD2 4
PB5 – PB6 5

One of the future updates will also include gray code type variable, which will allow to connect encoders of this type directly to Arduino.