I need to control the position of a lead Screw Stepper motor using EMS22A Absolute Encoder? I've seen James Bruton do this in his video. can anyone help me?

James Bruton Video: https://www.youtube.com/watch?v=ngazw18f6zw

edit: What i did was to determine the "Largest Change" to count the number of cycle that has occurred. However, with fast rotation the program was not able to detect the change.

void loop(){

unsigned long currentMillis = millis();
pos = encoder.ReadAngle();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    pos2 = encoder.ReadAngle();
int change = pos2-pos;
if (change > 200){
if (change < -200){
if(change > 1){         
if(change < -1){
if(change <= 1 && change >= -1){
Serial.print(" ");
  • I've offered some general How-To, but you'll get better answers, and more to the point, if you can be specific about what kind of help you need, where you're stuck, etc.
    – JRobert
    Aug 14 '19 at 13:15
  • What exactly is your problem in doing so?
    – chrisl
    Aug 14 '19 at 13:31
  • What library do you use for the encoder? Please provide a link.
    – chrisl
    Aug 15 '19 at 16:06

The encoder attaches to the motor (or other) shaft and sends a 10-bit rotational position for a precision of 0.35 deg, and a claimed accuracy of +/- 0.7 degrees. It will be up to the application to keep track of number of rotations, detecting when the shaft has completed a rotation in either direction.

In a lead-screw application there will always be a little bit of backlash or "play". The leadscrew and nut cannot be perfect and must have a little bit of slop (technical term!) to keep the rotational friction low. This means that the nut will have some linear play, leaving that much uncertainty in the linear postion, even if the leadscrew angular position is perfectly known. Most applications manage this by turning the leadscrew back, to behind the target position, and then approaching the target in the forward direction. The leadscrew and nut position will have been calibrated for this direction. Of course it could be calibrated separately for each direction. The key is that the nut must be driven "behind" (for the particular direction) the target by more than the known linear play, to be sure the play will be entirely taken up during the approach to the target.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.