OT: Simple shaft encoder for modified RC servos

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been busy with building a shaft encoder that can fit inside of a standard RC servo. I wrote a report that hopefully might be useful to fellow freaks who are into slowly spinning stuff, even though it's not directly related to AVR.

http://www.sensi.org/~svo/shaft_encoder

Please share your comments and criticisms.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not a bad idea.

I imagine you could key off other gears to get a higher resolution if you needed it, but that would depend on how tiny your optical components are.

---
Formerly Torby. Stitch626 just seemed a more descriptive nicname.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm, no, not really. I didn't explain that in the article, because it's obvious when you actually get down to it, but this gear is the closest to the motor spindle, hence it's the fastest. By a lucky coincidence, it's also the only one that's onobscured if you look at the gear set from the bottom.

What can really be done to improve resolution is adding more black zones to this gear. With 3mm optical parts I don't think it would make sense to have more than two, or welcome the glitches.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I enjoyed reading about your project. Very nice indeed. I myself am working on a replacment board for a $10 servo using an ATtiny45 and less than $10 in parts that will give full digital control of the servo over TWI bus including full position, speed and power feedback. Hopefully I'll have something to share in a few weeks time.

It's my first attempt at a hardware project in 15 years (I'm more of a software person) and I'm having a blast working with the AVRs in C.

Regarding hardware design of a servo board, any suggestions on where I can study up on EMI noise issues and such? I really don't know what I should be concerned with or not on my servo replacement board. I guess I may have to go through the school of hard knocks and figure it out as problems arise.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Regarding hardware design of a servo board, any suggestions on where I can study up on EMI noise issues and such? I really don't know what I should be concerned with or not on my servo replacement board. I guess I may have to go through the school of hard knocks and figure it out as problems arise.

I don't really know much about EMI either (and I'm a software man myself). Just make sure your control circuit power supply is separated from power that goes to motors as much as possible. Although servos are small, they are capable of making any uC reset even by adjusting, let alone when they get reversed.

I'm really curious about details of your project - how are you going to implement h-bridges? The servos have them packed into their tight custom chip, that's not a small thing when assembled from discrete parts. Are you going to stuff several boards inside? Probably there is enough volume, but where you're going to get feedback from then? Really interesting!

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've created an H-Bridge from discrete components -- derived from a circuit by a person I came across who created a PIC based servo replacement board that is very similar in concept to what I want to build. Using NDS352AP and NDS351AN MOSFETs with 1N4148W-7 switching diodes. These are in SOT-3 and SOD-123 packages so they are tiny -- but it did take me a number of days twiddling to come up with a workable PCB layout. I have about .8" by .7" dual-side PCB real-estate to play with.

Currently, I have a prototype H-Bridge working, TWI slave interface code working, PWM code working, ADC code working, and PID code working (untuned) on a ATtiny45 plugged into STK500 dev board. All code in C using WinAVR. Currently, on the software side I'm working on implementing the command protocol for reading/writing/controlling the servo and on the hardware side working on the final tweaks to the PCB layout, slowly getting my nerve up to get my first set of PCBs made.

I'll put together some notes on this and post a link so you can take a look. Some additional eyes and comments on this would be great.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a link to some hardware notes on the AVR ATtiny45 servo board I'm creating:

http://home.comcast.net/~michael...

Any comments are welcome. It will probably be a few weeks before I commit to get the actual PCBs. I'm still working out the software in a prototype environment and want to get 90% complete before committing the hardware.

An outstanding question I have involves current monitoring of a PWM driven motor. Ideally I want to capture average current/power, but I'm not certain my current circuit can do this. I'll try to work this out in the prototype.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mpthompson: this looks very impressive! I really like it how you managed to pack everything there's needed to control the motor in this tiny board, and even with a current sensing circuit - something I conveniently forgot about (I didn't publish my h-bridge board yet, but now I don't even think it would make much sense - yours is very clean).

Are you going to make the pcb's yourself or going to order them? I do mine myself and it's going to be a hot day in heaven before I dare to try a dual-sided board again.

As for current sensing, I think you need at least an RC filter on CSENSE. Cutoff frequency must be about 1/2-1/4 of Fpwm, methinks.. There's still some space on your board to put 2 more little components. Otherwise it must be pretty hard to be sure that you sample the current precisely during the high phase of PWM, and barely possible at all when duty cycle is short.

BTW, what design/layout software you're using? I use EAGLE and I can't find those fancy flags to mark nets there, so I have to draw some arrows myself. Just wondering if I'm missing out on something.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd try printing the encoder wheel pattern with a laser printer. Chances are the toner is carbon based and low reflective.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gizmo wrote:
I'd try printing the encoder wheel pattern with a laser printer. Chances are the toner is carbon based and low reflective.

Yes, I thought of that but the wheel is very small and the optical parts I use are very large. It would mostly have cosmetic value.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

svofski wrote:
I've been busy with building a shaft encoder that can fit inside of a standard RC servo. I wrote a report that hopefully might be useful to fellow freaks who are into slowly spinning stuff, even though it's not directly related to AVR.

