Go Down

Topic: Servo moves eratically [solved] (Read 5686 times) previous topic - next topic

Evekites

Mar 06, 2014, 10:53 pm Last Edit: Mar 09, 2014, 10:04 pm by Evekites Reason: 1
This problem was solved, see my posts dated:
« Reply #10 on: March 07, 2014, 06:12:04 pm »
« Reply #12 on: March 08, 2014, 05:59:06 am »



I'v got a problem with a sketch controlling a self-made cable to trigger a Canon point and shoot camera, a standard servo for tilting the camera and 1 continuous rotation servo (bought, not modified) used for panning the camera. Purpose of this construction is taking pictures hanging on a kite line (it is a so called KAP-rig, Kite Arial Photography). The whole is powered by two 18650 batteries (2 x 3,7 V), the servo's are powered by the Arduino, but they will never move at the same time.

The problem is that the standard servo moves erratically once in a while. At that point it moves up and down in a random way, sometimes it picks up the right direction at the next tiltstep, sometimes it wont recover at all. Things I tried to diagnose and or solve this problem includes:

- Testing the servo with A servo tester (no problem).
- Swapping the servo with another identical servo. The first servo behaved normally in another KAP rig making the same tilting and panning movements (not controlled by Arduino).
- Replacing the Boarduino (thought that the inaccuracy of the resonator could be the problem) with a Arduino Nano clone.
- Moving the trigger cable from D10 to D4.
- Replace servo,write(degrees) by servo.writeMicroseconds(uS)
- I even tried the SoftwareServo library.

Changing hardware (replacing Arduino, changing port, replacing servo) at first solved the problem, but after some time the problem re occured.

I've done tests at home with the above equipment for runs of 1 hour or more, without a problem. But when the problem occurs I'm not able to solve it. Yesterday evening I tested the equipment for 1,5 hour without a hitch, but today when I tried the KAP-rig outside the problem was back again. Bummer!

The following is a short description of my sketch:
The standard servo tilts the camera in a few steps from straight ahead to facing down (0-90 degrees), after every tilt step a pulss is given to the camera to trigger a shot. After reaching 90 degrees, the continuous rotation servo turns about 45 degrees and the tilt servo moves to the straight ahead position.

I hope somebody has any idea.

Erik


The code, in case someone is interested:

I hope
Code: [Select]
// Auto KAP
// Erik Verberne
#include <Servo.h>

int USBCHDKpin = 4;
int PanServopin=11;
int TiltServopin=12;
int LEDpin=13;
int DelayAfterPhoto = 8000;

Servo TiltServo, PanServo;

int Tiltpos = 0;    // variable to store the servo position
int TiltDelay = 1000; // Time for camera to stabalize after Tilt
int TiltForwards = 0; // Straight ahead
int TiltDownwards = 90; // Facing down
int TiltForwards_ms = 950; // Pulse to instruct tilt servo to face straight ahead
int TiltDownwards_ms = 1830; // Pulse to instruct tilt servo to face down
int Tiltsteps = 3; // # steps to face down, after facing forwards
int Tiltstepsize = (TiltDownwards-TiltForwards)/Tiltsteps; // stepsize in degrees

int PanDelay = 1000;
int Panmove = 110; // Pulse to instruct PanServo to turn Clockwise
int Panstop = 95; // Pulse to instruct PanServo to stop turning
int Pan360 = 2400; // Duration at speed: Panmove for PanServo to make 1 rotation
int Pansteps = 8; // 3 steps in 1 rotation
int Pandegree = Pan360/360; // Duration at speed: Panmove for Panservo to turn 1 degree
int Panturn = 360/Pansteps; // # degrees for 1 step

void setup()
{
 TiltServo.attach(TiltServopin, TiltForwards_ms, TiltDownwards_ms);
 PanServo.attach(PanServopin);
 pinMode(USBCHDKpin, OUTPUT);
 pinMode(LEDpin, OUTPUT);  
 Serial.begin(9600);
 digitalWrite(USBCHDKpin, LOW);
 digitalWrite(LEDpin, LOW);
}

void Tilt(int Tiltpos)
{
   if (Tiltpos+Tiltstepsize>TiltDownwards)
   {
     Tiltpos=TiltDownwards;
   }
   TiltServo.write(Tiltpos);
   Serial.print("Tilt to ");
   Serial.print(Tiltpos);
   Serial.print(" wait a moment, ");
   delay(TiltDelay);
}

