Does Software serial still conflict with the Servo library?

I have project that uses software serial to communicate with a HC-06 bluetooth module and the Servo library? to control a small servo motor. The idea is that the servo is controlled over bluetooth.
When I send data over software serial the servo motor is jumping around.

I have spent a fair amount of time looking for a solution but all I am finding is old stuff. Does Software serial still conflict with the Servo library and if so, is there a recommended solution?

I'll be interested to hear replies to this too. I wasn't aware of this problem, but everything I just looked at indicates the conflict. The newest reference I've found so far was in Jan. last year. Still looking....

I assume your hardware serial is already tied up doing other things?

Edit: Martyn, have you tried moving the servo to a different pin?
Which Arduino are you using? On the UNO, PWM pins 9 and 10 use timer 1, and so does the servo library.
Does SoftwareSerial use PWM? Even if not, it might be a similar interrupt conflict. Many people recommend not using SoftwareSerial, but maybe a pin change will cure your problem?

Try the ServoTimer2 library

...R

Does Software serial still conflict with the Servo library

Did you find ANYTHING that said otherwise?

PaulS:
Did you find ANYTHING that said otherwise?

I think it was a fair question. That's what the forums are for - those times when a search doesn't definitively answer a question.

I keep tripping over the shortage of timers too, and in my next project ServoTimer2 won't help either. I'm using the IRremote library, which uses timer 2, already had to disable timer usage in the NewPing lib so it would get along with IRremote, and the next project was going to use both as well as SoftwareSerial.
Looks like I'd better buy an ATMega2560 chip pronto, for extra hardware serial. The little UNO has it's limit, and I've reached it. :frowning:
(Or I'll throw in a second ATMega328 chip and share the load a bit.)

I think it was a fair question. That's what the forums are for - those times when a search doesn't definitively answer a question.

I don't. There is an assumption that the reason that the two didn't work together was because one, or both, was defective. That is a patently false assumption.

PaulS:
I don't. There is an assumption that the reason that the two didn't work together was because one, or both, was defective. That is a patently false assumption.

He didn't say, or assume 'defective', in my opinion. He said 'conflict'. To me that implies timer conflicts, not defects.
Either way, not important enough to argue about. :slight_smile:

SoftwareSerial doesn't use a timer.

No but it does conflict with Servo library because it uses very slow interrupt handler (PCINT) for receiving
characters which is both higher priority than timer1 interrupts and doesn't allow any other interrupts
to run until an entire char as been read (upto 1ms for 9600 baud).

There are alternatives to SoftwareSerial that do not block interrupts.

I wrote a library that has a much lower interrupt latency than SoftwareSerial. It depends on the input being ASCII characters. But a similar library that accepts a more general binary value isn't that much differnt. Robin2 did some work on that as well.

It's not impossible, it's just not built into the IDE.

jboyton:
There are alternatives to SoftwareSerial that do not block interrupts.

That was way back in Reply #2 - well, much the same thing.

...R

Changing the pin does not resolve the issue.

I am getting compile errors when trying to use the ServoTimer2 library error: conflicting declaration 'typedef bool boolean'. This is documented on the forums at ServoTimer2.h boolean deceleration error - Motors, Mechanics, Power and CNC - Arduino Forum and when I get more time I will try again.

Robin2:
That was way back in Reply #2 - well, much the same thing.

You posted a link and said "try it". I clicked on your link and it took me to a page full of links to files and comments in German.

I clicked on your link and it took me to a page full of links to files and comments in German.

The comments on the page are in German. The library names are in English. The comments in the libraries are in English.

jboyton:
You posted a link and said "try it". I clicked on your link and it took me to a page full of links to files and comments in German.

The bottom link is the source of the ServoTimer2 library. I had assumed you would know to download it. Perhaps I should have explained more clearly.

...R

Robin2:
The bottom link is the source of the ServoTimer2 library. I had assumed you would know to download it. Perhaps I should have explained more clearly.

I know how to download a zip file and expand it. It just seems like a long ways to go to find out what you meant.

Here are the comments at the top of ServoTimer2.h:

/*
  ServoTimer2.h - Interrupt driven Servo library for Arduino using
/*
  This library uses Timer2 to drive up to 8 servos using interrupts so no refresh activity is required from within the sketch.
  The usage and method naming is similar to the Arduino software servo library http://www.arduino.cc/playground/ComponentLib/Servo
  except that pulse widths are in microseconds.

  
  A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
  The servo is pulsed in the background to the value most recently written using the write() method

  Note that analogWrite of PWM on pins 3 and 11 is disabled when the first servo is attached

  The methods are:

   ServoTimer2 - Class for manipulating servo motors connected to Arduino pins.

   attach(pin )  - Attaches a servo motor to an i/o pin.
   attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds
    default min is 544, max is 2400  

   write()     - Sets the servo pulse width in microseconds.

   read()	- Gets the last written servo pulse width in microseconds.

   attached()  - Returns true if there is a servo attached.

   detach()    - Stops an attached servos from pulsing its i/o pin.
  

The library takes about 824 bytes of program memory and 32+(1*servos) bytes of SRAM.
The pulse width timing is accurate to within 1%

 */

Maybe I'm dense but I still don't see how this resolves the issue with SoftwareSerial blocking interrupts. It looks like that library uses interrupts. It has an ISR to handle the timer 2 overflow and I think it sets it up to fire once every 128us. SoftwareSerial can block interrupts for a lot longer than that.

What am I missing?

jboyton:
I know how to download a zip file and expand it. It just seems like a long ways to go to find out what you meant.

Hang on a mo... You are not the OP!

If the OP wanted the library how else would he get it?

...R

Robin2:
Hang on a mo... You are not the OP!

No, I'm the guy who said that there are alternatives to SoftwareSerial that don't have the problem MarkT described. You're the guy who said that your previous post already pointed that out.

So how does that other servo library solve the problem?