Go Down

Topic: how to program for the rotary encoder (Read 732 times) previous topic - next topic

sihotang_hansen

dc motor with rotary encoder is a new thing for me , can someone tell me an example for the program?

please see attachment for the motor dc

howiem

You'll need to do a few things, but thankfully there are pre-written Arduino libraries that'll do a lot of the work for you.

1. Get the rotary encoder working (Google "arduino quad encoder") - your aim is to be able to turn the rotor by hand and have the Arduino tell you its position.

Now the Arduino can track the motor's position, you need to be able to control the motor.

2. Get the Arduino to control the motor - for this, you'll probably need to build or buy a little motor driver. The Arduino won't have enough power to be able to control the motor directly, but there are little boards available on eBay for a few $ that accept a variable PWM input from the Arduino, and use that to drive the motor in whichever direction and with however much power / speed you want. (Google "arduino motor controller ebay")

Now you can make the motor move, and you can track its position.

3. To combine the two, so you can get the Arduino to, say, make the motor turn by 3 revolutions and then stop, you can use a PID control routine. There's an Arduino library already created for this (Google "Arduino PID").

Good luck :)

arssant

Hi.

This is your motor on the photo ?
Did you get it from a scanner or a printer ( HP ) ?
I got some of these from HP printer and multifunction officejet printer.
With so many wires, it's looks like a quadrature rotary encoder.

Nice tutorial here:

http://heliosoph.mit-links.info/make-your-own-quadrature-rotary-encoder/

http://heliosoph.mit-links.info/rotary-encoder-software-for-arduino/

Go Up