Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Commanderbob on February 04, 2008, 11:01:51 PM

Title: Servo Twitch
Post by: Commanderbob on February 04, 2008, 11:01:51 PM
I have a micro servo (S75) and I am using it so scan with a sharp IR sensor. The problem is I am increasing the PWM linearly, but the servo will be going fine but then jump like 15 degrees. What causes this? It is hardware PWM on a Atmega128.

Also I get a lot of change in the sensor output. Is this normal with the Sharp IR sensors?

Thanks,
Justin Rajewski
Title: Re: Servo Twitch
Post by: Admin on February 04, 2008, 11:18:25 PM
Quote
The problem is I am increasing the PWM linearly, but the servo will be going fine but then jump like 15 degrees. What causes this?
Assuming your code is correct, then most likely it is noise on your signal wire.

Did you use any servo wire extenders? Also, keep the servo wire away from anything that will cause stray signals, such as other servo wires, motors, etc.

Quote
Also I get a lot of change in the sensor output. Is this normal with the Sharp IR sensors?
http://www.societyofrobots.com/robotforum/index.php?topic=2712.0
Title: Re: Servo Twitch
Post by: Commanderbob on February 05, 2008, 05:57:50 PM
I am using a Gumstix Verdex XL6P (http://gumstix.com/store/catalog/product_info.php?cPath=27&products_id=178), netwifimicroSD FCC (http://gumstix.com/store/catalog/product_info.php?cPath=31&products_id=197), and the robostix (http://gumstix.com/store/catalog/product_info.php?cPath=31&products_id=139). I only have the servo and the Sharp IR sensor. I'll add some caps to the power line as in my past experience with the IR sensors they takes pulses of power that caused my PIC to reset every time it was plugged in. Maybe it is causing the servo to twitch. I tested the output with another servo that is know not to twitch and it jumped still.

 Could the Wi-Fi module make noise that could disturb the servo? I will also try to use a different timer (I am using timer 1 channel C, I am using channels A and B for motors that are attached to a H-bridge driver.)
Title: Re: Servo Twitch
Post by: Maltaeron on February 05, 2008, 06:49:14 PM
I was having some problems with my servo jumping a bunch on my atmega168, I was doing angle calculations for the built in pwm -- converting angle to comparison number -- but didn't use a large enough data size, only short, I changed it to unsigned short and it worked smoothly.
Title: Re: Servo Twitch
Post by: Commanderbob on February 05, 2008, 09:07:05 PM
It is not being calculated on the Atmega128. The data size is correct. I added a 50ms delay between sending the move servo command and the read ADC. It seems to work now. I could not get timer 3 to work. The servo would go full right and hit the wall.

I think that the I2C bus and/or ADC changed speeds enough to make the little jump. All of the delays before were from the ADC and I2C, now I have a constant 50ms delay. I take less samples to compensate for the added time.

Justin
Title: Re: Servo Twitch
Post by: Admin on February 05, 2008, 09:54:58 PM
Quote
I'll add some caps to the power line as in my past experience with the IR sensors they takes pulses of power that caused my PIC to reset every time it was plugged in. Maybe it is causing the servo to twitch. I tested the output with another servo that is know not to twitch and it jumped still.
You should always always always have caps on your power line.

Put like a .1uF ceramic, a 1uF ceramic, and a 200uF electrolytic capacitor on it.

This is probably the problem.
Title: Re: Servo Twitch
Post by: Commanderbob on February 05, 2008, 10:21:53 PM
There are already caps on the power line, It is also regulated power from my PC's USB port. (some times from batteries w/5v reg and 150uf cap). The Robostix has caps on it. I'll add some more though, can't be too safe. How much does it matter where they are connected to the power, near the source, or near the servo?

Also just to clarify when the servo jumps it does not return but continues going in the same direction. It is more like a burst of speed. That is why I don't think it is noise.

Justin
Title: Re: Servo Twitch
Post by: Admin on February 06, 2008, 05:26:40 AM
The caps should go close to the electronics that you want to protect from the noise.

As for your servo problem, that definitely sounds like a code issue!
Title: Re: Servo Twitch
Post by: Commanderbob on February 06, 2008, 09:26:29 AM
I ran a test over the i2c bus. The test counted how many ADC readings it could archive in 10 seconds. It varied from 550 to 600. I think the way the timing fell that there was some very fast readings that caused the code to execute faster. It works now with the constant delay.
Thanks,
Justin