Pages: [1]   Go Down
Author Topic: usb serial tx freezing on uno  (Read 915 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,
i just got a ardunio uno -
setup a simple circuit with a photoresistor that controls a servo

code belo

Code:
#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
« Last Edit: January 12, 2011, 02:23:00 pm by markweenlondon » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31462
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
I smell burning sillicon.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

thanks
mark
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8936
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8936
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1295000311
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: