After the first version of the I2C encoder we collected all the suggestions and we made this new upgraded version!

New features:

Details:

This new version is powered by the PIC16F18345. Respect to the MCU on the first version, it has more GPIO and the EEPROM memory.

The new design of the board support both the standard encoders and the illuminated RGB encoders.

Moreover, there are the castellated holes on all the 4 sides of the PCB, in this way will be possible to connect multiple board by soldering them.

There are also 3 configurable GPIOs organized with the same footprint of a RGB LED. They are called GP1 GP2 and GP3.

But in case you are using the RGB encoder, the configurable GPIOs are only 2: GP1 and GP2.

GPIO configuration:


I2C Adress setting

The I2C Encoder V2 is a I2C slave, it's possible to the set 127 different addresses. All of the 7-bit address can be customized by soldering the jumpers A0 - A6 on the bottom of the board.
When the jumper is open, it means a logic 0. if jumper is shorted it means a logic 1.

The I2C Encoder V2 has I2C pull-up resistors, by default they are not soldered. It's possible to solder two resistors R1 and R2. This must be done in case that the master doesn't have these resistors and must be enabled only one I2C Encoder V2 in a chain. A typical value of this resistors are 4.7k.

Interrupt configuration:

The INT pin is an open-drain output, and it's used to send an interrupt to the master.

The interrupt is active low, and have multiple sources where it's possible to mask.

Interrupt source:

I2C registers:

This is the internal registers accessible on the I2C bus

It's possible to write those register on the fly during the normal operation.

It's possible to confgure several option by setting the registers with the I2C bus. With the GCONF register, it is possible to configure several parameters.
In the configuration, it's possible to set the polarity of the encoder quadrature signals and also to set if the outputof the encoder is X1 or X2.

For reading the rotary encoder movement, there are 4 32bit registers: CVAL, CMAX, CMIN and ISTEP.
All of these 4 registers can be configured to work as 32bit INT or as IEEE 754 floating number, this format can be set in the GCONF register.

Every time the encoder moves one step, the value of the CVAL register is increased or decreased of the value of ISTEP. The direction of the rotation decides if ISTEP is added or subtracted from CVAL.
CMAX and CMIN are used for setting a minimum and maximum thresholds of CVAL. In the GCONF register, there is WRAPE bit. This bit is used to enable or disable a wrap functionality of CVAL when it exceeds from the thresholds.

For example, if i con gure the I2C Encoder V2 as following:

I will have CVAL is incremented of 1 at each rotation step of the encoder. The maximum value that CVAL can reach will be 5 while the minimum is -5.

When WRAPE is set to 1 when CVAL reaches the value of 5, at the next increment CVAL it will be wrapped to -5.
Every time when the encoder is rotated one step and when CVAL touch the thresholds, an interrupt is generated and is possible to read in the register ESTATUS.

Blue and red line are the CVAL values when the encoder is rotate and the WRAPE is disabled
Blue and red line are the CVAL values when the encoder is rotate and the WRAPE is enabled

Encoder push button

The I2C Encoder V2 support also the rotary encoder with the push button. When the push button is pressed an interrupt is generated at the rising and falling edge. 
In this way, it is possible to check when the push button is pressed or released.
There is also possibility to read a fast double push by setting a window time in the register DPPERIOD. 
When a double push is made inside of the DPPERIOD window, an interrupt is generated.
If the DPPERIOD is 0, the double push function is disabled.
All the above interrupt are possible to read in the register ESTATUS, and can be also disabled with the register INTCONFIG.


Fade feature

The I2C Encoder V2 has an auto fading feature. This function can be enabled for the RGB LED integrated on the rotary encoder, or in the PWM output of the GP pins.
There are two registers:

The value you write inside these registers is the step speed of the fading ramp, and it's in ms. If the value is 0, the fade feature is disabled. It means that when the new value of PWM is written, it is immediately updated to the output.
The fading process starts when a PWM value is written. Fading process is complete according to the PWM value you have set. When the internal fade PWM value is the same of the PWM value (it means that when fading is complete), an interrupt will be generated.

Schematic:

We will run a crowdfund campaign when everything is competed!