2

When uC1 wants to talk to uC2 via uart, the Tx of uC1 is connected to Rx of uC2 and vice versa. Half Duplex states that only 1 uC can use the communication line at a time and Full Duplex states that both uC can use the line at the same time. The Tx and Rx pin connections still remain the same for both methods of duplexing, but how 2 different scenarios are possible? Does the presence of separate Buffers for tx and rx determine duplexing or are special IC's and pin connections needed? Im confused because im working on a system where 2 uC's communicate with each other and both can send data at any point of time across a common uart connected to both of them(uC1=UART1,uC2=UART1).This will help me decide if priority among the 2 uC's is needed or not(i.e force them to work in half duplex, cos il be using ACK/NACK for messages sent via uart,and if both can send at any point of time,theres chances of misinterpretation/corruption of data(i.e uC1 is expecting ACK from uC2 in its rx buffer but uC2 is sending a message and not an ACK for the received message)).

Update

Im using 2 LPC1778,where the UART1 TX of uC1 is connected to UART1 RX of uC2 and UART1 RX of uC1 is connected to UART1 TX of uC2. Both uC can send data at any point of time simultaneously(full duplex)and no transceivers will be used(direct uC-uC communication).The uC's have separate Tx and Rx Shift registers. When uC1 is Tx'ng,data is going to uC2 Rx FIFO. If uC2 transmits,data will be going to uC1 Rx FIFO. So, if both uC's send, there wont be any collision right?

AlphaGoku
  • 1,003
  • 2
  • 11
  • 26

3 Answers3

6

Simplex, half duplex and full duplex shown below: -

enter image description here

Half duplex may make use of separate transmit_left and transmit_right wires or use some kind of hardware to permit non-simultaneous left or right transmissions on one shared wire (plus ground).

Full duplex can look like half duplex in terms of wires but, the hardware at both ends can handle simultaneous transmission and reception.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • Full Duplex= 2 wires. Half Duplex=1 wire. So in my scenario above, if i have to use half duplex,il need to use a switch to connect tx1 to rx2 or rx1 from tx2(wrt uC1 that is)? – AlphaGoku Apr 13 '16 at 10:33
  • 2
    Half duplex *may* use two wires just like full duplex OR it may use 1 wire with a hardware switch that controls direction at both ends. – Andy aka Apr 13 '16 at 10:34
  • By 2 wire u mean that tx1->rx2 and rx1<-tx2 will be connected so doesnt that become full duplex ? When Tx1 is sending, Tx2 can also send(full duplex right?). How is half duplex achieved using a two wires? – AlphaGoku Apr 13 '16 at 10:38
  • 2
    If using two wires and transmissions can't occur simultaneously or overlap then transmission is half duplex. – Andy aka Apr 13 '16 at 10:43
  • By "cant occur" you mean the hardware wont allow or software shouldnt send – AlphaGoku Apr 13 '16 at 12:16
  • 1
    To be half duplex simultaneous transmissions or overlaps "can't" happen else it becomes full-duplex (in part). It's semantics really. – Andy aka Apr 13 '16 at 12:19
  • Yes but by using 2 wire half duplex with the connections as mentioned above, both the uC's can transmit at the same time right? So the hardware shouldnt allow it. – AlphaGoku Apr 13 '16 at 12:31
  • I think thats what @Alan is talking about in the comment below – AlphaGoku Apr 13 '16 at 12:33
  • I noticed the update to your question but I'm wondering if this actually impacts on the core of the question. – Andy aka Apr 13 '16 at 12:59
  • I thought it may be useful because the uC's have separate Tx and Rx Shift registers. When uC1 is Tx'ng,data is going to uC2 Rx FIFO. If uC2 transmits,data will be going to uC1 Rx FIFO. So, if both uC's send, there wont be any collision – AlphaGoku Apr 13 '16 at 13:02
  • Sounds like full duplex to me or at least capable of it. – Andy aka Apr 13 '16 at 13:25
  • So then, Full duplex is determined by the uC and not the pin connections – AlphaGoku Apr 13 '16 at 13:55
  • @AkshayImmanuelD: Often in half-duplex, at least one end will be incapable of simultaneously listening and transmission. Such a scenario might occur with a processor or controller that doesn't have a UART but handles reception by using a loop that does nothing but waits for the Rx line to go low, followed by a loop to sample 8 bits at proper intervals. It's possible to achieve communication rates that are a significant fraction of the CPU speed if the CPU can devote 100% attention to reception or 100% attention to transmission, but doing both independently is hard. – supercat Apr 13 '16 at 14:08
  • @AkshayImmanuelD: An approach which is sometimes useful with that hardware situation, though I don't know a term for it, is to have only one side be capable of *initiating* each byte's transmission, but having the other side transmit a character at precisely the same time as it receives one, delayed by one bit time. I'm not sure there's a term for that variation, though. – supercat Apr 13 '16 at 14:10
  • @AkshayImmanuelD Full duplex is determined by both ends AND two wires plus ground. – Andy aka Apr 13 '16 at 14:14
  • @supercat- Edge trigger an interrupt for rising edges and send a bit maybe,by shorting the Rx pin of the uart to another GPIO configured for the level interrupt? – AlphaGoku Apr 13 '16 at 14:16
  • @Andyaka- So is the scenario above full/half? – AlphaGoku Apr 13 '16 at 14:17
  • 2
    I'm losing the will to live on this one.... which scenario? – Andy aka Apr 13 '16 at 14:19
  • Lol. The one where the uC has 2 separate buffers and can send anytime with 2 wires – AlphaGoku Apr 14 '16 at 10:09
  • 1
    If the transmission occur simultaneously or overlap it is full duplex. – Andy aka Apr 14 '16 at 10:39
