Author Topic: Community project: Encoder wheel  (Read 7098 times)

0 Members and 1 Guest are viewing this topic.

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Community project: Encoder wheel
« on: June 05, 2009, 01:52:52 AM »
I am making an encoder wheel for the community project. I'll post and keep people updated with plans ,shematics, and 3D files which will be Sketchup and/or Auto Cad

what do people think of this module idea?
« Last Edit: June 05, 2009, 02:03:37 AM by Joker94 »

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: Community project: Encoder wheel
« Reply #1 on: June 05, 2009, 02:18:23 AM »
Sounds great.

You should talk with the people who want to build motor controller modules and decide on some specifications such as the output signal of the encoder (generally quadrature) and the physical connector.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Community project: Encoder wheel
« Reply #2 on: June 05, 2009, 02:28:33 AM »
i think that the connectors should just be a standard 2.54mm molex connector to make
it easier for everyone who uses it. what do you guys think?
Howdy

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: Community project: Encoder wheel
« Reply #3 on: June 05, 2009, 02:43:34 AM »
I like those. But you still have to consider the pinout. For non-polarised connectors, the mirrored opposite of the V+ supply pin should be 'not connected'. E.g. in a 5 pin connector, if V+ is pin2 then pin 4 shouldn't be connected.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #4 on: June 05, 2009, 03:28:03 AM »
that sounds good for ease of use as most people probably would have a molex connecter and pins lying around some where

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #5 on: June 05, 2009, 03:34:43 AM »
My robot Woody had very good single channel encoders I made from sparkfun photo interrupters.  I just attached a code wheel drilled with 10 holes to the backshaft of my gearmotors.  The gear ratio was 80:1 and I used a change interrupt to achieve a resolution of 1600 pulses per revolution of the motor output shaft.  The little black squares next to the code wheels are the photo interrupters poking through Woody's frame.  The picture is of Woody's underbelly.

« Last Edit: June 05, 2009, 03:36:10 AM by sonictj »

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #6 on: June 05, 2009, 03:50:28 AM »
Great idea, not to difficult to achieve at first glance but i imagine there may be more that i am some how missing

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #7 on: June 05, 2009, 04:14:37 AM »
Quote
Great idea, not to difficult to achieve at first glance but i imagine there may be more that i am some how missing
yah and you can't beat it at 4 dollars an encoder.  They worked great!

I simply took datasheet dimensions of the photo interrupters and catered my code wheels and interrupter mounting to fit.  I was able to make a 20Hz PID controller using these encoders.  I actually just wrote a paper on the design and implementation.   I'd attached it to this post but it about 10meg.  I have since learned more about PID implementation.  I have developed a pretty nice controller that can run on an atmega168 using an Output compare interrupt and two external interrupts.  My latest build had the controller taking 37 us for the PID loop to complete.  The software is currently running in the arduino environment but The code is pure c so I can easily port it to avr studio and post a copy if there is a need.
« Last Edit: June 05, 2009, 04:16:07 AM by sonictj »

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Community project: Encoder wheel
« Reply #8 on: June 05, 2009, 04:19:58 AM »
can you upload the paper to mega upload or similar?
i would really like to see it.
Howdy

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #9 on: June 05, 2009, 04:40:31 AM »
sonictj, about the code it is not my strong point at the moment as i have not had much need to write much, so when i have finished the module would you be able to assist me in writing some code or if you want to write the code for the module.

i don't know how long it will take me to complete the module as i have another project on the go but hopfully it wont take to long.

and it would be great to be able to see the paper that you wrote, can you let me know if you upload it

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Community project: Encoder wheel
« Reply #10 on: June 05, 2009, 05:25:29 AM »
Quote
Great idea, not to difficult to achieve at first glance but i imagine there may be more that i am some how missing
yah and you can't beat it at 4 dollars an encoder.  They worked great!

I simply took datasheet dimensions of the photo interrupters and catered my code wheels and interrupter mounting to fit.  I was able to make a 20Hz PID controller using these encoders.  I actually just wrote a paper on the design and implementation.   I'd attached it to this post but it about 10meg.  I have since learned more about PID implementation.  I have developed a pretty nice controller that can run on an atmega168 using an Output compare interrupt and two external interrupts.  My latest build had the controller taking 37 us for the PID loop to complete.  The software is currently running in the arduino environment but The code is pure c so I can easily port it to avr studio and post a copy if there is a need.

