[MKE02Z32VLD2] Loopback issue when trying to communicate Single Wire UART with PC using CP2102 uart

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[MKE02Z32VLD2] Loopback issue when trying to communicate Single Wire UART with PC using CP2102 uart

Jump to solution
3,093 Views
thursdayfiveminutes
Contributor II

Question about circuit for Single Wire UART on MKE02Z32VLD2

MKE02Z32VLD2 and CP2102 I am trying to communicate with a PC using a USB converter and Single Wire UART, but there is an issue of loopback.

<My configuration>

1. My PC has CP2102 USB to TTL converter.
2. I configured LOOPS and RSRC MKE02Z Firmware for single wire UART


- UART1 C1 configured LOOPS bit and RSRC bit.
- UART1 C2 configured RE and TE.
- Controlled the direction using CS3 TXDIR bit.


3. I connected the CP2102 converter and UART1 TX pin referring to the circuit as an attached circuit diagram.

singlewireuart.png

A problem has been detected in which the signal sent by the PC is returned back. It has already been confirmed by debugging that this is not a signal that MKE02Z responds to.

loopback.png

The red part indicates that the packet sent from the PC is looped back, and the green part is the packet that the MKE02 responds to.

How to solve the problem that the message sent from the PC is looped back in the attached circuit? or what's the exact circuit to do the MKE02Z32VLD2 Single Wire UART?
If there is something I'm doing wrong, please point it out and comment.

could you please share the information for the single wire UART?

0 Kudos
1 Solution
3,027 Views
myke_predko
Senior Contributor III

@thursdayfiveminutes 

I think I can summarize the answers to your questions by saying with a 1 wire bus you're always going to have to be concerned with echo'd characters being received by the sender.  I would suggest that you don't think of this as a problem, it's a characteristic of a 1 wire bus.  

There are two ways of dealing with this:

1. As mentioned previously, select the "remove echo" option on your software.

2. In my first reply, I noted that you can add an OR gate to your RX line to prevent received data from being echo'd back - you keep the "Digital Output" high until you want to transmit back:

Two to one pins - with OR.jpg

I would consider this a sub-optimal solution because it requires another IO pin (and if you had two to spare, you would use a traditional UART with separate RX and TX pins).  

The best solution is for the host software to filter out the echo'd bytes.  

Again, don't think of this as a problem but as a characteristic of the circuit and adjust your design requirements accordingly.  

Good luck!

 

 

View solution in original post

12 Replies
3,041 Views
myke_predko
Senior Contributor III

@thursdayfiveminutes 

The forum software here is acting weird and your reply:

Hello,

Thank you so much for any advice and answers that help me. I have answered the question you asked me as follows.

1. The CP2102 UART to TTL converter is a converter product from the link below. It is a USB converter and when connected to a PC, it recognizes it as a virtual COM port.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8

RX pin: receive pin from MKE02Z to the PC side TX pin: transmit pin from the PC side to MKE02Z

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8




2. I got information about the circuit from the links below. I got the information from the link below, connected a 1N4148 diode to the TX pin, and put a 4.7KOHM pull-up on the TX PIN of UART1 of MKE02Z.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697?emcs_t=S2h8ZW1h...

https://cnnblike.com/post/stm32-OneWire/

Is coming through intermittently on the page.  

It was helpful seeing the 1Wire UART circuit post and I can see now what the author is trying to accomplish but it's more complex than it needs to be AND depending on the hardware used, it may result in incompatible voltages on your IO pins.  Could I suggest that you simplify your circuit to:

Two to one pins.jpg

It will perform the same function as your diode/resistor combination but it is more traditional and you don't have diode drop voltages to deal with.  You can probably go much higher than 2.2k for the current limiting resistor, but it's a good place to start - check the voltage drop across it to ensure that highs and lows are within your Vol and Voh range limits.  

Regardless, you're going to have your input characters echo'd back to you with any of the three circuits discussed here.  In your Modbus software, did you look at the "Remove Echo" option?  I just did a quick look at the datasheet and that's listed in Section 4.7 (Modbus Poll user manual).  I think that will remove the echo'd bytes and give you wnhat you want.  

Good luck!

myke

3,035 Views
thursdayfiveminutes
Contributor II

Thank you very much for your teaching and solution while my problem is going on.

As you said, I removed the diode and pullup resistor and replaced it with the simple circuit that only connects the resistor to the tx line. As you said, there is also an echo message in this simple circuit.

As you commented, I can remove the echo that sent messages are looped back after I enabled the echo cancellation is enabled in the Modbus poll's advanced menu.

so I have an additional question. Does communication with single wire UART communication between MKE02Z and PC always echo? or is it a problem with these circuits? Is there a way to completely solve the echo problem by further modifying these circuits? Is removing echo messages from software the only solution?

0 Kudos
3,028 Views
myke_predko
Senior Contributor III

@thursdayfiveminutes 

I think I can summarize the answers to your questions by saying with a 1 wire bus you're always going to have to be concerned with echo'd characters being received by the sender.  I would suggest that you don't think of this as a problem, it's a characteristic of a 1 wire bus.  

There are two ways of dealing with this:

