Go Down

Topic: Servo and NewSoftSerial library issues (Read 975 times) previous topic - next topic

Butters

This is my first post..... So, hello!

I've been searching around the forum for a similar problem as mine, but I did not find anything.

Here's my problem:
For my project, (I'm using a Duemilanove board) I'm trying to get a servo to work with the NewSoftSerial library without the random servo movements.  I tried downloading the servo library from 0016 version and copying that library to my 0018 library, but that servo library will not work for some reason.  I also tried using the SoftwarwServo library, but that library would not work either.

By "not working" I mean I get no servo movement at all.  The code compiles but the servo does nothing.  I even tried uploading the example servo codes, which wouldn't work.

When I use the servo library from 0018 with the NewSoftSerial, the servo jumps around to random positions while it is being powered.

Also, I know the servo is good, I tried it without the NewSoftSerial library and it worked fine.

Thanks in advance

PaulS

What are you using NewSoftSerial for? It has nothing to do with moving the servo.

If you are reading data from a software serial port and using that data to position the servo, there may be a coding issue. Hard to say without seeing the code.

Butters

I'm using a GPS module so I need to use NewSoftSerial.  I'm actually making my own version of Mikal Hart's Reverse Geocache.

I could post my code, but it's lengthy.  I'm fairly confident that it's not an issue with the coding, but I could be wrong...

I'm not using the data from the serial port to position the servo.

PaulS

Just declaring an instance of NewSoftSerial causes the servo to go crazy?

What pins are you using for NewSoftSerial? For the servo?

The servo library for 0018 was improved over that for 0016. What prompted you to go back to an older version?

Finally, what is the hardware serial port being used for? That is, why do you need to use a software serial port?


Can you detach the servo when not moving it, attaching it only when needed?

Butters

#4
Aug 08, 2010, 08:36 pm Last Edit: Aug 08, 2010, 08:48 pm by grothem Reason: 1
Yes it seems to be just the declaration of NewSoftSerial is causing the problem, it was acting fine before I added that library

I'm using digital pins 2 (tx on Arduino, rx on GPS) and 3 (rx on Arduino, tx on GPS), and digital pin 6 for the servo

I tried going back to the older version because I read that was  fix for people using 0017 version, but I wasn't sure if that problem was fixed with 0018.

I'm using the software serial port to set my tx and rx pins, like this:
NewSoftSerial nss(3, 2);

This is my first time working with serial ports, is there another way to do this?

I'll try detaching the servo when not in use and see if that fixes it.

Heres a little piece of my code...

void setup()
{
 myservo.attach(6);
 myservo.write(90);        // servo will go to this position
 delay(5000);                 // I just put the delay in just to see if the
 pinMode(led, OUTPUT);  // servo would jump around, it didn't
 //eepromClear();
 Serial.begin(115200);
 nss.begin(4800);
 lcd.begin(16,2);
 pinMode(offPin, OUTPUT);
 ...
}

after the delay, it jumps around to random positions

PaulS

Try moving the delay down one line at a time, to confirm that it is the nss.begin() statement that is the cause of the problem.

Other than debugging, are you using the hardware serial port (Serial) for anything else?

Butters

I kept moving the delay down a line and it does seem to be the nss.begin() statement that is the cause of the problem.

I only used Serial for the early part of my code and debugging, but I don't need it anymorel

Butters

Ok, so I thought I would need to use NewSoftSerial to pull data from the GPS, but I got rid of that and just used Serial, along with the rx and tx pins on the arduino, which is working for now.
But is there any way to get around having to disconnect my gps  from the digital pins when I have the arduino hooked up via USB? With the GPS plugged in I cannot upload anything to my board.

PaulS

The XBee shield used a jumper to connect the serial port to the XBee or not. You might be able to rig up a jumper the same way.

...

Servo library from 0016 only works with a maximum of 2 servos, one in pin 9 and other in pin 10, so you cannot use your servo in pin 6

AKSoapy29

I'm a noob but try using the servo library in 0022.
Andrew K.

Go Up