Docs
  • Welcome
  • Encoder
    • How to use analog output
  • Super Servo Plus
    • Usage Ideas
    • Motor Graph
  • Barecoder Micro
  • Super Servo (Discontinued)
  • Stagelite
Powered by GitBook
On this page
  • Specs
  • Wiring
  • Code Example
  1. Encoder

How to use analog output

PreviousEncoderNextSuper Servo Plus

Last updated 6 months ago

The melonbotics Encoder offers analog absolute output on the 3-Pin JST port.

Specs

  • Maximum angle error of ±1.0° (Integral Non-Linearity)

  • 12-Bit DAC

  • 5us Propagation Delay

  • Output Range 0V -> 3.2V (when used on at 3.3V)

Wiring

Method 1 (Recommended)

Use the to connect two Encoders to one Control Hub analog port.

Method 2 (Not Recommended)

Splice the included 3-Pin cable, with the included 4-Pin cable to create an adapter. See below diagram for connector pinouts.

Code Example

// Get analog port instance from hardwareMap
AnalogInput encoder = hardwareMap.get(AnalogInput.class, "encoder");

// Simple position return
double position = encoder.getVoltage() / 3.2 * 360;

// Position return with adjustable offset
// Offset must be positive, otherwise the modulo (%) operation breaks
//
// If you want to use a negative offset, just add some multiple of 360 so
// that the offset evaluates to be positive.
double offset = -123.4 + 360;
double offsetPosition = (encoder.getVoltage() / 3.2 * 360 + offset) % 360;

JST Joiner Board