1. As mentioned previously, select the "remove echo" option on your software.

2. In my first reply, I noted that you can add an OR gate to your RX line to prevent received data from being echo'd back - you keep the "Digital Output" high until you want to transmit back:

Two to one pins - with OR.jpg

I would consider this a sub-optimal solution because it requires another IO pin (and if you had two to spare, you would use a traditional UART with separate RX and TX pins).  

The best solution is for the host software to filter out the echo'd bytes.  

Again, don't think of this as a problem but as a characteristic of the circuit and adjust your design requirements accordingly.  

Good luck!

 

 

3,020 Views
thursdayfiveminutes
Contributor II

Thank you very much for your summary.
I understand correctly your answer.
Thank you.

0 Kudos
3,012 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

cp2102.png

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

single wire.png

https://cnnblike.com/post/stm32-OneWire/

singlewireuart.png

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,082 Views
myke_predko
Senior Contributor III

@thursdayfiveminutes 

Could you please confirm a couple of details for me:

  1. What is the actual USB to TTL converter (module) that you're using?  I'm guessing it's not the chip directly because I just looked at its datasheet the pins you've labeled don't match.  I'm asking because there's always confusion regarding TX/RX.  
    1. From the CP2102, can I assume:
      1. "0-RX" is from the PC?
      2. "1-TX" is to the PC?  
  2. Where did you get the connection circuit that you are using?  The diode on "TX" doesn't look right (discussed below).  
  3. What is the software on the PC side?  Is it something that you control?  

With the circuit that is shown in you should be getting the behaviour that you're experiencing.  Data from "0-RX" is passed to the MKE02 and the "1-TX" pin.  Data from the MKE02 is passed to the "1-TX" pin.  

So, data from the PC will be returned to the PC and data from the MKE02 will be passed to the PC.  

The only way to avoid data from the PC being returned to the PC is to place an OR gate which is controlled by the MKE02 - I presume that you don't want to do that because you're using a single wire connection and are IO limited.  This is why I asked about the PC's software - it needs to filter out what has been sent.  

Also, I think the diode should be on the output of the "0-RX" pin (with the Anode facing the pin) rather than on the "1-TX" pin.  Having it on the "1-TX" pin does nothing but lower the high voltage going into the CP2102 by the diode drop.  Having the diode on the "0-RX" pin will stop you backdriving the "0-RX" pin with your data (looking at the datasheet, none of the UART outputs are open drain).  

Good luck,

myke

3,015 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,013 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,013 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,015 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8

cp2102.png


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,013 Views
thursdayfiveminutes
Contributor II

Thanks for the advice and help.

As per your advice, I tested the diode connection on the CP2102 RX pin line.

The loopback problem still occurred when I connected the anode of the diode to the RX pin. Conversely, when I connected the diode's cathode, the loopback problem was eliminated, but no response message was received from the MKE02Z MCU.

Below is the answer to your question.
1. It is a CP2102 Converter (USB to TTL) as shown in the link below. When connected to a PC, a virtual UART COM port is created.

The RX pin is the receive pin coming into the PC.
The TX pin is the outgoing transmit pin from the PC.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8


2. I got the circuit information from the two links below.
According to the articles, I connected 1N4148 diode to the TX line of CP2102 Converter on the PC side, and pull up with 4.7kohm on the TX pin(PTC7) of a UART1 of MCU.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

3. I used the Modbus Master software named "Modbus Poll". By connecting a virtual UART COM port created by connecting a USB to TTL converter, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02Z MCU using a single read command.

Thanks again for your help.

0 Kudos
3,013 Views
thursdayfiveminutes
Contributor II

Hello,

Thank you so much for any advice and answers that help me.

As per your advice, I tested the diode connection on the cp2102 RX pin line.

I tried adding a connection to the RX pin and the 1N4148 diode towards the anode as you advised. But the loopback problem keeps occurring. So, for just a test, I connected the RX pin towards the cathode of the 1N4148 diode to the RX pin. The loopback problem is removed, but I am unable to receive a response message from MKE02. It seems that no current is flowing through the RX pin on the PC side by the diode.

I have answered the question you asked me as follows.

1. The CP2102 UART to TTL converter is a converter product from the link below.
It is a USB converter and when connected to a PC, it recognizes it as a virtual COM port.

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8

RX pin: receive pin from MKE02Z to the PC side
TX pin: transmit pin from the PC side to MKE02Z

https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8

cp2102.png

2. I got information about the circuit from the links below.
I got the information from the link below, connected a 1N4148 diode to the TX pin, and put a 4.7KOHM pull-up on the TX PIN of UART1 of MKE02Z.

https://community.nxp.com/t5/Kinetis-Microcontrollers/1Wire-UART-circuit/td-p/931697

https://cnnblike.com/post/stm32-OneWire/

 

 

single wire.png

3. The software I used is a Modbus master software called Modbus Poll from the link below. By accessing the virtual COM port created when the CP2102 converter was connected, an 8-byte (01 03 00 0A 00 01 A4 08) message was sent from the PC to the MKE02.

https://www.modbustools.com/modbus_poll.html

Thanks again for the helpful reply.

0 Kudos