Crowtail- Encoder

From Elecrow
Jump to navigation Jump to search

Description

The rotary encoder can convert the angular displacement and linear Displacement to the electrical signal,and then convert the electrical signal to the electrical pluse .The numbers of the pluse can be converted to the value of the angular displacement. There are two output pins of this module including signal A and signal B.we can determine the position of the detent and the direction of the rotation by sense the value of the output pins.

Model: CT0004EN

Crowtail-Encoder.JPG

Features

  • Crowtail Interface.
  • Incremental encoder
  • 360 degree rotary

Specification

Dimensions(mm):20.0(L)x20.0(W)x36.3(H)

Item Min Typical Max Unit
Voltage 4.5 5.0 5.5 VDC
Current 10 20 30 mA
Dimension 20 x 20 mm
Net Weight 7 g

Usage

This Crowtail-Encoder is very easy to use.

1.Hardware Connection

Encoder11.jpg

2.Connect the board to PC using USB cable.

3.Upload the following sample sketch:

#define ENCODER_A_PIN 2
#define ENCODER_B_PIN 3
long position;

void setup(){

 pinMode(ENCODER_A_PIN, INPUT);
 pinMode(ENCODER_B_PIN, INPUT);
 attachInterrupt(0, read_quadrature, CHANGE);
 Serial.begin(9600);
}

void loop(){
  Serial.print("Position: ");
  Serial.println(position, DEC);
  delay(1000);
}

void read_quadrature(){  
 
  if (digitalRead(ENCODER_A_PIN) == LOW){   
   //Check clockwise or counterclockwise
   if (digitalRead(ENCODER_B_PIN) == LOW)
     position++;
 }
  
 else{

   if (digitalRead(ENCODER_B_PIN) == LOW)
     position--;
  }
}

4.Open the serial monitor. You should see some data from Encoder.

Encoderresult.jpg

Resource