I'm looking to use a servo to pull on a cord. The cord is attached to a bell.
I have two questions:-
Given that the servo can't "spin", and can only move 180deg max, I'll need to find a way to increase the travel...any tips?
Code to drives servos seems fiendishly long and complicated. I was hoping there would be a function that would make interfacing with the library nice and tidy and simple...does anyone know of one? Essentially I am just looking for a nice bit of code to "sweep" the servo back and forth once without using delay. I've found the below.
#include <Servo.h>
Servo myservo; // create servo object to control a servo, max = 8 servos int myservo_pin = 9; // pin that controls the servo int myservo_speed = 5; // how fast the servo moves, 1 = very fast, 10 = very slow long myservo_movetime = 0; // next time in millis servo next moves int myservo_gPos = 0; // target position to move towards int myservo_cPos = 0; // current postion of servo
int pos = 0; // variable to store the servo position int cPos; // current position int gPos; // goal position int tDelay = 5; // delay between moves, gives appearance of smooth motion
void setup() {
myservo.attach(X); // attaches the servo on pin 9 to the servo object
Serial.println("setup complete : smooth servo movment without delay v1"); }
void loop() {
cPos = myservo.read();
if (cPos == 0) gPos = 180;
if (cPos == 180) gPos = 0;
if (cPos != gPos && millis() >= myservo_movetime) {
moveServo();
}
if (Serial.available() > 0) { GetCommand(); } }
void moveServo() {
if (cPos < gPos) myservo.write(cPos+1);
if (cPos > gPos) myservo.write(cPos-1);
//if (cPos == gPos) // nothing
myservo_movetime = millis() + tDelay;
}
void GetCommand() {
int command = Serial.read() - '0';
int mVal = command;
if (mVal == 'x') {
tDelay = tDelay * 10;
} else {
tDelay = mVal;
}
Serial.print("Pauses changed to : "); Serial.print(tDelay); Serial.println(" mSeconds");
Serial.flush();
}
To extend the effective travel you can extend the servo arm. As long as you keep it within reason you won't overload the servo. The other option is to look for a continuous rotation servo, but then returning to a position is a problem.
An extended arm will produce a non-linear response to the servo rotation (in fact it's a sine function) you could use a capstan cylinder mounted onto the servo shaft. This will then produce a linear movement with respect to servo rotation. Assuming the servo offers 270 degrees of rotation (3/4 of a circle) a drum of diameter D will provide a pull movement X = 3.142 x .75 x D So if you have determined how much movement X you want, the drum diameter D needs to be X / (3.142 x .75)
To prevent overload of the servo if the rotation tries to exceed the permitted movement of the bell cord you can use a spring in the pull cord.
An image linked above shows a capstan with spring in the cord I made for a remote controlled camera
jackrae:
An extended arm will produce a non-linear response to the servo rotation (in fact it's a sine function) you could use a capstan cylinder mounted onto the servo shaft. This will then produce a linear movement with respect to servo rotation. Assuming the servo offers 270 degrees of rotation (3/4 of a circle) a drum of diameter D will provide a pull movement X = 3.142 x .75 x D So if you have determined how much movement X you want, the drum diameter D needs to be X / (3.142 x .75)
To prevent overload of the servo if the rotation tries to exceed the permitted movement of the bell cord you can use a spring in the pull cord.
wouldnt it be a lot easier to just use a solenoid? that will give you a 'jerky' movement on your chord and you could use and arm/pivot setup to increase the travel. then all you're dealing with is a relay and a digital output
scott_fx:
wouldnt it be a lot easier to just use a solenoid? that will give you a 'jerky' movement on your chord and you could use and arm/pivot setup to increase the travel. then all you're dealing with is a relay and a digital output
Something like this? That should work with the Arduino, right?
So I guess it would need to normally be "thrown" and then when activated "not thrown" to tug on the bell cord... Won't that constantly be drawing current?
I'll let the more informed members comment about if the arduino can power it or if you need a relay and external power supply. but, yeah that is the type of thing you can use. depending on the amount of force you need you can go larger too.
it'll only draw current in one state. while it's at rest it draws no current.