[chbot] Shaft Encoder

Mikael Stewart mikael.stewart at gmail.com
Thu Sep 4 12:35:25 BST 2008

This may be veering a little off topic but I figure since I haven't come 
across this on the net before I'd share it with you people... who knows, it 
may be of use...

In the recent past I've used two DIY optical encoder concepts that seem to 
work quite well. In both cases I've used the optical sensor and quadrature 
detector from inside a computer mouse. In one case I also used the encoder 
wheel from inside the same mouse which I attached to one end of a motor with 
a double ended shaft. This encoder has 36 counts per rev, which gives 144 
ticks per rev (2.5 deg.) resolution + direction when clocking on both edges 
of both signals (36x4) - the dsPIC i'm using conveniently does this in 
hardware. The downside is that these sensors are designed for slow 
operation, so with weak pull up resistors (or pull down as the case may be) 
the voltage swing at high speeds reduces and the signal begins to look more 
and more sinusoidal until the micro eventually stops registering the 
transitions completely. Since the offset differs negligibly (mainly with 
ambient light), I solved the problem using a simple voltage comparator + 
hysteresis on both channels. The result is the ability to register at least 
4000rpm + direction without any hint of a glitch. I haven't tested beyond 
this speed as the motors I'm using don't go any faster!

I've uploaded some photos to show you what I'm talking about:

http://mikael.geekland.org/photos/P1010009.JPG  -- motor before adding 
http://mikael.geekland.org/photos/P1010016.JPG  -- after (only one mouse per 
two motors needed!).
http://mikael.geekland.org/photos/P1010020.JPG  -- after close-up.
http://mikael.geekland.org/photos/P1010022.JPG  -- one of the rejected PCBs. 
shows how simple it is though!

What the photos don't show is the plastic cover essential for blockign 
ambient light, thus keeping the signal offset stable. Also, the vtg 
comparator circuit is on the microcontroller side of electronics, so the 
motor pcb only has a essential pull up resistors + led + detector.

... WIth that out of the way, the other method I've tested but not really 
used was inspired by the SRS encoder article at 
http://www.seattlerobotics.org/encoder/200109/dpa.html. I took the 
postscript file from here but instead of printing on paper, i made a much 
higher resolution encoder on OHP plastic and protected the print side with 
transparent Duracell (stickable dust cover for books). Using the fine pitch 
sensitivity of the mouse quadrature detector obviously allows for quite a 
high resolution disc (far superior to what the SRS article illustrates). 
Remember also that even if the pitch is a little too small for the 
quadrature encoder, all that happens is a little cross coupling between ON 
and OFF states, which basically turns a square wave output more sinusoidal, 
which again is easily solved using a voltage comparator circuit. The 
coupling between channels is probably not so much an issue, so long as you 
have detectable phase difference. Also, the OHP + Duracell combination was 
rigid enough for quite a large disc. I used a homemade Perspex washer ring 
thingy to attach to the motor shaft. Downside is of course that it requires 
some room either side of the encoder wheel for led + detector.

Ok I'm done :)


----- Original Message ----- 
From: "Charles Manning" <manningc2 at actrix.gen.nz>
To: <chchrobotics at lists.linuxnut.co.nz>
Sent: Thursday, September 04, 2008 9:59 AM
Subject: Re: [chbot] Shaft Encoder

>I just checked data sheets and other info...
> The UGN3141 turns on at 100Gauss and off at 45Gauss. The Earth's magnetic
> field is less than one Gauss. Therefore there is no need for a "turn-off"
> magnet with these parts.
> On Thursday 04 September 2008 08:44:40 Charles Manning wrote:
>> There are different kinds of hall effect sensors. Some need to have
>> alternate poles to turn on/off and some do not.
>> With the HE sensor I am using I only need one magnet.
>> The HE sensors are a bit more expensive than optical forks, but they are 
>> so
>> much simpler to use and don't need any supporting electronics.
>> I bought the tiny magnets from a place in USA by mail order, but might 
>> end
>> up using something I bought from Natures Discovery.
>> Interestingly, that flexible fridge magnet stuff is made up of alternate
>> bands of north and south magnet and  would make an effective linear
>> encoder.
>> Quite a few DC motor encoders use HE sensors because they are far more
>> robust against dust etc than optical sensors.
>> On Thu, Sep 4, 2008 at 8:34 AM, Richard Jones <rjtp at ihug.co.nz> wrote:
>> > Thanks Charles,
>> >
>> > The UGN3141 Hall effect sensor from South Island Components does look
>> > interesting, a little more expensive than optical.
>> >
>> > To ensure that the hall effect sensors get low enough gauss to release 
>> > do
>> > magnets need to be alternated N S N S? That would mean an even number 
>> > so
>> > to detect direction of rotation you need 90 degree separation between
>> > hall effect devices rather than 180 degree that works with an odd 
>> > number.
>> > Where do you get your tiny magnets?
>> >
>> > I wonder if you might be able to place the hall effect sensor somewhere
>> > inside a brushed DC motor?
>> >
>> > Richard
>> >
>> > On Thu, 4 Sep 2008 07:38:10 +1200, "Charles Manning"
>> > <cdhmanning at gmail.com
>> >
>> > wrote:
>> > > Hi Richard
>> > > There's an alternative that we are dabbling with using a Hall Effect
>> > > sensor
>> > > that is probably a lot easier to do than shaft encoders.
>> > > The Hall Effect sensor is just a 3-pin transistor like device that
>> >
>> > detects
>> >
>> > > a
>> > > magnetic field (eg. UGN3141 from South Island Components). The magnet
>> > > can be
>> > > one of those tiny 2.5mm Neodymium magnets embedded in a gear (Drill a
>> >
>> > hole
>> >
>> > > and glue it in). Since some of gears inside the gearbox rotate quite
>> > > fast you can get pretty good resolution.
>> > >
>> > > On Wed, Sep 3, 2008 at 10:06 PM, Richard Jones <rjtp at ihug.co.nz> 
>> > > wrote:
>> > >> I came across this shaft encoder arrangement for the Tamiya 
>> > >> Twin-Motor
>> > >> Gearbox: http://www.noplabs.com/twinmotor/twinmotor.html
>> > >> This came via the HBRC mailing list. Andrew showed something along
>> > >> these lines at one of our robotics meetings several years back.
>> > >>
>> > >> Richard
>> > >>
>> > >>
>> > >> _______________________________________________
>> > >> Chchrobotics mailing list
>> > >> Chchrobotics at lists.linuxnut.co.nz
>> > >> http://lists.ourshack.com/mailman/listinfo/chchrobotics
>> >
>> > _______________________________________________
>> > Chchrobotics mailing list
>> > Chchrobotics at lists.linuxnut.co.nz
>> > http://lists.ourshack.com/mailman/listinfo/chchrobotics
> _______________________________________________
> Chchrobotics mailing list
> Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics 

More information about the Chchrobotics mailing list