1

For electrical signaling, count the number of wires - and subtract one for the ground wire. How many are left?

You started talking about 2-wire system: one from tx1 to rx2, another from tx2 back to rx1. This is a standard Full Duplex setup.

The other option has a single wire: half duplex. If the single wire is hooked up to tx1, the other end HAS TO connect to rx2 or you'll lose data. Similarly, if the single wire is on rx1 the other end HAS TO know to switch the wire over to Tx2 (and send back data)

Full duplex is faster and simpler, but needs more wires. Half duplex uses less wires, BUT you need a protocol at each end to know when to switch betweeen sending and receiving.

For more detail, you may want to look up "collision detection" on networks. It's a protocol to sort out who talks, and who listens. Another protocol is "token passing" on ring networks.

Update I'm reading your section about hooking up 2 uC chips. Yes, these chips should be able to operate in full duplex. However...

You are sending data, both ways, AND expecting ACK/NACK responses. We are right back to protocol handling, like HDLC or DDCMP. You need to send data in some form of "packet". Each packet contains a reference number.

Example: uC1 sends packet #101, then #102, then #103. At the same time, uC2 is sending packets #201, then #202, etc.

After sending packet #103, the control setup on uC1 starts looking at the packets from uC2, checking for a "#101 ACK/NACK". If it can't see that message, eventually the system will assume packet #101 was never received - and sends packet #101 again.

If uC2 manages to send back a #101 ACK, then uC1 knows to continue on by sending packet #104 (while also looking for #102 ACK/NACK).

Alan Campbell
  • 1,019
  • 6
  • 10
  • so Full duplex uses 2 wires & half duplex uses 1 wire. For half duplex,the uC must use a switch to interchange connections in order for both to be able to use that 1 line? – AlphaGoku Apr 13 '16 at 10:29
  • 1
    Yes you need a switch. You also need to know when to use it. If tx1 sends an "end of message" signal, uC2 needs to see that AND flick the interchange switch. Also, uC1 needs to flick its own switch (from tx1 to rx1) after sending the "end of message". – Alan Campbell Apr 13 '16 at 10:51
  • ur answer seems to point out that the scenario i have posed is full duplex because i dont use switches – AlphaGoku Apr 18 '16 at 05:23
0

Usually Transmitter and Receiver blocks on a uC are designed to be working independently. I don't know what kind of full duplex comm you are talking about. If that is regarding the user/software level implementation, the user program has to mask it's tx or wait for the reception to be completed. Else there should be some Mode (Full duplex) in uC to do this automatically, i.e., the uC will send your data after reception even though you trigger tx while reception is going on.

Hope this made you understand the concept. The next time anyone asks this kind of Question, I should find the Architecture (8051/Arm/PIC)? in the Question...

There won't be any collision

Bharath
  • 1
  • 1