I'm looking at the Feedback 360 Degree - High Speed Continuous Rotation Servo from AdaFruit.
What I don't understand is how the feedback of the current position is "formatted". The details say "PWM positional feedback across entire angular range" but does that get "averaged" in some way into a DC voltage...?
Or do I need to add a low pass filter to do the averaging myself?
Or do I need my software to measure the pulse width?
Or have I misunderstood something?
You have to measure the pulse width using Arduino's pulseIn() function.
1 Like
MrY
July 13, 2024, 4:17pm
3
Here is a link to a library that may provide the answer to your question.
1 Like
The Adafruit video mentions that the feedback is from an AS5600 sensor. See the data sheet for the details on the PWM output (page 27)
https://www.mouser.com/datasheet/2/588/AS5600_DS000365_5_00-1877365.pdf
1 Like
From the servo data sheet:
1 Like
But do I need a libary, can't I just use pulseIn() ? Genuine question, I have no experience with continuous servos...
Thanks, so I use pulseIn() with the formula you've shown me? Have I understood?
Finally got round to following your advice an I've implemented this for the Parallax 360 feedback servo, seems to work:
static const double kFeedbackFreq = 910.0 ;
static const double kFeedbackCycleTimeSeconds = 1.0/kFeedbackFreq ;
static const double kFeedbackCycleTimeMicroseconds = kFeedbackCycleTimeSeconds*1000000 ;
int Read_Servo_Angle()
{
// See how high the pulse is in microseconds
int iServoPulseFeedbackMicros = pulseIn (ikHoursServoFeedbackPin,HIGH) ;
// these also depend on your servo...
const double kDutyCycleMin = 0.027 ;
const double kDutyCycleMax = 0.971 ;
// Get a fraction from 0.027 to 0.971
double DutyCycle1 = iServoPulseFeedbackMicros/kFeedbackCycleTimeMicroseconds ;
// Convert to a fraction from 0.0 to 1.0
double DutyCycle2 = (DutyCycle1-kDutyCycleMin)/(kDutyCycleMax - kDutyCycleMin) ;
Serial.print ("DC1=") ; Serial.print (DutyCycle1) ;
Serial.print (", DC2=") ; Serial.println (DutyCycle2) ;
// Convert to an angle...
const double kDegsAngle = 180.0 - (DutyCycle2*360.0) ;
return int(kDegsAngle+0.5) ;
}