Garbled text using SoftwareSerial

Hi,
I'm almost new to using the Arduino Nano, learning as I go.
Problem I have is that I get 1 or maybe 2 lines of data correct when receving data with SoftwareSerial.
Any ideas or suggestions very much appreciated!!

This is code I'm using (not to complicated):
#include <SoftwareSerial.h>
SoftwareSerial HMRdisplay(2, 3); //pin D2 = rx, D3 = tx

void setup()
{
// initialize serial communication:
Serial.begin(9600);
HMRdisplay.begin(9600);
}

void loop()
{
while (HMRdisplay.available())
{
Serial.write(HMRdisplay.read());
}
}

and this is an example of what the data might look like (first line is correct, then garbage):
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 1234567890 DE
HQI RNF USVRH Z G2479D T IKRWFXUSORT Z G1469 T UKBWFXUPORT A O1369
TEUKBW XUPO
ETEAYO1368 E
EUCBW XJP E EAYO 3580E

HMRdisplay.read() returns an int.
Serial.write() takes a byte.

It is not clear why you are using a binary data function to send ASCII data.

Hi PaulS,

Do you have any suggestion for another way to do it, all I will send is ASCII-chars.
I just took the example that came with SoftwareSerial and made some minor adjustments.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

void setup()
{
Serial.begin(57600);
Serial.println("Goodnight moon!");

// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}

void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}

Do you have any suggestion for another way to do it, all I will send is ASCII-chars.

Yes.

char inChar = HMRdisplay.read();
Serial.print(inChar);

Hi again,

Tried suggestion above but no change :frowning:
Found that it I lower the speed from 9600 to 4800 it works perfect, but surely it must be possible to run faster than 4800??

Should maybe have mentioned before that I have a MAX232 in between the sender equipment and my Nano, and I can run the MAX232 at much higher speeds.

What to do?

Should maybe have mentioned before that I have a MAX232 in between the sender equipment and my Nano, and I can run the MAX232 at much higher speeds.

Probably irrelevant, so the failure to mention it is understandable.

Found that it I lower the speed from 9600 to 4800 it works perfect, but surely it must be possible to run faster than 4800??

What is sending the data the SoftwareSerial is reading? This is using Arduino 1.0, right? Is that device what you lowered the speed on?

Hi,

I'm using a "GN Navtel Datatest 3" to send data, but it will not be used once this is working.
I lower the speed on the Navtel and of course also in the code:
HMRdisplay.begin(4800);
the above setting works fine.

Arduino 1.0 is being used YES.

I'm using a "GN Navtel Datatest 3" to send data

A link?

Not exactly the one I have but same functions, not the best link though =(
http://www.teknetelectronics.com/Search.asp?p_ID=23888&pDo=DETAIL

I'm wondering if the problem is that sending data takes so long that it interferes with reading data.

Try this. Set the machine back to 9600. Set the software serial speed back to 9600. Kick the hardware serial speed up to 115200. See what happens.

That's an idea, I will try it tomorrow as I don't have the Navtel with me now :frowning:
To be continued...

PaulS: Tried what you suggested but still same problem.
Speeds up to 4800 no problem but over that garbled text. =(