License

Recommend Projects

360 rotary encoder

3 years ago 2066
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments

Description

360° Rotary encoder for arduino

360° Rotary encoder (rotary encoder) can be converted into a rotational position or rotation amount signal (analog or digital), through a certain way (mechanical, optical, magnetic, etc.), that the axis of rotation, and send a signal to inform us. Can be divided into absolute type (absolute) and incremental (incremental) or called a relative type (relative), absolute position of the shaft of eleven different number, then according to the current position of the output number; incremental encoder is when output shaft rotation changes, the shaft does not move, there is no output.

I was under the purchase of incremental rotary encoder modules, you can always rotate, rotate an entire week is divided into 20 small cells, forward reversal can be, when the rotation, CLK pin will show a low level, at this time DT pin data can be read, if it is HIGH represents a positive turn, LOW representatives reversal; SW is the switch pin, the shaft can be pressed to change the status of this pin. Also + must be connected to the positive supply, GND ground.

360 rotary modules This encoder is a mechanical type, the need for de-jitter signal, the less accurate for low speed applications; optical formula can be used for high-speed or accuracy of high demand areas.

Incremental rotary encoders have a similar mechanism of induction gear gap and, in order to have two output A and B, the rotation, A and B will output different signals, forward and reverse the string of different signals available , so you can distinguish positive reversal.

But I purchased the module has been handled well, you do not need to detect their own A and B for the processing and judgment.

I use the board is Arduino MEGA 2560, software development environment Windows 8.1 .

Circuit as follows: Arduino pin 2, connecting module CLK. Arduino pin 3 connection module DT. Arduino pin 4, the connection module SW.

The draft code is as follows, when the detected forward, increased global variable count, and output to the serial port, to reverse the reduction, press the switch is zero. serial com3

360°rotary encoder CODE


/*
  360RotaryEncoder

  Read a rotary encoder with interrupts
  Encoder&Switch hooked up with common to +5V
  Read the press action with digitalread

  ENCODER_A_PIN to pin 2
  ENCODER_A_PIN to pin 3
  SWITCH_PIN to pin 4  

#define ENCODER_A_PIN 2
#define ENCODER_B_PIN 3
#define SWITCH_PIN    4
long position;

void setup(){
  //setup our pins 
  pinMode(ENCODER_A_PIN, INPUT);
  pinMode(ENCODER_B_PIN, INPUT);
  pinMode(SWITCH_PIN, INPUT);

  attachInterrupt(0, read_quadrature, CHANGE);

  //setup our serial 
  Serial.begin(9600);
}

void loop(){
   if (digitalRead(SWITCH_PIN) == LOW){
     delay(10);
     if (digitalRead(SWITCH_PIN) == LOW){
       Serial.println("Switch Pressed");
     }
   }
   Serial.print("Position: ");
   Serial.println(position, DEC);
   delay(1000);
}

void read_quadrature(){  
  // found a low-to-high on channel A 
  if (digitalRead(ENCODER_A_PIN) == LOW){   
    // check channel B to see which way 
    if (digitalRead(ENCODER_B_PIN) == LOW)
      position++;
  }
  // found a high-to-low on channel A 
  else{
    // check channel B to see which way
    if (digitalRead(ENCODER_B_PIN) == LOW)
      position--;
  }
}

Documents

360 Rotary Encoder

360 rotary encoder

BOM

ID Name Designator Footprint Quantity
1 M05 JP1 1X05 1
2 rotary encoder SW1 ENCODER_LED_3_KIT 1
3 M03 JP2 1X03 1

Attachments

None

Members

Success
The owner does not allow comments in this project now

Comments (0)

goToTop
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.