Capacitor, Resistor, Inductor

1000ppr 5V Encoder ABZ Pulses Hollow shaft incremental encoder digital encoder

Condition: New
Availability: In Stock
Share:     Faceook Twitter

SKU: TMD,Th,KRT

Rs.3500 Rs. 4375

Rotery Encoder 1000 PPR 5V ABZ motor hollow shaft incremental encoder digital encoder

10cm x 8cm x 6cm (3.94in x 3.15in x 2.36in)

Pinout:

  1. Red +5v
  2. White GND
  3. BLUE A
  4. GREEN B
  5. YELLOW Z

A rotary encoder, also called a shaft encoder, is an electro-mechanical device that converts the angular position or motion of a shaft or axle to an analog or digital code.

There are two main types: absolute and incremental (relative). The output of absolute encoders indicates the current position of the shaft, making them angle transducers. The output of incremental encoders provides information about the motion of the shaft, which is typically further processed elsewhere into information such as speed, distance and position.

Rotary encoders are used in many applications that require precise shaft unlimited rotation—including industrial controls, robotics, special purpose photographic lenses,[1] computer input devices (such as optomechanical mice and trackballs), controlled stress rheometers, and rotating radar platforms.

Incremental rotary encoder

Encoder ROD 420

An incremental rotary encoder provides cyclical outputs (only) when the encoder is rotated. They can be either mechanical, optical or magnetic. The mechanical type requires debouncing and is typically used as digital potentiometers on equipment including consumer devices. Most modern home and car stereos use mechanical rotary encoders for volume control. Due to the fact the mechanical switches require debouncing, the mechanical type are limited in the rotational speeds they can handle. The incremental rotary encoder is the most widely used of all rotary encoders due to its low cost and ability to provide signals that can be easily interpreted to provide motion related information such as velocity.

The fact that incremental encoders use only two sensors does not compromise their resolution. One can find in the market incremental encoders with up to 10,000 counts per revolution, or more.

There can be an optional third output: reference or “index”, which happens once every turn. This is used when there is the need of an absolute reference, such as positioning systems. The index output is usually labeled Z.

The optical type is used when higher speeds are encountered or a higher degree of precision is required.

Incremental encoders are used to track motion and can be used to determine position and velocity. This can be either linear or rotary motion. Because the direction can be determined, very accurate measurements can be made.

They employ two outputs called A & B, which are called quadrature outputs, as they are 90 degrees out of phase.

The state diagram:

Phase A B
1 0 0
2 0 1
3 1 1
4 1 0
Phase A B
1 1 0
2 1 1
3 0 1
4 0 0

Two square waves in quadrature (clockwise rotation).

The two output wave forms are 90 degrees out of phase, which is what quadrature means. These signals are decoded to produce a count up pulse or a count down pulse. For decoding in software, the A & B outputs are read by software, either via an interrupt on any edge or polling, and the above table is used to decode the direction. For example, if the last value was 00 and the current value is 01, the device has moved one half step in the clockwise direction. The mechanical types would be debounced first by requiring that the same (valid) value be read a certain number of times before recognizing a state change.

On encoders with detents there are different ways to switch states. In some, both A and B are always open circuit at the detents, and an entire 00 ? 00 switching cycle occurs while transitioning from one detent to the next. Others have detents of alternating 00 and 11 value, with staggered switching times during the transition between detents.

Incremental Pulse Diagram A, B, Z

Additionally some incremental encoders output a “Z” signal. Once every rotation, this Z signal is rising for typically 90°, on exactly the same position. This can be used as an accurate reference point. Some incremental encoders also have additional differential signals, called “/A”, “/B” and “/Z”. These signals are inverted “A”, “B” and “Z” signals. Controllers can compare each pair (“A” must be equal to inverted “/A”) to ensure that there is no error during the transmission.[10]

An observer, such as a microprocessor, will read (sample) the output of the encoder. The observer needs to sample the encoder output often enough so it does not miss any code changes. If the encoder turns too fast, then the observer may miss an encoder output change, so the observer will see an invalid transition, such as 00 ? 11, and be confused. For that transition, the observer does not know which way the encoder turned: it may have gone forward (00 ? 01 ? 11) or backward (00 ? 10 ? 11). If the encoder is turning even faster, then multiple output changes could be missed, and the observer may get the direction wrong. Consider the moving forward sequence 00 ? 01 ? 11 ? 10 (3 steps forward). If the encoder is turning too fast, the observer may see only the first (00) and fourth (10) outputs and conclude the encode made a legal 00 ? 10 transition (1 step backward).

This same principle is used in ball mice to track whether the mouse is moving to the right/left or forward/backward.

Arduino Example code to measure Length.