void Pan(int Panstop)
{
 Serial.print("Pan");
 Serial.println(Panturn);
 PanServo.write(Panmove);
 delay(Panturn*Pandegree);
 PanServo.write(Panstop);
 /*delay(PanDelay);*/
}

void loop()
{
 int servoms=0;
 Serial.println("KAP start");
 for (Tiltpos=TiltForwards; Tiltpos<= TiltDownwards;Tiltpos=Tiltpos + Tiltstepsize)
 {
   Tilt(Tiltpos);
   f_shoot();
 }
 Pan(Panstop);
 f_shoot(); /*first Pan, then take another picture facing down*/
}

void f_shoot()    
{
 Serial.println(" & then shoot");
 pulse(1);
 delay(DelayAfterPhoto);
}

void pulse(int number)
{
 for (int counter=1;counter<= number;counter++)
 {
   digitalWrite(LEDpin, HIGH);
   digitalWrite(USBCHDKpin, HIGH);
   delay(110); /* pulse length, at least 100ms*/
   digitalWrite(USBCHDKpin, LOW);
   delay(60);  /* gap between pulses, at least 50ms, but less than 500ms*/
   digitalWrite(LEDpin, LOW);
 }
 delay(510); /* gap between pulse trains at least 500ms)*/
}

regor2

#1
Mar 06, 2014, 11:19 pm Last Edit: Mar 08, 2014, 07:19 pm by regor2 Reason: 1
I have been having the exact same problem. Is the servo a Hitec digital servo? I have been using these :here
And the sevos after a minute begin to move extremely erratically when they are on my robot arm!
Arduinos: 9 Megas, 5 Unos, 2 Nanos, 10 ethernet

Robin2

Am I right in thinking that everything works OK indoors but has problems on the KAP- rig?

Can you describe the KAP-rig and perhaps post a wiring diagram.

Might there be a problem with long wires causing loss of power, loss of signal or picking up interference?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Evekites

Hi regor2,

Sorry, it's not a Hitec, but a SpringRC SM-S4303B http://www.kapshop.com/Rig-Parts-Servos/c6_43/p336/SpringRC-SM-S4303Bearing/product_info.html.

I brought back my KAP-rig to my study and at this moment it's running fine!!! I whis I knew what triggers the problem.

Are you also powering your servo from your Arduino?

regor2

Hi EveKites,
The servo you have there looks like its designed to be lightweight, think its the servo?

Second:
No, I am powering the servos right off the battery- if you are powering your servo off the arduino that might be the problem.
Arduinos: 9 Megas, 5 Unos, 2 Nanos, 10 ethernet

Evekites

Hi Robin2,

Today was the first time runnig the KAP-rig outside. But the problem also occured inside. One time it ran for 1 hour, then suddenly moved randomly. Turn the power switch off and on, ran it for 1,5 hour without any problems. To bad, switching it off and on does not always solve the problem.

Wiring diagram in words:

The Nano is situated on a Nano Sensor Shield.
Power supply, directly to the power connector of the Nano Sensor Shield (red cable goes through a Tumble switch).
Original Servo cables directly connected to Nano Sensor Shield.
Trigger cable is made of a USB cable (25 cm), one end mini USB and the other end has the same kind of connector as the servo's (black to gnd and red to signal) and connected to the Nano Sensor Shield.

For the Boarduino I used perfboard with 3x3 male header pins to connect the servo's and trigger cable and two rows of 15 female header pins to connect to the Boarduino.

Evekites


The servo you have there looks like its designed to be lightweight, think its the servo?

The servo is sold by the KapShop for this purpose. The camera only weighs 110 grams, make this 140 grams together with the frame and tripod screw. The camera is balanced so the torque should be minimal. I wouldn't mind replacing it, if it realy is the servo causing the problem, but I'm not sure yet  it's the servo, because I think a lightweight servo suits my needs.

The servo served it's purpose already controlled by a ClickPan Pro http://www.kapshop.com/Rig-Parts-Motion-Control-clickPAN/c6_81_71/p342/clickPAN-PRO/product_info.html for hours without any problems. The ClickPan pro was powered by 4xAA. Inside the ClickPan Pro is some sort of PIC controller.


If you are powering your servo off the arduino that might be the problem.


The Arduino documentation says:
Note that servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino).
http://arduino.cc/en/reference/servo#.UxkAZ-ddUXI
Since only one servo is moving at a time, this shouldn't be a problem.

zoomkat

Quote
Since only one servo is moving at a time, this shouldn't be a problem.


