Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: ENERGIA
HI
I have interfaced 131:1 Metal Gearmotor 37Dx73L mm with 64 CPR Encoder with tiva board. coding done in energia and as below:
#define Left_Encoder_PinA PD_6
#define Left_Encoder_PinB PD_7
volatile long Left_Encoder_Ticks = 0;
volatile bool LeftEncoderBSet;
#define Right_Encoder_PinA PC_5
#define Right_Encoder_PinB PC_6
volatile long Right_Encoder_Ticks = 0;
volatile bool RightEncoderBSet;
void setup()
{
Serial.begin(115200);
SetupEncoders();
}
void SetupEncoders()
{
pinMode(Left_Encoder_PinA, INPUT_PULLUP);
pinMode(Left_Encoder_PinB, INPUT_PULLUP);
attachInterrupt(Left_Encoder_PinA, do_Left_Encoder, RISING);
pinMode(Right_Encoder_PinA, INPUT_PULLUP);
pinMode(Right_Encoder_PinB, INPUT_PULLUP);
attachInterrupt(Right_Encoder_PinA, do_Right_Encoder, RISING);
}
void loop()
{
Update_Encoders();
}
void Update_Encoders()
{
Serial.print("e");
Serial.print("\t");
Serial.print(Left_Encoder_Ticks);
Serial.print("\t");
Serial.print(Right_Encoder_Ticks);
Serial.print("\n");
}
void do_Left_Encoder()
{
LeftEncoderBSet = digitalRead(Left_Encoder_PinB);
Left_Encoder_Ticks -= LeftEncoderBSet ? -1 : +1;
}
void do_Right_Encoder()
{
RightEncoderBSet = digitalRead(Right_Encoder_PinB);
Right_Encoder_Ticks += RightEncoderBSet ? -1 : +1;
}
compiled and uploaded successfully, but am not able read values in serial monitor.
is there any configuration i have to do? if yes how?