Using SG90 servos with Mega and PCA9685

Hi, I am using a Mega to control 16 SG90 servos connected to a PCA9685 the sketch I have which I modified to switch 16 servos is used for point control on a Model Railway..

The question I would like help on is do I need to detach or disable the servos when they have changed position which is normally 0 deg then 60 deg when point thrown..

I have seen on other web sites a command "servo.detach();" but do I need to add this on each servo at the end of the move or not.. or is it better to leave the servo live..

Regards John

If you detach() a servo it is normally free to move and will not hold its position. Apart from current consumption and the chance of the servo making a noise whilst holding its position there is normally no need to use detach()

I am not familiar with the PCA9685 so the normal advice may not apply. Incidentally, I assume that you are using an external power supply for the servos and not the Arduino 5V output

Thanks for that I wasnt sure if Servo would get warm if left in one position the basics are the servo is mounted and the arm has a piece of piano wire which goes throught the base board and through a hole in the point movement and rocks from left to right to change the point similar to a Tortoise Switch machine which are quite expensive ... the PCA9685 works from the I2C bus and can switch up to 16 channels or servos etc and is powered from a seperate 5 volt power source and NOT from the Arduino..
In saying that it does have a 5 volt and Gnd to the end connectors think this is for the 9685 chip ... you can also add other PCA9685 and change the address to give near 1000 channels..
Thanks

Regards John

Tortoise Switch Machine.JPG

Servos don't generally get damaged by constantly writing to them as long as they can freely reach and stay at the commanded position. What is not acceptable is to say command a servo to move to an angle of 100 and have it stall at an angle of 90 degrees because of a physical obstruction. It looks like the Tortoise switch tries to ameliorate such problems by using a thin, flexible wire to apply the force to the points.

There are users on here with practical experience of model railway control systems who should be able to provide help based on their own experience

UKHeliBob:
Servos don't generally get damaged by constantly writing to them as long as they can freely reach and stay at the commanded position. What is not acceptable is to say command a servo to move to an angle of 100 and have it stall at an angle of 90 degrees because of a physical obstruction.

I agree with that.

I am helping with a Club model railway using a similar mechanism for connecting the servos to the turnouts. The piano wire provides a degree of flexibility but it would be well to arrange the motion so there is as little force as possible on the servo when the turnout blades are in either position. Then the natural friction in the servo gears will be sufficient to hold the position and there will be no load on the motor.

I have found it impossible to stop the servos we are using (cheap Hobby King digital servos) from making noise when supposedly stationary so I have recently changed the software so it only attaches the servo for the period of motion.

...R

Another thing which have as yet not found the answer when using the PWM command for the PCA9685 so I have a line :-

pwm.setPWN(9,0,200) // servo no 9 active...

I understand the 9th servo on PCA9685 and the 200 is the SERVOMIN I have set, but what is the "0" for in the middle of the 3 numbers as it always seems to be a zero....

John

UKHeliBob:
Servos don't generally get damaged by constantly writing to them as long as they can freely reach and stay at the commanded position. What is not acceptable is to say command a servo to move to an angle of 100 and have it stall at an angle of 90 degrees because of a physical obstruction. It looks like the Tortoise switch tries to ameliorate such problems by using a thin, flexible wire to apply the force to the points.

The Piano wire I am using is only 0.70 mm and is quite flexible..and works on point well..

John

John40131:
pwm.setPWN(9,0,200) // servo no 9 active...

I understand the 9th servo on PCA9685 and the 200 is the SERVOMIN I have set, but what is the "0" for in the middle of the 3 numbers as it always seems to be a zero....

Basically channel (9), count from 4096 when pulse goes high(0), count when pulse goes back low (200). Gives a pulse 200 long starting at 0. The start point could be another number but it's true that 0 is most normal.

Steve

Hi, Thanks for help, just setting up the Mega with 16 inputs to control, plus LED functions on certain turns my sketch is probably a bit long winded but it works..

Regards John