Mini Robot chassis Encoder (SKU:SEN0116)
Editing Mini Robot chassis Encoder (SKU:SEN0116)
Contents
1 Introduction
2 Specification
3 Encoder Connection Diagram
3.1 Sample Code
4 FAQ
Introduction
This encoder is matched with 2wd miniQ Robot chassis. AB two-phase pulse wave,measured by two
infrared reflective sensor.These two sensor pulse waveform is close to a phase difference of 90
degrees, through the AB two-phase lead and lag of the waveform judged wheel forward rotation or
the reverse. You can install it on the motor bracket or mini robot chassis to do the PID and position
control.
Note: Please short current R4 when working in 3.3V
Specification
Working Voltage:3.3V or 5V
Working Current: the interrupt pin 0
const byte encoder0pinB = 4;//B pin -> the digital pin 4
byte encoder0PinALast;
int duration;//the number of the pulses
boolean Direction;//the rotation direction
void setup()
{
Serial.begin(57600);//Initialize the serial port
EncoderInit();//Initialize the module
}
void loop()
{
Serial.print("Pulse:");
Serial.println(duration);
duration = 0;
delay(100);
}
void EncoderInit()
{
Direction = true;//default -> Forward
pinMode(encoder0pinB,INPUT);
attachInterrupt(0, wheelSpeed, CHANGE);
}
void wheelSpeed()
{
int Lstate = digitalRead(encoder0pinA);
if((encoder0PinALast == LOW) && Lstate==HIGH)
{
int val = digitalRead(encoder0pinB);
if(val == LOW && Direction)
{
Direction = false; //Reverse
}
else if(val == HIGH && !Direction)
{
Direction = true;
//Forward
}
}
encoder0PinALast = Lstate;
if(!Direction)
else
duration++;
duration--;
}
FAQ
Q1. I have a question about the encoder. In the process of adjusting the screws, I have turned a
screw out of range and don't know which way to turn it back. Is there one direction i should turn it
to 'start from zero'?
A1. You can turn it in clockwise or reversely to adjust the resistance value, range 0-30KΩ.
And the valid adjustable angle is 260°±20°. To make it easier to understand, it means if you
rotate it in 360°, it will keep the same resistance value.
Powered By DFRobot © 2008-2017
很抱歉,暂时无法提供与“SEN0116”相匹配的价格&库存,您可以联系我们找货
免费人工找货