Go Down

Topic: Motor range auto calibration (Read 2761 times) previous topic - next topic


Hello guys!!!

I would like to know if its possible and how to program a specific function related with arduino, motor and a motor encoder.

assuming that I have the encoder connected to the arduino and the motor controller is a TTL / PWM one

So, what I need is:

having a moving device equipped with the motor and encoder which moves in some kind of tracks, knowing that these tracks can have different lengths, because of this variable length, I would need to have an automatic length calibration function.

Let me explain....

some code that start the device movement into one direction until it reaches the edge, recognize that the device is not moving anymore, read the encoder value and assume it as an electronic edge, once done, it goes into the oposite edge, stop when the edge is reached, read the encoder value and mark it as the oposite edge.
Now the device's code know from each max and min values it can work.... like an electronic boundary.

Now you ask me...  Why don't you use limit or calibration switches??? Because I can't..  I have to work only with the encoder readings and motor movement detection as this is for something as big as a finger. The device on tracks was only an easy way to picture describe it.

I hope I have explained it in an easy way.

Can somebody help me?

Thank you



Set the motor heading in one direction and monitor the encoder - when it stops changing kill the power
and set one endpoint.
Repeat for the other direction.

Avoid using too much drive if the motor is powerful enough to do mechanical damage.

If the motor controller can set a maximum current you can use this to reduce max torque during this
homing phase.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Hi Markt,

I really appreciate your effort but I know that.. I would like to see how it is done in terms of code.

You are right, the calibration speed will be around 10% or so.. to avoid mechanical damage.



What code do you have already then?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


At this point I don't have a code yet... I am just trying to realize if it doable.. later I would need a bit of support because I don't think that my coding knowledge is not enough to do it.


Well you certainly can do it,    but I am not going to try and write code for you,  it would be about four
pages long.

The problem with your approach is going to be,  the repeatability.   The wheels are going to slip somewhat
on the track,  that is almost inevitable.   So even if you can "calibrate" the end positions  using the encoder,
it is not going to be repeatable when you actually use the mechanism for it's intended purpose.

What you perhaps need is some physical reference point so that you can continually adjust the calibration
for the cumulative wheel-slip encoder error,   which doesn't necessarily have to be at the end of the track.


Mar 25, 2013, 11:26 am Last Edit: Mar 25, 2013, 11:27 am by xrail Reason: 1

The assembling is like this... encoder on the back motor shaft and a gear in the from shaft...  as the "linkage" is made with a gear, there is no slip and no error.

No, I cannot add physic switches as I have told before, as this has to be as small as possible.

I can tell that I am trying to build a remote control to my photo DSLR camera which as a dented gear in the rings (in all my lens which has different ring rotation ranges)
The motors (one per lens function, focus and zoom) are mounted in some rods attached to the camera, and the motor gears put together with the lens rings gears... as you can realize, I have 0 (zero) encoder slip. If the motor reaches the lens ring max or min, it will certainly stop on that exact point.

Here you have an example of a similar device (motor to lens attachment) used in Cinema camera lenses.

Thank you


So those vertical gears drive the focus on the lens,   which part is moving those drives along the rails ?


I have given the example of the rail because is something easier to understand rather than an unknown professional lens control system.. it doesn't change anything... the function is always the same... go, stop, mark.... go inverse, stop, mark


The motor behaviour and requisite functionality that you desire calls for a PID algorithm to be implemented that I already did here >>

This provides for very precise motor position controlling, so one gets the position where the motor is and there is no further movement.
"Real Men can Accomplish  Anything"

- skype : nishants5  
ਫ਼ਤੇਹ ਕਰੁਂ!


Well...  is mostly this:



Go Up