1

I have a quirky question today.

I have an Arduino MEGA 2560 with a very simple setup. It's connected to my pc over usb, and has one device connected on its onboard TX/RX2 port group. Whenever I open the COM port on my pc I see a short spike in voltage on the TX2 pin. An analogous behavior happens on even the simplest sketches so I don't think it's the library I'm using to talk to this device.

With the sketch below instead of a short spike in voltage, the TX2 line stays high and when the pc's COM port is opened that TX2 line drops to 0v for maybe a half second.

Not super relevant info about device

It's a Noritake GU140X32F-7000 display. The mfg website doesn't list it's model directly but the
info on the 'B' variant, and it's supplied AVR code, work just fine.

MFG Website for this model>> https://noritake-vfd.com/gu140x32f-7000b.aspx
Code Library>> https://www.noritake-elec.com/codeLibrary.php#gu7000

Relevant bare-minimum code to see this effect on an oscilloscope connected GRD <-> AVR Ground, POS <-> Pin16(TX2)

void setup() {
  Serial.begin(115200); // Connection to computer
  Serial2.begin(38400); // Connection to TX2 pin 16
  Serial2.write('akjlahsdkjahsdkjlhasdkjhaskldjhaksjhd');
}

uint8_t serialByte = 0;
void loop() {
  if (Serial.available() > 0) {
    serialByte = Serial.read();
  }
}

What happens, which I don't want happening, is after I've had the Arduino draw to the Noritake screen, and I open or reopen the COM port from my pc to the Arduino, the screen blanks itself. Doesn't matter if I use PUTTY, python's serial library with

ser = serial.Serial('COM4', 115200, R timeout=0,parity=serial.PARITY_NONE, rtscts=1)

or Serial Port Monitor's trial version from https://www.com-port-monitoring.com/ via the send dialog - it happens either way.

Especially weird is I don't see data going over this COM port in the Serial Monitor software when the COM port is opened and yet my oscilloscope (fairly crappy DSO138) catches a spike in voltage happen the moment this serial line is opened from my pc. When I use the Noritake library the TX line is normally low when there's no data, whereas the Arduino built in Serial2 line is normally high until there's data. Then when I connect it goes low for about a half second. The code Noritake uses to communicate over this serial line is a bit odd, not actually using the Serial or Stream built in classes, instead opting to write data manually to this port and only including these two external libraries.

#include <avr/pgmspace.h>
#include <util/delay_basic.h>

What causes Serial2 to go low when my PC opens the COM port to Serial on my Arduino? What can I do to prevent it from writing to Serial2?

5
  • 2
    You're probably over-researching things and finding a problem that isn't a problem. The simplest reason: when you open serial the Arduino resets and your sketch runs from the start again.
    – Majenko
    Jul 19, 2020 at 17:18
  • Ok this answered my question. Thank you! Do you want to get credit for it or should I answer this thread myself? Jul 19, 2020 at 17:52
  • Why would we delete this question? I suggest @Majenko post his comment as an answer and the answer get selected. Don't delete valuable debugging info. like this from the internet. Jul 19, 2020 at 19:38
  • Interrobang, you can also answer your own question, and then select it as the right answer in 2 days. I suggest keeping the question and answering it yourself, quoting Majenko. Jul 19, 2020 at 19:40
  • I'm going to wait the two days, thanks Gabriel! Jul 20, 2020 at 2:34

1 Answer 1

2

As to why this happens: connecting to the Arduino with the built in USB port would wipe the display because the Arduino would reset and re-initiate the display initialization routine. The spike in current was actually the initialization signal. In the bare minimum sketch the signal going high, low, then back high was again due to the Arduino resetting.

The solution I'm going with is just changing how I connect to my Arduino with python by adding dsrdtr = 1 to my serial declaration. I tested this and my Arduino no longer resets, and uploading sketches is not impacted.

# Python 3.7.5
import serial
ser = serial.Serial('COM4', 115200, timeout=0, parity=serial.PARITY_NONE,
                   rtscts=1, dsrdtr = 1)
1
  • 1
    I removed the part with links to mostly obsolete and not applicable information about auto-reset. Leonardo is very different in this and the current Uno/Mega boards have pads which can be cut to disable auto-reset and eventually connected again with solder. the solution for Python is nice. upvote for this
    – Juraj
    Jul 21, 2020 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.