Help needed with GWS S125 Winch Servo Control.

Hey guys - Need some help with my servo control !

Video explains all !

http://www.youtube.com/watch?v=_6i6ALS6hnA

Im trying to connect servos to control knobs on various devices such as signal generator to allow remote control of the device. Any comments or suggestions are greatly appreciated !

Are you really driving it with PWM (hard to tell from the scope trace)? Don't.

You say it is a 1.5 turn device. This is 540 degrees, which by an odd coincidence is twice the range (270 degree) you said you needed. What about simple gearing or pulleys and drive belt?

Thanks for the reply - Im using the 'Knob' sketch which comes with the arduino software to drive it at the moment, this is usually used for 180degree servos, im guessing this is why the proportionality of the control is different with this servo.

How else can you drive a servo without PWM??

Id like to avoid a gearing system - i want to connect the servo with suction pads directly to the thing i want to move - im going to connect it to a synthesiser control knob to allow remote control of it . What do you think? SI

How else can you drive a servo without PWM

By using Pulse Position Modulation, which is what an R/C servo is designed for. May look similar, but the standard R/C PPM rate is 50Hz, whereas the Arduino PWM rate is closer to 500Hz.

However, if you're using the knob demo, I guess you're using the servo library, which gives PPM.

I see .. :blush:

Ive never played with servos or arduino before so sorry about the noobish questions.

The 'knob' example comes with the demo sketches im confused is that a PWM or PPM sketch?

So within the servo library should there be a PPM function?

I can’t see your sketch (hint), but I assume you’ve included the servo library.
There is no explicit mention of PPM, but the “Servo.write()” method controls the generation of a correctly timed 50Hz PPM waveform.
It is difficult to tell the difference between PWM and PPM from a scope trace, because I can’t read the timebase value from your video.

Roughly speaking, a 50Hz (20ms period) PWM signal with a 5 to 10% duty cycle would be correct to drive a servo, but if you’ve only got 8 bit PWM resolution, you’d have very coarse control.

Without seeing your code, you will be pretty much on your own, Below is some servo test code where you can send positions to the servo via the serial monitor. You should be able to see the max rotation speed of the servo and how well it can respond. Do note that your servo may rotate at 1/3 the speed of a normal large servo.

// zoomkat 10-27-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Servo.h default servo position 1500 on startup
// for Arduino IDE 0019 and later

#include <Servo.h> 
String readString;
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {

  while (Serial.available()) {
    delay(10);  

    char c = Serial.read();  //gets one byte from serial buffer
    readString += c;
  } //makes the string readString

  if (readString.length() >0) {
    Serial.println(readString);
    int n;
    char carray[6];
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
    myservo.writeMicroseconds(n);
    //myservo.write(n);
    readString="";
  } 
}

Thanks for replies all -

Timebase was set to 0.1 ms

As i mentioned before the sketch is the standard ‘knob’ which comes with the software. Im using an UNO running the servo from a separate bench supply to the Arduino . I want to be able to get three of these babys running independently of each other eventually!
knob sketch =
#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

I basically want to use the knob sketch but with 3 separately controlled winch servos.

Ill try the zoomkat code thanks for that -
I don’t really understand how it can be that difficut to control the servos, surely you can edit the knob sketch to house more than 180 rotation??

I don’t really understand how it can be that difficut to control the servos

It is remarkably easy to control servos.

surely you can edit the knob sketch to house more than 180 rotation??

The 0…180 is just a convenience - the Arduino has no idea how far the servo is capable of turning, it just maps the range 0…180 into 1…2ms pulse length.
Some servos aren’t even capable of 180 degree turns.
If you want more flexible control, look at the “writeMicroseconds” method in the Servo library.

thanks - i have been looking at writemicroseconds() - could i just pop that function into the knob sketch do you think?

Yes, but don't forget to re-scale the reading from the analogue input - try using "map".

thanks ill give it a go this week and post the results!

i tried putting writeMicroseconds() Into knob but i couldnt seem to get it to work - the code zoomkat posted allowed me to control the servo with serial commands - i need to either be able to control those serial commands with the potentiometer value as the variable or somehow get the variable to work with writeMicroseonds() .. any ideas/code examples on how to do this?

i tried putting writeMicroseconds() Into knob but i couldnt seem to get it to work

Be aware that the range of values accepted by writeMicroseconds is higher than the standard write method - what values did you use? Typical pulse lengths are from 1000 to 2000 microseconds, though the method allows values outside this range. Can you post your code?

include "Servo.h"

Servo myservo;

int potpin = 0; // analog pin used to connect the potentiometer int val;

void setup() { // attaches a servo connected to pin 9 myservo.attach(9); }

void loop() {

myservo.writeMicroseconds(1500);

}

this is the code what im trying to do is very simple but i am not familiar with coding to be able to do it i know the 1500 is a specific angle - id like to have this value as a variable, controllable by the potentiometer input (of which there is no mention in this code as i don't know how to do this)

val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)

You need to make a very few changes to this code.

AWOL: val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)   val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)

You need to make a very few changes to this code.

thanks for help so far i added that code to the original it turns and keeps on going in one direction...

include "Servo.h"

Servo myservo;

int potpin = 0; // analog pin used to connect the potentiometer int val;

void setup() { // attaches a servo connected to pin 3 myservo.attach(9); }

void loop() { // sets the servo position at 180 degrees

val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) myservo.writeMicroseconds(val); delay(15); }

You need to make a very few changes to this code

OK, I don't see the changes you made. Remember, you need to re-map (hint) the interval 0...1023 to something more like 1000...2000

ok ive changed it to this

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 1000, 2000); // scale it to use it with the servo (value between 0 and 180)
myservo.writeMicroseconds(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
seems to work im going to make another vid this week
cheers x