Wild Thumper DC Motor Controller Encoder Setup

Traditional mobile robotics is all about wheeled robots.
4 postsPage 1 of 1
4 postsPage 1 of 1

Wild Thumper DC Motor Controller Encoder Setup

Post by Toby » Mon Jul 01, 2013 11:30 pm

Post by Toby
Mon Jul 01, 2013 11:30 pm

Hey everybody,

anybody could comment my ideas on hooking up Thumper 4WD encoders to the motor controller?

Probably pin D2 and D4 for left encoder and D7 and D8 for right encoder would be ok? Does the color coding white and yellow matter in any way?

Also would you like to share some arduino code for quering encoder state? I would like to learn how you address the fact, that there is only one free interrupt available at D2, so an separate interrupt for left and right encoder is not an option. Thus, do you pack everything in the main loop?

Looking forward for your replies :D

Cheers
Toby
Hey everybody,

anybody could comment my ideas on hooking up Thumper 4WD encoders to the motor controller?

Probably pin D2 and D4 for left encoder and D7 and D8 for right encoder would be ok? Does the color coding white and yellow matter in any way?

Also would you like to share some arduino code for quering encoder state? I would like to learn how you address the fact, that there is only one free interrupt available at D2, so an separate interrupt for left and right encoder is not an option. Thus, do you pack everything in the main loop?

Looking forward for your replies :D

Cheers
Toby
Toby offline
Newbie
Newbie
Posts: 1
Joined: Mon Jul 01, 2013 11:10 pm

Post by BotThoughts » Mon Aug 26, 2013 3:42 pm

Post by BotThoughts
Mon Aug 26, 2013 3:42 pm

What encoders?

I've used QRE1113 reflectance sensors from Sparkfun (Pololu sells these too I think). And it's a matter of giving them power and ground, and then plugging signal into some ports.

On ATmega, you can have an interrupt fired every time there's a transition on these type of reflectance sensors, then write interrupt handler code to increment a counter based on which pin changed. Or if you use ATmega's special INT0 and INT1 pins, you can specific which transition (rising or falling or both) and fire interrupts with handlers unique to each pin.
What encoders?

I've used QRE1113 reflectance sensors from Sparkfun (Pololu sells these too I think). And it's a matter of giving them power and ground, and then plugging signal into some ports.

On ATmega, you can have an interrupt fired every time there's a transition on these type of reflectance sensors, then write interrupt handler code to increment a counter based on which pin changed. Or if you use ATmega's special INT0 and INT1 pins, you can specific which transition (rising or falling or both) and fire interrupts with handlers unique to each pin.
BotThoughts offline
Robot Builder
Robot Builder
Posts: 7
Joined: Thu Aug 22, 2013 6:57 am

Post by Grumpybeard » Fri Aug 30, 2013 11:59 am

Post by Grumpybeard
Fri Aug 30, 2013 11:59 am

I would be very much interested in a solution to what Toby asks - indeed a later revision of the thumpers cam with encoders built into 2 of the motors, so how to connect these up to the thumper controller board would be great to know.
I would be very much interested in a solution to what Toby asks - indeed a later revision of the thumpers cam with encoders built into 2 of the motors, so how to connect these up to the thumper controller board would be great to know.
Grumpybeard offline
Newbie
Newbie
Posts: 6
Joined: Tue Apr 09, 2013 1:49 pm

Timer Interrupts

Post by OddBot » Sat Aug 31, 2013 5:16 am

Post by OddBot
Sat Aug 31, 2013 5:16 am

In cases where external interrupt pins are limited the next best way is to create a timer interrupt. This generates an interrupt at precise intervals. The ISR (Interrupt Service Routine) then checks the pins attached to the encoders.

There is an Arduino library here that is quite useful: http://playground.arduino.cc/Code/Timer1

Unfortunately this library uses the same timer as the servo library so you cannot use servos with it unless your using An Arduino Mega or DAGU Spider controller. There is also a timer3 version of the library suitable for these boards.

Alternatively, if your main code repeats quickly enough then simply monitor the inputs with each loop of the program. This is ok for distance measurements but not suitable for speed measurement which needs accurate timing.

I often use the millis() or micros() function to call my ISR once every millisecond. The accuracy of this method depends on how quickly your main loop is running. If your encoders or maximum speed is low enough then you can check your encoder inputs at longer intervals.
In cases where external interrupt pins are limited the next best way is to create a timer interrupt. This generates an interrupt at precise intervals. The ISR (Interrupt Service Routine) then checks the pins attached to the encoders.

There is an Arduino library here that is quite useful: http://playground.arduino.cc/Code/Timer1

Unfortunately this library uses the same timer as the servo library so you cannot use servos with it unless your using An Arduino Mega or DAGU Spider controller. There is also a timer3 version of the library suitable for these boards.

Alternatively, if your main code repeats quickly enough then simply monitor the inputs with each loop of the program. This is ok for distance measurements but not suitable for speed measurement which needs accurate timing.

I often use the millis() or micros() function to call my ISR once every millisecond. The accuracy of this method depends on how quickly your main loop is running. If your encoders or maximum speed is low enough then you can check your encoder inputs at longer intervals.
OddBot offline
Robot Builder
Robot Builder
Posts: 11
Joined: Fri Nov 12, 2010 2:06 am


4 postsPage 1 of 1
4 postsPage 1 of 1
cron