Go Down

Topic: Issue with SoftwareSerial library and repeated input characters? [SOLVED] (Read 981 times) previous topic - next topic

7wed

I've managed to solve this, but I don't really know how or why...

Since I'm developing on my desk, I was using HyperTerminal (comes with Windows XP) as my terminal emulator, to pretend to be the industrial machine my Arduino will end up connected to.

I was using a USB -> Serial FTDI chipset adapter, going into my SoftwareSerial input pin, through a MAX232 chip. When I saw the repeated character problem, I then tried an Arduino USB2SERIAL board, with the outputs going straight into the TTL Arduino pins (no MAX232). None of this made any difference. I also tried using several different input pins on the Arduino as SoftwareSerial to check if this was pin-related, to no effect. Tried using a different Leonardo and an Uno, but this didn't change things either. When sending to D0 on the Arduino (which I am already using somewhere else in my full program) repeated characters come out fine. That's why I suspected SoftwareSerial.

In desperation, I tried a different terminal emulator (PuTTY). This works perfectly, and there seems to be no problem at all sending data through the same hardware, and the same code on the board.

I'm wondering if there's a timing issue in HyperTerminal which occasionally rears its ugly head, or if its timing is screwed up by using a modern CPU, or selecting a slow baudrate.

Thanks for all those who submitted comments,

Ross

Erdin

I think it is your sketch.
The HyperTerminal would perhaps add CR LF, and puTTY perhaps only CR.

If you want to be sure if something is wrong with HyperTerminal, you can make a test sketch that shows the problem. So we could try it to see if we have the same result.



7wed

The empirical program:
Code: [Select]

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9);

void setup() {
  Serial.begin(2400);
  mySerial.begin(2400);
}

void loop() {
  if (mySerial.available()) Serial.write((char)mySerial.read());
}




exhibits the same behaviour using HyperTerminal / SoftwareSerial (I tried several input pins on both Uno / Leonardo), but is fine with a hardware serial port.

I tried using a Win7 machine (with hyperterm.exe / hyperterm.dll copied from WinXP) as well as a standard Windows XP machine.

Using PuTTY, there is no problem.

If the same character is repeated three times, the third character is the ASCII value +128, and then subsequent characters alternate between correct and +128.

Erdin

I tried to test it in Windows XP, but I was not able to install a driver for any of the usb-to-serial adapters I have. And Windows XP crashed, so something is wrong with it. Sorry, I can't try HyperTherminal. I use linux.

Erdin

I have some good news and bad news.

First of all, it was not your sketch. Sorry for that.

You have done some extensive testing.
I ran HyperTerminal and got that error right away with the second character. I tried other pins, some delays, but nothing stopped receiving the wrong data.
I can't tell what the problem is, but the SoftwareSerial library doesn't receive the data by HyperTerm correctly.

This is the post I created for the problem with the SoftwareSerial library, http://arduino.cc/forum/index.php/topic,163082.0.html

Go Up