Continuous rotation servo with feedback - how to run?

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Systembolaget
 
Posts: 335
Joined: Wed Mar 08, 2017 1:01 pm

Continuous rotation servo with feedback - how to run?

Post by Systembolaget »

Hi,

I have a Feetech FR5317M connected to a Metro Mini and wonder how I can implement what you explain in your servo with feedback tutorial https://learn.adafruit.com/analog-feedb ... g-feedback.

The servo's feedback pin outputs a voltage from the potentiometer inside, not a PWM signal.

The feedback has to be calibrated first by rotating the servo to two known positions, but obviously, that cannot be done out of the box with a continuous rotation servo.

Any ideas?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Continuous rotation servo with feedback - how to run?

Post by adafruit_support_bill »

Send a known pulse width to the servo. Then measure the position. It is now a 'known' position. Then you can measure the voltage on the feedback lead to correlate with that position.

User avatar
Systembolaget
 
Posts: 335
Joined: Wed Mar 08, 2017 1:01 pm

Re: Continuous rotation servo with feedback - how to run?

Post by Systembolaget »

Thanks, if I use

Code: Select all

myservo.writeMicroseconds(value);
with value ranging from 500 to 2500, the servo won't stop in a position, it only rotates forwards or backwards, slower or faster, so I can't measure anything meaningful on the feedback lead.

Any other ideas?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Continuous rotation servo with feedback - how to run?

Post by adafruit_support_bill »

The guide you referenced is for servos with an external lead for the analog feedback such as this one: https://www.adafruit.com/product/1404

The FR5317M - like most continuous rotation servos does not have any external feedback. In fact, even the internal feedback has been disabled. So by definition, they are not even servos: https://learn.adafruit.com/adafruit-mot ... vo-2875539

Parallax makes a continuous rotation servo with digital feedback: https://www.adafruit.com/product/3614

User avatar
Systembolaget
 
Posts: 335
Joined: Wed Mar 08, 2017 1:01 pm

Re: Continuous rotation servo with feedback - how to run?

Post by Systembolaget »

It sure has a (fourth) feedback wire, also says so in the spec sheet. I made a typo, it's FB5317M, not FR5317M.

How about hooking it up, feedback wire to A0, and then manually turning it to two positions, noting down the value at A0 for both positions?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Continuous rotation servo with feedback - how to run?

Post by adafruit_support_bill »

Not familiar with that model. Looks like it uses an AS5600 hall-effect encoder for the feedback.

Most (but not all) servos will disable active control in the absence of a control signal. If that is the case with the FB5317M, you should be able to power the servo with the control signal disabled and manually rotate it to known positions for calibrating the feedback.

User avatar
Systembolaget
 
Posts: 335
Joined: Wed Mar 08, 2017 1:01 pm

Re: Continuous rotation servo with feedback - how to run?

Post by Systembolaget »

The blurb says not Hall-effect sensor (like Parallax, for which there's feedback code), but good ol' potentiometer tapping.

I think I'll give the manual rotation method a whirl. If that works, one could augment the tutorial, because a calibrated continuous rotation servo (with feedback from a pot) one can rotate to an angle and then stop it there with 1500 milliseconds would be nifty.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Continuous rotation servo with feedback - how to run?

Post by adafruit_support_bill »

The Feetech site (translated) says: "AS5600 feedback line"
https://feetechrc.com/multi-mode-operat ... ction.html

The AS5600 is a hall-effect encoder that can do either analog or PWM output.
https://ams.com/documents/20143/36005/A ... 5_5-00.pdf
The AS5600 is a Hall-based rotary magnetic position sensor
using planar sensors that convert the magnetic field
component perpendicular to the surface of the chip into a
voltage.

User avatar
Systembolaget
 
Posts: 335
Joined: Wed Mar 08, 2017 1:01 pm

Re: Continuous rotation servo with feedback - how to run?

Post by Systembolaget »

All right, with the below, I obtain feedbackMin 0 and feedback Max 690 (values from 688 to 692 on multiple trials).

Now I have to write code that continuously compares feedback to a desired Min or Max value, and then stops the servo's rotation with

Code: Select all

myServo.writeMicroseconds(1500);
, when that value is reached.

Code: Select all

#include <Servo.h>

const byte pinServo = 6;
const byte pinFeedback = A0;

int feedback = 0;
int feedbackMin = 1023;
int feedbackMax = 0;

Servo myServo;

void setup()
{
  Serial.begin(1200);

  myServo.attach(pinServo);

  while (millis() < 7000)
  {
    myServo.writeMicroseconds(2000);

    feedback = analogRead(pinFeedback);

    if (feedback > feedbackMax) // Seek maximum
    {
      feedbackMax = feedback;
    }

    if (feedback < feedbackMin) // Seek minimum
    {
      feedbackMin = feedback;
    }
  }

  myServo.writeMicroseconds(1500);

  Serial.print("Min: "); Serial.println(feedbackMin);
  Serial.print("Max: "); Serial.println(feedbackMax);
}

void loop()
{
}

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Continuous rotation servo with feedback - how to run?

Post by adafruit_support_bill »

You will probably want to slow it down as you approach your setpoint to avoid overshoot. A PID algorithm is commonly used for that. Brett Beauregard's has an excellent PID library for the Arduino.
http://brettbeauregard.com/blog/2011/04 ... roduction/

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”