Arduino Zero Serial Transmission Problem

Hi

I am new to the forums/Arduino so if I have any problems creating this thread or anything else let me know.

I am trying to read in data serially from the RX port, then Transmit data using that received data. I currently use the functions Serial.read for the receiving and Serial.write for the Serial transmission. The problem I am having is when I scoped the output from the TX port, it is a curved waveform.

It basically looks like one positive decaying exponential and one negative decaying exponential. They are symmetric across the y and x axis'. The picture is not mine, but it looks similar to this.

I have scoped the input, and scoured the data sheet and such with no avail, any help would be much appreciated! :slight_smile:

Thanks!

EDIT:

I would prefer to stick to UART, it works better with my system. Also I have tried powering through DC and USB to no avail. I am using an actual Arduino Zero not a clone or genuino or MO.

Thanks Again!

Hi dspencer,

Please share your full code using the code tag "</>" and your schematics / wiring. It will then be much easier to help you resolve your issue.

Are you using the USB programming port or the USB native port?
For information :

Serial refers to USB programming port
SerialUSB refers to USB native port
Serial1 refers to pin 0 and 1 (RX / TX)

Out of curiosity (and a little time to kill), I decided to try this here. Since you didn't give any specific code, I tried this:

void setup() {
  Serial1.begin(115200);
}

void loop() {
  Serial1.print("Hello");
  delay(5);
}

Here's the waveform I see when I connect my scope to pin 1.

How I tested, if anyone's curious.

So here is my code. I have a signal coming in at around 3 V to the RX port then a line just like Paul Stoffregen's for probing. Thanks for the replies, I think my problem may lie in the syntax. I am very green when it comes to some of this so I apologize if I am missing something very small. I appreciate any insights given and the time invested in solving this problem.

void loop() {

 if (Serial.available() > 0) {
     // read the incoming byte:
     Received = Serial.read();
 }
 if (Received == 24) {
   Serial.begin(2400);
    }
 if (Received == 48) {
   Serial.begin(4800);
 }
 if (Received == 16) {
   Serial1.write(Received);
 }
 if (Received == 32) {
   Serial1.write(Received);
 }
 if (Received == 64) {
   Serial1.write(Received);
 }

Thanks again!
Daniel

You're trying to send the number "16" to the Serial port? You should use ascii character :

16 (decimal) is the character 'DLE', a special command. 48 decimal is the character '&' etc... (look on google for ascii table). So if you send "16" through the Serial port, it a 2 bytes message : the ascii code of '1' (= 49) and then the ascii code of '6' (=54).

Why do you post only part of your program? There's no setup, no idea of baud rate, maybe other details involved....

Do you really imagine that people like us enjoy having to guess the rest of your code, only so we can help you?

Thanks for the clarification Aloysetech, I will try this tomorrow when I can get my hands on the board again.

I apologize for the not posting of the entire code, I never intended to make this a problem for anyone of you that help people like me.

Thanks for the quick replies, I will post my results if anyone is interested. And my entire code...

-Daniel

#include <arduino.h>

int Vselect1 = 9;
int Vselect2 = 10;    
int Mux1_1   = 11;
int Mux1_2   = 12;   //Intialize Vselect1 to pin 9, and Vselect2 to pin 10.

int Received = 0;
void setup() {
  


pinMode (Vselect1, OUTPUT);     //set the select lines as output
pinMode (Vselect2, OUTPUT); 
pinMode (Mux1_1, OUTPUT);

Serial1.begin(4800);             //Open the Serial port with 2400 Baud rate default  

}

void loop() {
  if (Serial1.available() > 0) {
      Received = Serial1.read();
  }
  
  Serial1.write(Received);
  
  analogWrite(Vselect1, 32);   //Write the waveform at 100% to the select lines
  analogWrite(Vselect2,64);
  analogWrite(Mux1_1, 128);
  
}

This currently works for what I need it to do, which is basically write the Received values straight to the Transmit port. The IF statements along with the Received variable were having a tough time but now just straight writing the Received variable works.

Thanks for the suggestions!
Daniel
Thanks for the suggestions!

If you want to process command coming from the serial port, you can check the Serial examples (Bottom right corner). Especially the ReadASCIIString one.