Go Down

Topic: HCPCA9685 with Contentious servos (Read 163 times) previous topic - next topic

aimmet

May 16, 2019, 01:13 am Last Edit: May 16, 2019, 01:14 am by aimmet
Hello all, I recently had to switch from the Sunfounder servo (180 degrees) to a Feetech FS5106R continuous servo. Im using the HCPCA9685 break out boards to provide better power and control to the servo. Previouosly, I Used a Joystick to control certain angles of a servo so that I can move it with in a given area, i got a servo bracket designed for the Feetech FS5106R so I removed the Sunfounder servo and put it in the Feetech but it keeps rotating. How can i Prevent this from happening? Below is my code
Code: [Select]

/* Arduino Multiple Servo Motors Control Using The PCA9685 PWM Module VERSION 1 PROPORTIONAL

Created by Yvan / https://Brainy-Bits.com

This code is in the public domain...

You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!

*/

#include "HCPCA9685.h" // Include the HCPCA9685 library created by Andrew Davies

#define I2CAdd 0x40 // Default address of the PCA9685 Module

#define JoyX A0 // Joystick X pin connected to A0 on the UNO
#define JoyY A1 // Joystick Y pin connected to A1 on the UNO

// Used to store the mapping of the Joystick X and Y values
int ServoXforward;
int ServoXbackward;
int ServoYforward;
int ServoYbackward;

HCPCA9685 HCPCA9685(I2CAdd); // Define Library to use I2C communication

void setup()
{
Serial.begin(9600);
HCPCA9685.Init(SERVO_MODE); // Set to Servo Mode

HCPCA9685.Sleep(false); // Wake up PCA9685 module
}


void loop()
{
int val1X = analogRead(JoyX); // Read current value of Joystick 1 X axis
int val1Y = analogRead(JoyY); // Read current value of Joystick 1 Y axis

// Map Joystick Axis values to servo Min and Max position
ServoXforward = map(val1X, 0, 1023, 402, 10); // Move servo 15
ServoXbackward = map(val1X, 0, 1023, 10, 820);

ServoYforward = map(val1Y, 0, 1023, 10, 820);
ServoYbackward = map(val1Y, 0, 1023, 820, 10);

// Move Servos to read postion from Joystick
HCPCA9685.Servo(15, ServoXforward); // Move Servo 15

{
Serial.println("pot below");
Serial.println(val1X);
delay(300);
Serial.println("Servow below");
Serial.println(ServoXforward);
delay(300);

}

Thank you for any help

Coding Badly


Please do not cross-post.  Other thread removed.


vinceherman

#2
May 17, 2019, 04:56 pm Last Edit: May 20, 2019, 02:40 pm by vinceherman
Hello all, I recently had to switch from the Sunfounder servo (180 degrees) to a Feetech FS5106R continuous servo. Im using the HCPCA9685 break out boards to provide better power and control to the servo. Previouosly, I Used a Joystick to control certain angles of a servo so that I can move it with in a given area, i got a servo bracket designed for the Feetech FS5106R so I removed the Sunfounder servo and put it in the Feetech but it keeps rotating. How can i Prevent this from happening? Below is my code

But it keep rotating...  Do you know that what you describe is exactly what continuous rotation servos do?
So, I say that this is behaving exactly as the equipment you have chosen should behave.

Why did you replace standard servos that have positional awareness with continuous rotation servos that have no positional awareness?

Go Up