NewSoftSerial

Hi guys,

I've ArduinoYUN and I've huge dubt.

I need improved serial library NewSoftSerial?

At link NewSoftSerial | Arduiniana specified:

Note: don’t download this if you have Arduino 1.0 or later. As of 1.0, NewSoftSerial is included in the Arduino core (named SoftwareSerial)

Then, can I quietly use SoftwareSerial.h?

Thansk

Then, can I quietly use SoftwareSerial.h?

Yes. But, for what?

For communication with external controller (ie. Pololu micro maestro)

Please be aware that the capabilities of SWSerial are far less than from a hardware serial. It really depends on what the rest of the program does, how many interrupts etc.

Thanks robtillaart,

Your note seems to me interesting. Can you explain better for me?

Thanks a lot

Software serial is manually timed based upon its internal clockspeed. If the flow of the code is interrupted by a hardware interrupt, be it a timer or the hardware serial, ADC ready etc, then the timing of SWserial is affected. As interrupts are not predictable there is an effect on the timing. With lower baudrates the timing is not as critical as with higher baudrates. e.g.

at 57600 baud the time of a bit is only 17.36 micros.
For 10 bits of a byte(incl start/stop) that means that the timing of the first and last bit may shift at most 9 usec.
One very short interrupt takes 4usec (incl call overhead etc) so 2 interrupts is on the edge of killing communication.

Great response robtillaart,

Indeed, when i send a command to my external microcontroller, put the code snippet in "No interrupted section"

noInterrupts();
   externalMicroController.initiateCommunication();
interrupts();

what do you think about?