모터 인코더 키트

(Motor Encoder Kit)

개요

  • 본 제품은 모터 인코더 키트입니다.
  • 인코더 두개와 20개의 구멍이 나있는 원형 그리드 보드가 포함되어 있는 제품입니다.
  • 인코더는 포토인터럽터(검정 ㄷ 모양)를 장착하고 있으며, 이 사이에 그리드 보드가 회전하며 통과하는데, 빈 공간으로 적외선이 지나갈때마다 펄스를 생성하게 됩니다.
  • 원형 그리드 보드를 모터의 뒷쪽 샤프트에 아래와 같이 연결하여 사용합니다.
  • 원형 그리드 보드가 360도에 20개의 홀이 있기 때문에 하나의 펄스당 360/20 =18도씩 측정이 가능하게 됩니다.
  • 5V 시스템과 사용이 가능하며 DOUT 핀이 펄스 출력핀입니다.

특징

  • Working Voltage: 4.5~5.5 VDC
  • Emitter Voltage Drop: 1.5V
  • Output Voltage: TTL
  • Max Output Frequency: 100Khz
  • Circular Grid Board Diameter: 24mm
  • Circular Grid Board Inner Diameter: 4mm

    Partlist

    • encoder x2
    • Circular Grid Board x2
    • 6 Pin Female to Female Wire x1

문서

  • 아두이노 예제 코드
  • int encoder_pin = 2;  // The pin the encoder is connected           
    unsigned int rpm;     // rpm reading
    volatile byte pulses;  // number of pulses
    unsigned long timeold; 
    // The number of pulses per revolution
    // depends on your index disc!!
    unsigned int pulsesperturn = 20;
    
     void counter()
     {
        //Update count
          pulses++;    
     }
    
    void setup()
     {
       Serial.begin(9600);
         //Use statusPin to flash along with interrupts
       pinMode(encoder_pin, INPUT);
       
       //Interrupt 0 is digital pin 2, so that is where the IR detector is connected
       //Triggers on FALLING (change from HIGH to LOW)
       attachInterrupt(0, counter, FALLING);
       // Initialize
       pulses = 0;
       rpm = 0;
       timeold = 0;
    
     }
    
     void loop()
     {
       if (millis() - timeold >= 1000){  /*Uptade every one second, this will be equal to reading frecuency (Hz).*/
     
      //Don't process interrupts during calculations
       detachInterrupt(0);
       //Note that this would be 60*1000/(millis() - timeold)*pulses if the interrupt
       //happened once per revolution
       rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
       timeold = millis();
       pulses = 0;
       
       //Write it out to serial port
       Serial.print("RPM = ");
       Serial.println(rpm,DEC);
       //Restart the interrupt processing
       attachInterrupt(0, counter, FALLING);
       }
      }
    

연관제품