Servo motor noise in analog input
i'm trying move servo motor according audio stream. noticed servo gets connected, there noise in analog read value. removed , connected a0 gnd, servo 5v, gnd , pin 9, uploaded below code , watched serial monitor. got noise in analog input average value of 30 , max of 40. if remove servo, flat 0 reading, expected. behavior expected servo , how prevent polluting analog inputs? tried adding 0.1uf , 10uf caps servo power pins of no use.
-antzy
-antzy
code: [select]
#include <servo.h>
servo myservo; // create servo object control servo
int pos = 0; // variable store servo position
int sensorvalue;
void setup()
{
serial.begin(9600);
myservo.attach(9); // attaches servo on pin 9 servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos'
serial.print("{");
serial.print("input");
serial.print(",t,");
serial.print(getmaxval());
serial.println("}");
}
for(pos = 180; pos>=1; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
// print out value read:
serial.print("{");
serial.print("input");
serial.print(",t,");
serial.print(getmaxval());
serial.println("}");
}
}
int getmaxval()
{
int maxval = 0;
for(int i=0;i<100;i++)
{
sensorvalue = analogread(a0);
if(sensorvalue > maxval)
maxval = sensorvalue;
}
return maxval;
}
i tried powering servo seperate regulated 5v supply , induced noise in power supply lines. when drawing power arduino, possibly changing aref voltage causing noise in adc.
the mention of electrical noise due servo on internet find solution was:
http://letsmakerobots.com/node/12679
i tried putting caps across power , signal suggest didn't work.
i found grump mike's decoupling tutorial:
http://www.thebox.myzen.co.uk/tutorial/de-coupling.html
the capacitors-resistor option didn't work. have buy inductor , give try. has else ever experienced problem before? couldn't find many mentions of on whole wide internet.
the mention of electrical noise due servo on internet find solution was:
http://letsmakerobots.com/node/12679
i tried putting caps across power , signal suggest didn't work.
i found grump mike's decoupling tutorial:
http://www.thebox.myzen.co.uk/tutorial/de-coupling.html
the capacitors-resistor option didn't work. have buy inductor , give try. has else ever experienced problem before? couldn't find many mentions of on whole wide internet.
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Servo motor noise in analog input
arduino
Comments
Post a Comment