Problems with the UART decoder

Forum for discussing PicoScope version 6 (non-automotive version)
poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Problems with the UART decoder

Post by poxyran »

Hello!,

I just bought a Picoscope 2204A some time ago and I'm trying to use it to decode some UART data from an Arduino Uno R3.

The task is really simple (sorry, I'm new at oscilloscopes and Arduino), here's the code:

Code: Select all

void setup(void) {

  Serial.begin(115200);

  delay(1000);

  Serial.println("Hello");

}

void loop(void) {
  //Serial.println("World");
}
In the screenshot attached, you can see the settings I'm using. The settings for the decoder are: baudrate 115200, 8 bits of data per frame, no parity, 1 stop bit, LSB order. The threshold is -5 and the hysteresis is 0. I'm using channel B, btw.

The problem is that I'm not seeing anything on the decoder window (screenshot attached), I tried to delete the current decoder and create a new one, getting a new capture again, etc. I always end up getting the same result :/

Just in case, I'm running this on Windows 10 x64 2004 (build 19041).

Any help on this?.
Attachments
Capture.PNG

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Problems with the UART decoder

Post by bennog »

Can you post the .psdata file.

Benno

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Problems with the UART decoder

Post by bennog »

Some hints on setting up the right way
1st set your scope to +/- 10V instead of 5 because you have overvoltage and the decoder can have problemens with overvoltages.
2020-09-14_08-04-39.png
2nd your signal seems te be inverted so you need to setup as shown below.
2020-09-14_08-04-19.png
Benno

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Hello bennog!,

thanks for your answer. I tried with the setup you suggested but I'm getting the same results. Attached goes the .psdate file and the .cvs with the decoder settings. Btw, I'm working with channel B, does it makes the difference?.
Attachments
20200915-0002.psdata
(9.88 KiB) Downloaded 277 times

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Here's the cvs file with the decoder settings.
Attachments
decoder.csv
(278 Bytes) Downloaded 266 times

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Problems with the UART decoder

Post by bennog »

You have initialized the port with no stop bits.

See attached and fixed settings.

Benno
Attachments
20200916-0001.psdata
(10.67 KiB) Downloaded 294 times

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Hello bennog,

thanks for the answer and the fix. I see that the fix was to set the Stop Bit to 0 in the serial decoder. However, there is something I don't get it. Serial.begin() (in the code I wrote), according to the docs, is initialized with one stop bit: https://www.arduino.cc/reference/en/lan ... ial/begin/. See the default (SERIAL_8N1, 8 bits, no parity, one stop bit). How is this possible?.

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Hello,

I really need to understand what's wrong with the setup. I asked on the Arduino forum and they pointed me that the problem is in the scope but they didn't mention what's wrong so I'm like at the beginning again. Any hints?.

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Problems with the UART decoder

Post by bennog »

Looking at the data again it could also be 7N1 witch makes more sense.

As of why it is not the default 8N1 needs investigation.

can you try with
Serial.begin(115200,SERIAL_8N1);

Benno

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Problems with the UART decoder

Post by Martyn »

I agree that it is 7-N-1 and that you do not need to invert in the decoder as the signal has the correct Idle High state.
Martyn
Technical Support Manager

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Hello Benno,

yes, I tried like that and the result is the same. No way to correctly decode the data with the stop bit set to 1. Could it be due to hardware problems?.
bennog wrote:
Fri Sep 25, 2020 6:20 am
Looking at the data again it could also be 7N1 witch makes more sense.

As of why it is not the default 8N1 needs investigation.

can you try with
Serial.begin(115200,SERIAL_8N1);

Benno

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Here's the link to the Arduino forum: https://forum.arduino.cc/index.php?topic=706222.0
They said that the problem is in the way I'musing the scope or the Picoscope has some problem.

Regarding the use of the scope, I just have channel A connected to the TX pin on the Arduino, nothing special. Regarding the Picoscope software, I can't say anything more tant I have the latest available version: 6.14.23.5207.

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Problems with the UART decoder

Post by Martyn »

If you setup the decoder as 7 data bits no parity and 1 stop bit, but do not tick the Invert box. Your data is decoded as "hello" , which I am guessing is correct.

I would move the trigger to 20% rather than 50% to see the remainder of the message correctly.
Martyn
Technical Support Manager

poxyran
Newbie
Posts: 0
Joined: Wed Sep 09, 2020 2:17 pm

Re: Problems with the UART decoder

Post by poxyran »

Hello Martyn!,

thanks for the answer. Yes, I think it works but, is it really the expected behavior? I mean, I'm explicitly setting the serial communication with 8 bits, no parity and 1 stop bit. Why the Picoscope is getting 7N1?. Isn't that a mismatch?.

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Problems with the UART decoder

Post by Martyn »

I have just checked more carefully, and the issue is that the baud rate is not quite 115.2kB and if you opt for custom decoding with a rate of 119kB you can decode the data correctly at 8-N-1 , so your software is correct but there is a slight error in the timing. With single characters you wouldn't notice this but a string of characters causes a misalignment of the data the further you go through the string.
Attachments
custom_baud_rate.psdata
(10.09 KiB) Downloaded 281 times
Martyn
Technical Support Manager

Post Reply