Pages: [1]   Go Down
Author Topic: Problem with Servo. I/OException  (Read 283 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello. I am using Arduino One with a Servo. I make the circuit like this: http://arduino.cc/en/uploads/Tutorial/sweep_BB.png
with this code:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 
int pos = 0;    // variable to store the servo position
int val = 0;
void setup()
{
  Serial.begin(9600);
  myservo.attach(10);  // attaches the servo on pin 10 to the servo object
}
 
 
void loop()
{
  while(Serial.available()==0){}
  pos=Serial.parseInt();
  myservo.write(pos);
  Serial.print(pos);
  
}

So, when I put a number in the monitor, the servo turns in that degrees. The problem is: when I introduce a number, give me that:
java.io.IOException: Error de entrada/salida in writeArray
   at gnu.io.RXTXPort.writeArray(Native Method)
   at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124)
   at processing.app.Serial.write(Serial.java:517)
   at processing.app.Serial.write(Serial.java:540)
   at processing.app.SerialMonitor.send(SerialMonitor.java:200)
   at processing.app.SerialMonitor.access$100(SerialMonitor.java:32)
   at processing.app.SerialMonitor$3.actionPerformed(SerialMonitor.java:89)
   at javax.swing.JTextField.fireActionPerformed(JTextField.java:508)
   at javax.swing.JTextField.postActionEvent(JTextField.java:721)
   at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:836)
   at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1661)
   at javax.swing.JComponent.processKeyBinding(JComponent.java:2870)
   at javax.swing.JComponent.processKeyBindings(JComponent.java:2917)
   at javax.swing.JComponent.processKeyEvent(JComponent.java:2833)
   at java.awt.Component.processEvent(Component.java:6282)
   at java.awt.Container.processEvent(Container.java:2229)
   at java.awt.Component.dispatchEventImpl(Component.java:4861)
   at java.awt.Container.dispatchEventImpl(Container.java:2287)
   at java.awt.Component.dispatchEvent(Component.java:4687)
   at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
   at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
   at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
   at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
   at java.awt.Component.dispatchEventImpl(Component.java:4731)
   at java.awt.Container.dispatchEventImpl(Container.java:2287)
   at java.awt.Window.dispatchEventImpl(Window.java:2719)
   at java.awt.Component.dispatchEvent(Component.java:4687)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
   at java.awt.EventQueue.access$200(EventQueue.java:103)
   at java.awt.EventQueue$3.run(EventQueue.java:688)
   at java.awt.EventQueue$3.run(EventQueue.java:686)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
   at java.awt.EventQueue$4.run(EventQueue.java:702)
   at java.awt.EventQueue$4.run(EventQueue.java:700)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

And I dont know why. Another problem that I have, is that the Servo dont follow the instructions. When I only put servo.write(45), it starts turn aroung with no pause.

Anyone knows why?

Thank you.



EDIT: I add some images of my circuit.
« Last Edit: May 15, 2013, 05:39:10 am by elseine » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 299
Posts: 26178
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I only put servo.write(45), it starts turn aroung with no pause.
Uh-oh...this sounds like an ex-servo, aka "continuous rotation servo".

Are you saying it never hits hard end-stops?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I only put servo.write(45), it starts turn aroung with no pause.
Uh-oh...this sounds like an ex-servo, aka "continuous rotation servo".

Are you saying it never hits hard end-stops?

Yes, it stops, sorry. He stop at the limit, and then, turn to the other side until he finally stops in an arbitrary position.


EDIT: Oh, and another thing. Aleatory, he starts moving in a tiny range and stops, and maybe has passed more than a minute without move.
« Last Edit: May 15, 2013, 05:16:32 am by elseine » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 299
Posts: 26178
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you connected the ground to the Arduino?
How are you powering the servo?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you connected the ground to the Arduino?
How are you powering the servo?

Yes, the ground is conected and the servo is powered with the pin of 5V.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 299
Posts: 26178
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried just running the servo sweep demo?

You should not really be running the servo off the 5V pin. Try powering the servo from four AA batteries, and remember to connect the grounds.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried just running the servo sweep demo?

You should not really be running the servo off the 5V pin. Try powering the servo from four AA batteries, and remember to connect the grounds.

Yes, i tried the servo sweep demo and dont work. Why is not good idea to use 5V? And how I power it with four AA?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why is not good idea to use 5V?
Because the servos can draw more current than the Arduino's 5V pin can comfortably source.
Quote
And how I power it with four AA?
By connecting the four AA batteries in series to the Servo.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why is not good idea to use 5V?
Because the servos can draw more current than the Arduino's 5V pin can comfortably source.
Quote
And how I power it with four AA?
By connecting the four AA batteries in series to the Servo.

I have a HK15298 Servo. It need the bateries too?  Now i am using the USB power.
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a HK15298 Servo. It need the bateries too?  Now i am using the USB power.

What do you mean by "too"? Do you have more than one servo? USB power is fine for the Arduino, but not for the Servo.
Logged

Pages: [1]   Go Up
Jump to: