Arduino Mega with Touchshield (COM question)

I have a few questions about the communications with the Mega and a Touchshield (TSS).

The Mega communicates with the USB port (PC) using pins 2 and 3. 2 is the RX and 3 is the TX. However, the TSS uses these same two pins and are connected to the same pins 2 and 3 using the same pinout. This would seem to have two outputs (TX) from two devices, driving the same line at the same time (albeit there is a 1K resistor between).

Also, I have notice that I cannot load programs, into the Mega, unless I remove the TSS first. There is a conflict when both are connected at the same time.

Question1:

Can these two TX pins both connected at the same time, cause damage to the chips? This doesn’t look like good design practice but the TSS is supposed to be compatible with this board.

Question 2:

In order to communicate with the TSS, from the Mega, using the SoftwareSerial is necessary and the pin function is reversed on the Mega. But if I reverse the TX/RX pin functions, that would seem to make the hardware serial non-functional. However it isn’t.

I have written a program that will communicate over USB and to the TSS, both using these same 2 pins. But in the code there is only one setup for pin direction. How is it that this can send both hardware serial using pin2=Rx, pin3=Tx and SoftwareSerial using pin2=Tx, pin3=Rx?

#include <SoftwareSerial.h>
#include "Wire.h"
#include <LibTemperature.h>

#define RX_PIN 3
#define TX_PIN 2

LibTemperature temp = LibTemperature(0);
SoftwareSerial mySerial = SoftwareSerial(RX_PIN, TX_PIN);

void setup()
{
   pinMode(RX_PIN, INPUT);
   pinMode(TX_PIN, OUTPUT);
   mySerial.begin(9600);
   Serial.begin(9600);
   Serial.println("Starting...");
}

void loop()
{
    mySerial.print("To TSS");
    Serial.println("To USB");
}

How is it that this code can use the same 2 pins with TX on pin 3 for hardware and pin 2 for the SoftwareSerial? I could see how this might work one time. I mean the setup of pin directions for softwareserial could be corrected by the hardware serial but since the setup is a one time thing, I don’t see how the SoftwareSerial would continue to work. But it does.

Can anyone explain this?

Question 3:

I’m thinking about doing a cut and jumper and connecting the Mega Serial2 port to the TSS (pin 0,1), instead of using the Serial0, and reversing the TX/RX lines (crossover). That way, I could use a hardware serial to communicate between Mega and TSS.

However, I still need the FT serial driver connected to both the Mega and TSS, for program loading (using these same pins). If I just use a 1K resistor, like between the FT driver and the Mega, would that be enough isolation to prevent conflict with other serial ports?

As it is now, using the SoftwareSerial, when the Mega is communicating with the TSS, the FT driver is still connected but seperated by that 1K resistor. It would seem that if I just stopped using the SoftwareSerial and used the Serial2 (with crossover), it wouldn’t be electrically any different, with regards to serial conflicts between connections.

The Mega communicates with the USB port (PC) using pins 2 and 3. 2 is the RX and 3 is the TX.

No. The Mega communicates with the PC using pins 0 and 1 (the Serial instance).

However, the TSS uses these same two pins and are connected to the same pins 2 and 3 using the same pinout. This would seem to have two outputs (TX) from two devices, driving the same line at the same time.

Yes, except that should be pins 0 and 1.

Also, I have notice that I cannot load programs, into the Mega, unless I remove the TSS first. There is a conflict when both are connected at the same time.

Yep, because both are trying to use pins 0 and 1.

Can these two TX pins both connected at the same time, cause damage to the chips? This doesn't look like good design practice but the TSS is supposed to be compatible with this board.

If there are two inputs, and both set the pin LOW, there is no problem. If either sets the pin HIGH, there is no problem. If both set the pin HIGH, it is set to 5V. No problem.

Of course, the input will be garbage until one device shuts up.

I have written a program that will communicate over USB and to the TSS, both using these same 2 pins.

How do you know which you are talking to?

The SoftwareSerial class is obsolete. With 4 hardware serial ports on the Mega, why do you need to be using software serial?

In this code, the software serial instance will interfere with the Serial1 instance, not the Serial instance.

I'm thinking about doing a cut and jumper and connecting the Mega Serial2 port to the TSS (pin 0,1), instead of using the Serial0, and reversing the TX/RX lines (crossover). That way, I could use a hardware serial to communicate between Mega and TSS.

I'd re-think this. Serial is already connected to pins 0 and 1. If you cut the connection between 0 and 1 and the Mega chip, you won't be able to program it any more.

I meant pin 2 and 3 on the Mega chip; not the connector. The Mega communicates on pins 2,3 (on the ATmega1280), with the USB.

The SoftwareSerial class is obsolete. With 4 hardware serial ports on the Mega, why do you need to be using software serial?

Because the other serial ports aren't connected to the TSS. It's configured to connect to pin 2,3 on the Mega chip and 0,1) on the board.

Perhaps I'm confused on these connection references. The connector is marked TX(pin 1, chip pin 3), RX(pin0, chip pin2). I don't have a schematic of the TSS so I was assuming the communications is over this TX/RX pair.

I'd have to cut and jumper to use the hardware ports; hence my last comment.

How do you know which you are talking to?

The SoftwareSerial class is obsolete. With 4 hardware serial ports on the Mega, why do you need to be using software serial?

In this code, the software serial instance will interfere with the Serial1 instance, not the Serial instance.

I'm not sure what you are referring to here. I do have it connected as it was built and neither Serial or SoftwareSerial conflict. Serial1 isn't even used or connected. Serial1 uses pin 18,19 on the communications connector. The TSS isn't even connected to that.

I'm thinking about doing a cut and jumper and connecting the Mega Serial2 port to the TSS (pin 0,1), instead of using the Serial0, and reversing the TX/RX lines (crossover). That way, I could use a hardware serial to communicate between Mega and TSS.

I'd re-think this. Serial is already connected to pins 0 and 1. If you cut the connection between 0 and 1 and the Mega chip, you won't be able to program it any more.

I wasn't planning on removing pin 0,1 from the Mega.

Yes, the Serial is connected to 0,1 (on connector). But it's Tx is pin 1, RX is pin 0. That is necessary for communication with USB. But the TSS has these pins defined the same.

USB --> Mega USB --> TSS

If the Mega were to communicate with the TSS on these same pins, there would need to be a crossover. Is there a way to do that in the hardware serial?

BTW, the SoftwareSerial might be obsolete but it works. I have tested it. Unless I define pin 3 as RX and pin 2 as TX, the Mega won't communicate with the TSS. Check out the examples and you will see the TSS examples makes this crossover in SoftwareSerial communications.

Maybe I'm missing something but the code above does work. And it requires the crossover.

UPDATE I have just noticed that the TSS description says it communicates with the Mega using only 2 pins (pins 2 and 3). Perhaps that is the source of my confusion.

There are 2 TSS pins connected to pin 0,1 on the connector (marked TX/RX). And there are also 2 TSS pins connected to pin 2, 3. If the Mega board uses pins 2 and 3 for communications between the board and the TSS, that simplifies things.

Pins 2 and 3 aren't connected to any Serial port; hence the need for SoftwareSerial and it would also explain why there is no conflict in my code above. They are connected to PE4,5. These appear to be ports with interrupt capability though.

And it would make cut-and-jumper between Serial1 and the TSS pin 2,3 much easier.

I really do need to get a schematic for the TSS. ;)

http://arduino.cc/en/Main/ArduinoBoardMega shows pin 0 as RX and pin 1 as TX. These are Serial.

Pins 18 and 19 are Serial1. Pins 16 and 17 are Serial2. Pins 14 and 15 are Serial3.

The Mega communicates on pins 2,3 (on the ATmega1280), with the USB.

No. It communicates on pins 0,1. See the picture.

Do you have a link to this TSS you are referring to?

TX and RX designations depend on your perspective. From the Arduino, stuff is sent out the TX port. Perhaps from the TSS perspective, stuff is received on the TX port (because that is where it was transmitted from). Stuff is sent on the RX port, so that the Mega can receive it.

It's all just speculation without a schematic for the TSS.

No. It communicates on pins 0,1. See the picture.

I said on the ATMega1280. That is the CPU chip (pin 2,3).

The confusing part is there is a pin 2,3 (RX,TX) on the atmel chip. This is the same serial that is connected to connector 0,1. And to make matters worse, the TSS refers to pins 2,3, which I now think refers to connector pins 2,3. These require SoftwareSerial to communicate on. And I have verified (see code above) that indeed 2,3 is used for this communications. And it works.

Do you have a link to this TSS you are referring to?

Here is a link to the board. http://www.liquidware.com/shop/show/PMP/Portable+MegaPalm

Here is a link to the display that refers to communication on Arduino pins 2,3. It’s 2,3 on the Mega board as well. But I still think it uses pins 0,1 for program load. To load a program, I have to press reset on the TSS, which I think resets the MEGA and allows loading directly to the TSS. When load is complete, the both boards are reset.

So, I think the communications goes like this:

Load Mega Program: USB → Mega (0,1)
Load TSS Program: USB–> TSS (0,1)
Comm from Mega to TSS: Mega <–> TSS (2,3) Software Serial

http://www.liquidware.com/shop/show/TSL/TouchShield+Slide

From what I can see, it’s not possible to use the existing hardware serial ports, unless I use jumpers, because pin 2,3 are connected to PE4,5 on the chip and those aren’t serial ports.

I was going to use NewSoftSerial but apparently it’s not compatible with the Mega, yet. So, now I’m thinking I might want to run jumpers from TX1/RX1 to pins 2,3. I wouldn’t need to remove any traces, since I just wouldn’t be using PE4,5 port output.

I agree that having a schematic would be great. I have looked for one but have yet to find it. :wink: