Go Down

Topic: Servos (or Servo Pins) are 'misbehaving" (Read 1 time) previous topic - next topic

coolaturon

Hey everyone,

I'm programming a quite big Programm which is meant to control a model boat autonomously.

At the Moment my Servo Pins do quite stranage things:

I'm using the Arduino Servo library. If I tell my Servo to go to the middle (or the Motor to go to zero speed) they continuously receive pulses to go in a certain direction. The Servo is turning to full 180 (or zero...I didn't exactly check which direction it is going) and back to the middle then to 180 again and back to the middle and so on. And the Motor is howling up as well, goind back to idle, howling up again ... Other positions except them around the middle position (so around 90) work just fine.

I checked the code twice, there is not even a command in the code which pushes these values so high.
I tried to add stronger external power which didn't work either.
I wrote a new little sketch only telling both Servo and Motor to go to the middle/zero speed ... it worked fine.

The variables in my navigation sketch are using around 75% of the RAM of the UNO-board. Might this be the problem?

What else could be the possible reason for that?

Thanks a lot in advance!

AWOL

Quote
checked the code twice,
"but I didn't think to post it"


zoomkat

Bad grounding/wiring or malformed servo control pulses can cause servos to operate erratically. If the servos are making noise, they are possibly trying to turn against the internal mechanical stops. How are the servos powered?
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

Robin2

they continuously receive pulses to go in a certain direction.
Servos should always get a continuous stream of pulses. It is the width of the individual pulses that defines the position.

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

coolaturon

#4
Aug 21, 2015, 09:55 pm Last Edit: Aug 21, 2015, 09:59 pm by coolaturon
"but I didn't think to post it"

Sorry I didn't think to post it, because I found nothing special about it that might lead to the problem since I commented out the actual navigation method in the setup, so that the servo values are set once and not change from that point. But since it still doesn't work and it seems to be about the code here it is:

The main Code: http://hostcode.sourceforge.net/view/3273
The 'class' Coord: http://hostcode.sourceforge.net/view/3274
How are the servos powered?
The Servo is powered by the UNO-Board (5V and GND) and is connected to digital pin 5
The Motor is Powered by its own battery via a ESC which is connected to a GND-Pin and and digital pin 3
But as the problem does not show up when using a very simple basic code I believe there can't be too much wrong with the wiring.

coolaturon

Servos should always get a continuous stream of pulses. It is the width of the individual pulses that defines the position.

...R
Yeah right :) But that was not quite what I meant. Sorry for the bad wording. Here by 'pulse' I meant the continuous change between maximum and middle position not the actual pulse of the PWM Signal.

MarkT

Don't ever power a servo from Arduino 5V, you will damage something and you'll certainly
get random or repeated resets as the servo pulls large currents and crow-bars the supply
voltage.

Power motors/servos separately from logic chips.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

coolaturon

#7
Aug 21, 2015, 11:07 pm Last Edit: Aug 21, 2015, 11:38 pm by coolaturon
OK thank you. I'm powering it with the BEC from the ESC now.
But unfortunately the original problem's still not solved by that :(

Update:
I commented out all the GPS and SoftwareSerial compomemts. The Problem is gone. Might it be possible that the Arduino can't send a straight PWM-Signal to pin while reading information from another pin or while running a while-loop (as used in the getPos() method)?

coolaturon

Update: It has turned out that the Problem is a conflict between the SoftwareSerial and the Servo library. Everytime the SoftwareSerial receives data from the GPS module, the Servo freaks out.

AWOL

So, we got to reply #7 before we found out about (but not saw) the presence of SoftwareSerial.
Three hours.

Nice

Robin2

Update: It has turned out that the Problem is a conflict between the SoftwareSerial and the Servo library. Everytime the SoftwareSerial receives data from the GPS module, the Servo freaks out.
This is a well known problem - and illustrates the importance of making ALL the information available and not just the bits that seem relevant to you.

Try the ServoTimer2 library.

I know that works with Arduino IDE 1.5.6 - I think I have seen people have problems with some of the newer versions.

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

Go Up