looks like you may have made yourself a sh*t sandwich and now asking why it taste strange. I suggest you try powering the servos from the batteries and not the arduino. note that 6v servos may operate erratically at 7v.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Evekites


I suggest you try powering the servos from the batteries and not the arduino. note that 6v servos may operate erratically at 7v.

This is the reason I hesitated to power the servos from the batteries. I could try a step down voltage module I have around, but this is extra weight, space and modification to the cables  (but perhaps I can now get rid of the Nano Servo Shield, thus saving weight and space again)  But before I'll try this I have one more experiment to try. Yesterday before I went to bed, I noticed that removing the trigger cable during the erratical movement, the servo started to act normal again, reconnecting the trigger cable made the servo act strange again. This means either a defective trigger cable (so I will make a new one), or an increase in current, so the need for the servos to power from the batteries as you all suggested. Even connecting the trigger cable to another port (without changing the sketch).  has the same result.

I'll keep you posted.

zoomkat

Quote
I could try a step down voltage module I have around


Just add a diode like below in the servo power wire to drop the voltage by ~.7v.

http://www.radioshack.com/product/index.jsp?productId=2036270
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Evekites

Here is an update of my last experimenting. It looks like I found the problem (I'm running a duration test right now).


A
I came to the point that every time I connected the trigger cable to the Arduino, the tilt servo started to move randomly, removing this cable solved the problem. At this point this cable seemed to be the problem. Replacing the cable by a cable bought at the KAPshop didn't solve the problem.


B
Separate regulated power supply for the servo's (5V)
Separate power supply for the Boarduino (regulated to 5V by the 7805 onboard of the Arduino)
Connected GND of both power supplies to each other.
Trigger cable connected to camera's USB port and the other end to the Arduino.
Camera is not mounted in the KAP rig, but standing on the table.
==> No problem at all


C
As soon as I mount the camera on the KAP rig (with a tripod screw), the tilt servo starts moving randomly. Removing the Tripod screw everything is fine again. Somewhere there is an unwanted electrical connection between my Arduino, the tiltservo, the USB cable and the camera. So something to investigate.


1  Using  a multimeter it shows that the gnd connector of the USB cable is connected to the tripod mount inside the camera, this is by design I think, so no (easy) changes possible here.

2 The tripod screw is made of metal and connects the camera electrically with the camera mount (only gnd).

3 The camera mount is made of aluminum, one side is isolated from the rest of the rig by a plastic pivot point, so at this point no electrical connection.

4 The other side of the cradeis attached to the tilt servo. 2 screws to the plastic horn, so also no electrical connection.

5 The two screws connected to the plastic horn is not secure enough to carry the weight of the camera, so a third screw is used throught the middle of the horn inside the tilt servo. At this point there could be an electrical connection between the camera mount and the tilt servo.



Point 5 looks promising.  At this moment, I loosened the middle screw by 2 mm and the tilt servo runs fine now. I even removed the 2nd power supply, using power directly from my Arduino. Everything looks nice. Then I cut about 2 mm from the end of the middle servo screw. Everything seems fine now.

I'm running a duration test right now, keeping my fingers crossed.

Next Sunday will be a nice day to bring my KAP-rig in the air, the weather forecast looks promising, sunny, 15-19 degrees Centrigrade, 3 bft wind!


Robin2

Full marks for a clear and logical presentation.

It should be used as an example to others.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Evekites

Thanks Robin2 :), but that's all part of being a forum member. I hate it when OP's close the discussion with just "I solved the problem, bye bye", without telling the solution they used.

This morning my KAP rig panned and tilted without any problems for at least 2,5 hours at one run. The only change I made to my original design was shortening the middle screw at the Servo, thus preventing some kind of short circuit. Servo's are powered through the Arduino again.

Off topic:
Three months ago I started playing with Arduino and in the mean time I documented all my findings (libraries, datasheets, specs, connections and sample sketches for about 70 plus sensors and actuators). I've put this together in a 200 plus pages Word and want to share this with the Arduino community. Could someone suggest a good place to post this document?

Robin2


I've put this together in a 200 plus pages Word and want to share this with the Arduino community. Could someone suggest a good place to post this document?


I've uploaded some stuff to Google Drive and then posted links to it here. There may well be a better way.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Evekites

My problem is gone, cutting 2 mm of the middle screw at the Titl servo removed the short circuit. Everything is fine now.

Today my KAP-rig was in the air for 3-4 hours in total, I only had to replace the battery of my camera, the 18650 batteries are still working.

I will post some pictures of my KAP-rig and of the photo session tomorrow evening.

Go Up