Multiple Tx and one Rx Problem

Go To Last Post
34 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,
I am working on ATmega8A for my graduation project. I have a problem about of multiple tx device and one rx device. If i need talk about my circuit; I am using ATmega8A as mcu this device is receiver and tx devices are one EM-18 RF ID reader module and PL2303 usb to ttl converter for computer communication between mcu. I am using toggle switch for change rx tx wires EM-18 between computer. But incoming datas is incorrect. For example, my rf id tag number is 360052A5266F but readed value is 6F 360052A526 360052A5266F. I don't use \ r when sending from computer, could it be because of this?

Thank you.

Last Edited: Mon. Feb 10, 2020 - 09:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most serial comm issues are caused by baud rate mistakes due to not knowing your cpu clock frequency!

You need an accurate and stable clock, best to use external xtal rather than the internal RC osc for serial comms.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A Usart signal idles high, I would place a pull up resistor 10k on the rx line to hold it high while the toggle switch is changing from one tx line to the next.

see if that helps.

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
Most serial comm issues are caused by baud rate mistakes due to not knowing your cpu clock frequency!

Indeed - see Tip #2 and Tip #3  in my signature (below; may not be visible on mobile).

 

It's far easier to describe your setup with a diagram than in words.

 

Before adding the complication of the AVR, have you tested the basic operation of your devices by connecting them to a Terminal program on a PC ?

 

This is always the way to start on  any serial interface task!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Wouldn't life be a whole lot easier if you simply based your design on an AVR that has the number of UARTs that your design actually calls for rather than trying to shoe-horn everything into the single UART that the mega8 has? Things like mega324P/644P (40 pin DIP) for example have a couple and a lot of the newer AVR-0/AVR-1 type device have lots of them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One solution would be to use software to emulate another UART, search for softuart, most need a timer and interrupts for operation.

This is how the Arduino Uno can have more then one UART.

Jim

edit:spelling

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Wed. Feb 12, 2020 - 03:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

admcmly wrote:
id tag number is 360052A5266F but readed value is 6F 360052A526 360052A5266F.
As you have the wrong sequence and numbers of the correct bytes,

you likely have a logic error in how you handle correct data.

By any chance do you read the tag more than once to check for errors?

 

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP is using a manual toggle switch. So it's also possible that the MCU is seeing parts of different transmissions - and incorrectly joining them as if they were a single transmission ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe that you have two serial signals coming into the Mega8.   One from the RF ID reader and the other from the PL2303 USB-TTL converter.   

  I suggest using a set of high-impedance buffers on each of the two inputs.   The best and cheapest to use is the 74HC125 chip.  When the control signal is pulled low, the '125 output reflects the logic on the input.  When the control signal is high, then the '125 output is high-impedance, which means it is effectively invisible to the logic seen by the AVR USART RX input.   

  To use the 74HC125, you need to two control output pins from the Mega8.   Use external pull-up resistors on the '125 control lines (2K  to 10K ohms).  At power up, all the '125 control lines are pulled hi and the Mega8's USART can be used with a bootloader.    Then you have to pull one of the buffer's Enable output pin low to have a clear channel between either the RF ID reader or the PL2303.  

  Another approach is to use the CD4053 1-out-from-2-input , 3-switch IC.  Old, but cheap.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you i will use 16Mhz external osc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using toggle switch for two peripheral device. Is it correct?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, i was simulate the circuit in Proteus ISIS. Circuit is running correct in the simulation. But running incorrect in the real (bread board)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tought that, but firstyl i want solve the problem with in my hand mcu. In worst case, i will do that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

admcmly wrote:
Is it correct?

Surely, you know whether the statement is correct or not?!

 

Whether it's a good design is another matter:  see the point raised by clawson in #5; and the potential problems mentioned in #8 - and that's without even considering contact bounce ...

 

surprise

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I heard that, can i imlement softuart library for ATmega8A beacuse ATmega8A is haven’t general porpose pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes i am reading tag more than. What kind of logic error could it be?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes i have two signals. Thank you i will try that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I saw them, i will try them as soon as.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

admcmly wrote:
can i imlement softuart library for ATmega8A beacuse ATmega8A is haven’t general porpose pins.
Do you mean tat you are already using all the pins on the chip so that there are non left for "soft UART"? if the soft UART is going to be transmit only (usually a good choice!) then you only need one GPIO pin. If you want receive as well it would need two port pins.

 

And the point I make here is valid. To "fake a UART" it's actually pretty easy to get the transmit part working with the correct timing but reception can be a real problem as it could happen at any time. So if you have two UART attached devices but for one the AVR only sends to it (like sending debug messages to a PC say?) then elect to do that one with softUART and keep the real UART for the thing that may also transmit to the AVR

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I downloaded the softuart, I will try it after trying other solutions. Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I said earlier the "best" solution is to pick the right micro for the job. If you can trade up from a mega8 to something like a mega164P you will have 2 UART anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought but I want to do with the MCU in my hand. Thank you for your suggestions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's a bit like saying I want to get from Los Angeles to New York but I've only got this bicycle. Life would be a lot easier if you bought a Ferrari! ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes you are right :) if i make this i will send reply here thank you for your replies

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do you post a million one sentence answers??   Post only full paragraphs so people can understand you.   This is a conversation, not a bunch of sound bites.

 

Take all of the following & turn it into some sort of commentary & explanation---it will be more sensible to everyone.

 

Thank you i will use 16Mhz external osc.
I am using toggle switch for two peripheral device. Is it correct?
Yes, i was simulate the circuit in Proteus ISIS. Circuit is running correct in the simulation. But running incorrect in the real (bread board)
I tought that, but firstyl i want solve the problem with in my hand mcu. In worst case, i will do that.
I heard that, can i imlement softuart library for ATmega8A beacuse ATmega8A is haven’t general porpose pins.
Yes i am reading tag more than. What kind of logic error could it be?
Yes i have two signals. Thank you i will try that.
I saw them, i will try them as soon as.
I downloaded the softuart, I will try it after trying other solutions. Thank you.
I thought but I want to do with the MCU in my hand. Thank you for your suggestions.
Yes you are right :) if i make this i will send reply here thank you for your replies

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Feb 13, 2020 - 01:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am new here, sorry. I will slowly learn the forum rules.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


You can multiplex one USART TX pin to two devices with only two resistors...

 

 

Set the associated EN pin as a high output to disable the feed to that external device. Set it as an input to enable that device.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


And in the receive direction...

 

 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW, the above two posts are a complete hack and are only there as a way to get you out of a hole. There are lots of problems to get them to work properly and lots of reasons why they won't always work.

 

The proper way to do it is either...

 

a) Use a chip with two USARTS or

b) Use an external chip to do the multiplexing.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Life would be a lot easier if you bought a Ferrari! ;-)

Or a plane ticket!

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have full control of all of the devices (your code in each), you can designate the main unit as the master....all other units listen at all times, only one can TX back to the main unit at a time, upon query from the master (rquest voltage reading, sensor reading, etc)

The units that are not transmitting back, put their TX pin in high-Z state.  A few resistors are needed such as pullups & separation resistors are a good idea too.  This works nice when the devices are "widely" separated by a few feet & perhaps you need to talk with 5 different devices.

A more robust method is to use rs485 or similar hookups...then you can go hundreds (or more) feet.

 

  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

admcmly wrote:
Yes i am reading tag more than. What kind of logic error could it be?
Idano.

When one loses one's keys, 'tis usually better to look where they might be instead of where the light is best.

Look for logic errors not hardware errors.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using toggle switch for that, won't it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the last try i will do option a thank you.