Go Down

Topic: usb serial tx freezing on uno (Read 1 time) previous topic - next topic

markween

Jan 12, 2011, 08:06 pm Last Edit: Jan 12, 2011, 08:23 pm by markweenlondon Reason: 1
hi,
i just got a ardunio uno -
setup a simple circuit with a photoresistor that controls a servo

code belo

Code: [Select]
#include <Servo.h>

Servo myservo;  


int potpin = 0;  
int val;    

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

void loop()
{
   val = analogRead(potpin);          
   val = map(val, 0, 900, 0, 179);    
   constrain(val, 0, 179);

    Serial.println(val);
    delay(25);
 
   myservo.write(val);                
   delay(15);                        
}  


i upload that code and open the serial monitor which starts printing out values.
the problem is that the serial sends data out but when there is a sudden large change in the value its sending tx freezes (the tx led either stays lit constant or goes out) and no data is being sent anymore - i have to unplug the usb and start again to get it sending again

i also tried reading with dotnet on com11 so make sure it wasnt a software issue and i got the same result
anyone know why this might be happening???

cheers,
mark

Grumpy_Mike

It might be a problem with the servo code. Try removing that call and see if it still happens.

It could be a hardware issue where a sudden demand for current causes a glitch and screws up the arduino. How are you powering the servo? They normally need an external power supply, how much peak current does yours take?

C222

I agree with mike.
Most servos I have used are right on the edge of the power Arduinos are capable of supplying on board.
Try hooking it via an H-bridge, mosfet, or transistor to an external power supply like a >5v battery or a wall wart.

markween

Thanks for the replies it was power I think!
I removed the sevo and it works

thanks
mark

zoomkat

Quote
Most servos I have used are right on the edge of the power Arduinos are capable of supplying on board.
Try hooking it via an H-bridge, mosfet, or transistor to an external power supply like a >5v battery or a wall wart.


The "H-bridge, mosfet, or transistor" are usually for motors and aren't usually used with servos.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

markween

thanks for the input zoomkat but forgive me ignorance but what do you use to power a servo?

mines a mini servo btw

thanks,
mark

zoomkat

The below discussion covers several points that might be of interest.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1295000311
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up