Sonicj, I would like to take a look at your code, perhaps I will also need your help writing it for the DC motor controller I am building. Since I am not a pure C programmer, I was thinking of using Arduino libraries to write the code, but if you allready been there, done that, there is no point reinventing the wheel.

Thank you so much.
Check out the uBotino robot controller!

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #11 on: June 05, 2009, 11:17:13 AM »
do you want me to post the code here or send you a personal message since this is the electronics forum?

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #12 on: June 05, 2009, 11:57:18 AM »
Also note even though I said I used the arduino environment I actually broke a great deal of its functions and hacked their source code.

for instance I revved up the pwm on timer0 so that it was at 62khz (above audible)  this in turn killed the delay function so made timer 2 the timer source of the delay command.  I also completely changed the timer1 settings so that it just counted up to some number equivalent to 50ms for a timer interrupt.

The easiest way to do all this is to change the initializations in wiring.c.  If your not comfortable with this I can develop a project in avr studio.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Community project: Encoder wheel
« Reply #13 on: June 05, 2009, 08:07:29 PM »
Sonictj,

I am not such a good programmer as obviously you are, that's why I use the libraries in Arduino. I know there are some libraries allready written for GCC by Webbot and by Admin, but I don't feel comfortable writing code in GCC yet. So, for my personal use, I will stay with Arduino for now.

That been said, here is my setup:
- tiny2313 microcontroller, with UART and I2C connections
- SN754410 dual H-Bridge, all pins connected to micro, 2 pins to OSC1A and OSC1B for PWM control, that means it uses Timer1
- 2 quadrature encoders, channel A of each tied to INT0 and INT1 (external interrupts) and channel B of each tied to regular pins that have Pin Change Interrupt

What I need to do is:
- have PID control with trapezoidal profile for smooth acceleration-topspeed-deceleration (for both motors)
- have PID control to keep left-right error to zero
- have the following commands:
          - move(distance, speed); positive goes forward, negative goes bakward
          - turn(degrees, speed); positive turns counterclockwise, negative turn clockwise
          - drive(direction, speed); no distance target, drive until other command
          - stop
          - turn(direction, speed)
- should return 1 after command completed
- should return total traveled distance since started (optional)

If I can remember anything else... I'll add up.

So far I have the ISR for the encoders and some of the PID control, using the PID library. I still need to work on the trapezoidal profile and the commands.

The code you have is just as reference, so it will help if you attach a zip file.

Thanks.
Check out the uBotino robot controller!

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #14 on: June 05, 2009, 08:41:30 PM »
I'll work on writing the code in a way that will not get too complicated (lots of comments and such).  I'll probably post it in a day or two ok?

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Community project: Encoder wheel
« Reply #15 on: June 05, 2009, 08:54:36 PM »
Hi,

I am making an encoder wheel for the community project. I'll post and keep people updated with plans ,shematics, and 3D files which will be Sketchup and/or Auto Cad

what do people think of this module idea?

I think it's kind of reinventing the wheel (pun not intended;))
A CAD drawing will be one resolution//rev and if people needs AutoCAD, it will barr many from using it, since not many of the projected target audience can afford AutoCAD and nobody here would use "BlackWare" i assume(?).

For arbitrary resolutions, free and legal discs can be made with the Post Script found at http://research.meei.harvard.edu/epl/Engineering/encoderdisk.html

Another possibility is http://www.sxlist.com/techref/io/sensor/pos/enc/enc_ps.htm

There exists a program running stand alone as well, but I don't recall where I got it until I fire up an old PC of mine where the link and the software is, but the .ps versions are fine and very customizeable.


P.S. "shematics"! Is that diagrams for women?  ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Community project: Encoder wheel
« Reply #16 on: June 05, 2009, 09:02:38 PM »
I'll work on writing the code in a way that will not get too complicated (lots of comments and such).  I'll probably post it in a day or two ok?

Sure, no rush! I still need a bit of time to get the motors with built in encoders so I can test out the code. My first test rig will use a mega168 instead of the tiny2313. I don't think there will be issues on porting the code afterwards. It will be just resetting the hardware bits.

Thanks.
Check out the uBotino robot controller!

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #17 on: June 06, 2009, 02:34:56 AM »
sonictj, it would be great if you would be able to PM me the code just to see what your code entails

Soeren, when i post files iw il post a sip file or equivelant so every body can view them

 it may be a few days before i can post any plans, ihave a school assignment due on tuseday and it accounts for 55 % of my grade

thanks for the tips and keep posting

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #18 on: June 06, 2009, 06:42:10 AM »
All i have done so far is design the way i am going to collect the speed data