http://www.sensi.org/~svo/shaft_encoder

Please share your comments and criticisms.

You might look into using the P5587 photoreflector instead of the discreate LED/emittier pair.

http://acroname.com/robotics/parts/R64-P5587.html

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you. I know about P5587 part, but it's not available here, at least not in small quantities, that's why I did the thing in the first place.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's what I did many moons ago...
http://www.parex.org/weblog/archive/000033.html

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

svofski, regarding my servo control circuit. I've had concerns about the current monitoring and I'll add in a small RC circuit as you suggest. I'll also play with it on my prototype to make sure it works as expected.

I plan on getting the board manufactured by ExpressPCB. I've used their free software from their site to put together the circuit drawing as well as the PCB design. I haven't used other software so I can't compare, but it's worked fine for me so far. I should be able to get 18 boards made for about $51 -- less than $3 a board which seems like a good deal.

I've just worked out the TWI/I2C control protocol over the last two days. From the outside the board will look like 32 byte wide registers that represent the state of the servo. These registers are read from and written to using the same TWI/I2C sequences that one would use on an I2C EEPROM. There are also command messages to perform miscellaneous tasks such as write enable certain registers, enable/disable PWM generation and store defaults into the AVR EEPROM.

This project is my reintroduction back into embedded systems after nearly a 20 year hiatus. I looked at a number of different MPU families, but I'm glad I settled on the AVR to play with. The tools have been great and the information on this forum invaluable as I lurked around. I really like the fact the AVR community seems to have a single watering hole such as AVRFreaks where people of all different skills can share ideas and get questions answered.

I'll keep you updated as I make more progress on my servo design.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Regarding a shaft encoders, I always thought it would be interesting to attempt to use a an optical mouse sensor to directly detect rotation of a disc or shaft. The following application note (warning, non-AVR related) shows an easy way of hooking to such a sensor in a hacked optical mouse:

http://www.kronosrobotics.com/An...

The surface observed by the sensor would just have to have enough features for the DSP internal to the sensore to detect movement. The sensor would then give a steady output of direction and rate of rotation.

Has anyone heard of such a sensor being used for shaft encoder purposes before? Perhaps it's just a silly idea.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mpthomson: of course optical mice can be used. I made an "arcade cabinet" a couple years ago and I used an optical mouse (got one semibroken for free, isn't it good to know how to handle an iron and some wires?) to make a spinner control, kind of like those in Arkanoid cabinets. I used floppy drive, a custom-made knob and below there is an optical mouse that "sees" the bottom of the spinning disc. They work, but I've never tried to actually use the chip in a circuit - I just used the mouse as mouse, plugged it into a usb port. As for the surface that can be sensed by mouse camera/DSP - that thing is pretty badass, it reliably feels nearly everything except for clean mirrors. E.g. if it's a non-glossy white paper, it has enough tracking features already. I think the idea is not silly per se, but it's impractical due to high cost of mice and it's hardly possible to order fresh chips like that. OTOH, together with some adjusting optics to make it able hang higher away from the ground, it may be used for tracking and odometry pretty well.

Here are some pics:
http://sensi.org/~svo/garson.org-svo/public_html/photo/unindexed/arcade/spinner1.jpg
http://sensi.org/~svo/garson.org-svo/public_html/photo/unindexed/arcade/spinner2.jpg
http://sensi.org/~svo/garson.org-svo/public_html/photo/unindexed/arcade/spinner3.jpg
(WARNING: not AVR-related and features duct-tape construction!)
That directory (...../arcade/) also has some more pics of the cabinet, too. I love those old games.

And regarding chosing the AVR for the comeback - my congratulations, you can't go wrong with AVR :) Please keep us updated on your progress.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a servo open right now just to peek around. You could use the primary gear coming off of the servo motor itself as a mouse wheel easily just by drilling holes in it at the proper spaceing. There's really not enough room to mount a encoder wheel (like from a used mouse) but the bigger problem is finding space to mount the optics in the first place. The clearance from the primary gear to the start of the base of the case is less than .5mm's and the clearance above the gear is only 1.5mm's or so. Try cramming an opto interupt (solidly mounted mind you) into that space, not gonna happen. Servo's generally take a lot of abuse so you really have to make them solid. Inserting sub miniature magnets into the primary disk and using a hall effect sensor mounted nearby sounds little more plausible to me. Just under the output shaft (which is connected to the feedback POT) there is quiet a bit of space for stuff, (like a hall effect sensor) and if it's sensative enough a pair of magnets on the servo motor primary gear (to ballance it) would probably work pretty well. Though finding magets small enough might be a problem, unless you want to drill a whole in the gear and embed them into it. https://secure.avdns7.com/~scitoys/ sells some minature magnets that might possible fit if altered. The nice thing about magnets and hall effect sensors vs an opto interuptor is you only need an electrical connection on one side, so it's easy enough to embed the magnets in the gear itself.

-Curiosity may have killed the cat
-But that's why they have nine lives