UART2 Rx data problem

Any bugs you encounter with Flowcode should be discussed here.
lucibel
Posts: 172
http://meble-kuchenne.info.pl
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

UART2 Rx data problem

Post by lucibel »

hi,
I'm using ESP32 TTGO Display to receive data from $PortA.26 with UART2 then transfer these data to Computer with UART1 (Tx $PortA.1, Rx $portA.3).
Problem is that UART2 received data are always 255 ! but as you cans see below, the signal to $PortA.26 is not always 255.
OSC.jpg
OSC.jpg (156.89 KiB) Viewed 3168 times
So I made a test with and without data input
- When data wire disconnected from $PortA.26 , input data = 0 see below
- when data wire connected from $PortA.26 , input data = 255 see below
data.jpg
data.jpg (65.43 KiB) Viewed 3168 times
Data on screen
screen.jpg
screen.jpg (33.85 KiB) Viewed 3164 times

I don't know what's wrong, please check.
Last edited by lucibel on Fri Nov 26, 2021 3:13 pm, edited 4 times in total.
Seb

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: UART2 Rx data problem

Post by lucibel »

sorry can not add the files to first post
Data disp.fcsx
(30.82 KiB) Downloaded 102 times
Data disp.fcsx
(30.82 KiB) Downloaded 102 times
Seb
Attachments
Data_Send2.fcfx
(28.63 KiB) Downloaded 89 times
Seb

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: UART2 Rx data problem

Post by BenR »

Hi Seb,

Please can you try this slightly modified program. This should interrupt on every byte received and add each byte to the circuilar buffer one at a time. Before I beleive you were trying to do a bit too much inside the interrupt.

When we have at least 4 bytes in the buffer we re-send them to the PC and display on the LCD.
Data_Send2.fcfx
(27.23 KiB) Downloaded 99 times
I'm not sure on the data you're working with but you can use the CB component to do things like wait until you get a specific character and then go from there allowing you to sync up correctly with the data you're receiving and throw any surplus data away.

Let us know how you get on.

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: UART2 Rx data problem

Post by lucibel »

Thx Ben for your prompt reply, I just test it and the result is NG.
Panic.jpg
Panic.jpg (65.6 KiB) Viewed 3155 times
FYI, the data are from a sensor who is pushing 16 bytes every each second (1hz)
The first and second bytes to receive are always Byte0=0X42 and Bytes01=0x4D
For example,: 42 4D 0C 51 09 A2 07 2B 01 35 05 81 20 08 20 AD

66:77 received are ok --> 0x42 0x4D

Seb
Seb

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: UART2 Rx data problem

Post by BenR »

Hi Seb,

Looks like you're getting some data through now.

What about this instead?
Data_Send2.fcfx
(21.92 KiB) Downloaded 99 times
This waits for the first two bytes to be received, throwing anything else away. Once the bytes are received it waits for the buffer to fill with a complete reading of 14 data bytes. Once this happens it transfers everything through to the PC and prints out the first four data values on the LCD.

Watchdog delay reset was caused by the lack of delay in your main loop so I've put this back in now.

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: UART2 Rx data problem

Post by BenR »

Sorry missed the ':' characters in between the numbers.
Data_Send2.fcfx
(22.45 KiB) Downloaded 100 times

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: UART2 Rx data problem

Post by lucibel »

Im testing,
what do you mean by " CB component" when you said "you can use the CB component to do things like wait until you get a specific character" ?
Seb

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: UART2 Rx data problem

Post by lucibel »

Thx a lot Ben it works very well !!!! :D :D :D
may be I will need your help to send data to sensor next week.

What is "CB component" ?

BIG THANKS
Seb

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 505 times
Been thanked: 468 times

Re: UART2 Rx data problem

Post by medelec35 »

lucibel wrote:
Fri Nov 26, 2021 6:12 pm
What is "CB component
It's the Circular Buffer component.
It's very useful if receiving a fair bit of comms data.
Martin

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: UART2 Rx data problem

Post by lucibel »

Okay, understood now, yes very useful
Thx Martin
Seb

Post Reply