i am not sure about the encoders wheels final design or whether i am going to us an LED and a light dependent resistor or infa red

i have attached a jpg of my very basic design, not alot of detail as it is  only early on  ;D

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Community project: Encoder wheel
« Reply #19 on: June 06, 2009, 07:25:30 AM »
i would say go with infrared as there is less chance of other light sources interfering with the sensor.
Howdy

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #20 on: June 06, 2009, 10:29:59 AM »
I agree with smash infrared is the best for this sort of thing.  Also a photoresistor is not fast enough.  photo resistors have a response time of about 100 ms, way too slow for encoders.  My motors were recording 200+ ticks per 50 ms.  you need a device with a response of a few microseconds.  The photo interrupter sparkfun sells have a response of ~ 6 us.

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #21 on: June 06, 2009, 06:27:07 PM »
where would be the best place to purchase som infa red sensors

would it be possible just to use a infared tranciever and reciver and use the encoder wheel to block the signalor is that going to be to slow
« Last Edit: June 06, 2009, 06:35:58 PM by Joker94 »

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #22 on: June 06, 2009, 06:55:18 PM »
digikey sells photo interrupters of many sizes.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Community project: Encoder wheel
« Reply #23 on: June 06, 2009, 07:08:27 PM »
If you are starting from scratch then this product is pretty good: http://www.solarbotics.com/products/gmww02/
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Joker94Topic starter

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Community project: Encoder wheel
« Reply #24 on: June 06, 2009, 07:15:24 PM »
willa infared emitter and detector work for my purpose, or will i need a more powerful infared system
« Last Edit: June 06, 2009, 07:20:35 PM by Joker94 »

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Community project: Encoder wheel
« Reply #25 on: June 06, 2009, 07:42:49 PM »
yes, an infrared emitter/detector pair will work for this.
Howdy

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #26 on: June 06, 2009, 09:41:34 PM »
if you want a good pid controller you need the appropiate resolution per your design.  Here are some equations I have developed for determining the best resolution, sampling frequency etc. .  I prefer a sampling rate of 20HZ or more.  I also shoot to have the maximum ticks per PID cycle to be greater than my pwm resolution (0-255 for an 8 bit timer ).

for encoder placed on backshaft for non backshaft placement gear ratio = 1

(max motor rpm / 60 )*(encoder resolution*gear ratio)/PID frequency = max ticks per PID cycle

(max motor rpm / max ticks per PID cycle) = tolerence in speed in rpm t


example:

200 rpm motor
gear ratio 80:1
encoder res 10
PID frequency 20Hz

(200/60)*(10*80)/20 =133 ticks max

200/133 = 1.5 rpm max error

These calculations are for rpm.  wheel diameter will be a factor when distance measurement is required.  I recommend only using encoders for rpm management, there is too much slip for accurate distance measurement.



« Last Edit: June 06, 2009, 09:46:57 PM by sonictj »

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Community project: Encoder wheel
« Reply #27 on: June 06, 2009, 10:22:24 PM »
I also shoot to have the maximum ticks per PID cycle to be greater than my pwm resolution (0-255 for an 8 bit timer ).

What do you mean by ticks per PID cycle? Encoder clicks? The motors I will use have 141 high pulses per output rotation or 1 high pulse per motor rotation (per channel), 80RPM at the voltage I'm going to use them.
Check out the uBotino robot controller!

Offline sonictj

  • Supreme Robot
  • *****
  • Posts: 416
  • Helpful? 11
Re: Community project: Encoder wheel
« Reply #28 on: June 07, 2009, 12:38:02 AM »
when I say per PID cycle I'm talking about how I have my PID algorithm refreshing every 50 ms (20Hz).  During the 50ms period I have the controller collect the number of pulses of the encoders.  The number of pulses is proportional to the rpm of the motors.  I like for the max speed of the motors to have greater than 255 pulses collected over the 50ms period.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Community project: Encoder wheel
« Reply #29 on: June 07, 2009, 06:06:32 AM »
Ok, so I have 80 RPM max speed and 141 clicks per rotation.

At 80 rotations I have 141x80=11280 clicks per minute, that means 188 clicks per second, that means 9.4 clicks per 50 ms, per channel. So for a quadrature that counts both low-high and high-low transitions for both channels, there will be 37.6 clicks per 50 ms. A bit low, but what can I do, that's the motor specs. Hard to find a motor with built in encoders.
Check out the uBotino robot controller!

 


Get Your Ad Here

data_list