//====================

#include
volatile unsigned long threshold = 10;
signed long pulse_counter = 1000;
#define encoder_a 2 // pin 2 only pin 2
#define encoder_b 8 // pin4 can be change
#define power_fail 4 // pin3 can be change



int calibration_pulses=0;
int mm_calibration=0;
int update_flag=0,debug_flag=0;
int current_mm_value=0,current_cm_value=0,old_cm_value=0;
//====================================================
void int0() {if ( digitalRead(encoder_b)) pulse_counter++;else pulse_counter–;}
void int1()
{
EEPROMWritelong(4, pulse_counter);
}
//====================================================
void setup()
{
Serial.begin(9600);Serial.setTimeout(50);
pinMode(encoder_a, INPUT);
pinMode(encoder_b, INPUT);
pinMode(power_fail, INPUT);
digitalWrite(power_fail, HIGH);
digitalWrite(encoder_a, HIGH); // enable internal pull up
digitalWrite(encoder_b, HIGH); // enable internal pull up
attachInterrupt(0, int0, RISING );
pulse_counter=EEPROMReadlong(0);
mm_calibration=EEPROMReadlong(4);
calibration_pulses=EEPROMReadlong(8);
calculate_variables();
old_cm_value=current_cm_value;
}
//============================================
void loop()
{
setting();
calculate_variables();
if(update_flag==1) {update_flag=0;Serial.println(current_cm_value);}
if(debug_flag==1) {debug_flag=0;updater_all_variables();}
if((current_cm_value>old_cm_value) || (current_cm_value// if(digitalRead(power_fail)==0){EEPROMWritelong(4, pulse_counter);while(digitalRead(power_fail)==0);}
int input_voltage = analogRead(A0);if(input_voltage<400){EEPROMWritelong(0, pulse_counter);while(analogRead(A0)<400)Serial.println(“LOW_VOLTAGE”);}
//Serial.println(input_voltage);
}
//============================================
void calculate_variables()
{
float cmm=mm_calibration;
float cp=calibration_pulses;
float float_pulse_counter=pulse_counter;
float float_mm=pulse_counter;
float_mm=float_pulse_counter*cmm/cp;
current_mm_value=float_mm;
current_cm_value=current_mm_value/10;
}
//===========================================
void updater_all_variables()
{
calculate_variables();
Serial.println(” “);
Serial.print(” pulse_counter=”);
Serial.print(pulse_counter);
Serial.print(” mm_calibration=”);
Serial.print(mm_calibration);
Serial.print(” calibration_pulses=”);
Serial.print(calibration_pulses);
Serial.print(” CURRENT MM=”);Serial.print(current_mm_value);
Serial.print(” CURRENT CM=”);Serial.println(current_cm_value);
}
//==============================================
void setting()
{
if(Serial.available())
{
String command=Serial.readString();
if(command==”clear”){Serial.println(“Clear”);pulse_counter=0;}
// else if(command==”calibrate”) calibration_pulses= pulse_counter;
else if(command==”update”) update_flag=1;
else if(command==”debug”) debug_flag=1;
else if(command==”set_last_pulse”)
{
Serial.println(“PLEASE ENTER LAST KNOWN PULSE”);while(Serial.available()==0);
command=Serial.readString();Serial.println(command);
pulse_counter= command.toInt();// String to Int
}
else if(command==”mm_calibration”)
{
Serial.println(“PLEASE ENTER VALUE”);while(Serial.available()==0);
command=Serial.readString();Serial.println(command);
mm_calibration= command.toInt();// String to Int
Serial.println(mm_calibration); // )>

calibration_pulses=pulse_counter;
EEPROMWritelong(0,pulse_counter); //Save current pulses
EEPROMWritelong(4,mm_calibration);//Save Exact value
EEPROMWritelong(8,calibration_pulses);//Save Exact value
Serial.println(“saved”);
}

}
}
//==============================================
void EEPROMWritelong(int address, long value)
{
byte four = (value & 0xFF);
byte three = ((value >> 8) & 0xFF);
byte two = ((value >> 16) & 0xFF);
byte one = ((value >> 24) & 0xFF);

//Write the 4 bytes into the eeprom memory.
EEPROM.write(address, four);
EEPROM.write(address + 1, three);
EEPROM.write(address + 2, two);
EEPROM.write(address + 3, one);
}
//==============================================
long EEPROMReadlong(long address)
{
//Read the 4 bytes from the eeprom memory.
long four = EEPROM.read(address);
long three = EEPROM.read(address + 1);
long two = EEPROM.read(address + 2);
long one = EEPROM.read(address + 3);


return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
}

No Reviews Yet

0

overall

Add a review