Using 2 uarts of ATMega devices and implementing an RS485 se

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

Hi,

I have a problem with regards to the design of a controller board that will interface 32 individual slave devices to a PC. I need to have two UARTS to serve to communication ends. The controller board acts as the master of 32 slaves set to monitor a certain parameter. The MCU used in the slave board is AT90S8515. With 32 slaves, i need to implement a serial bus line for lower cabling costs. But we had a problem using the RS485 implementation. When a single slave is connected to bus, it responds, but when another slave is added, neither of them replies to the command sent by the master MCU from the controller board. Does anyone of you had previous working designs using RS485 bus implementation which i could learn from? I also had problem implementing the 2 uSarts of the megaMCUs. The other USART is for the bus line, while the other is for the serial communication with the PC. We encountered that problem 2 years ago using ATMEGA161. but i dont know with the latest mega versions of the AVR having two USARTs.

Hope to hear from you guys soon. Thank you very much.

Alvin

admin's test signature
 

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

When a single slave is connected to bus, it responds, but when another slave is added, neither of them replies to the command sent by the master MCU from the controller board.
================================
Well, when you solve this, you're golden. This is the whole idea of multidrop half duplex. Everyone needs to assert Transmit Enable when they are ready to transmit, and I suppose the slave need to sit there with Data Enable on all the time so they can hear the master. One other thing I found is that when transmitting on the avr uart, I check Transmit Data Reg Empty, send the char, then wait for Transmit Complete bit to go hi, THEN CLEAR THE TXC BIT by writing a 1 to it in the status reg...... hope this solves a prob for you....

admin's test signature
 

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

When a single slave is connected to bus, it responds, but when another slave is added, neither of them replies to the command sent by the master MCU from the controller board.

I suggest that you need to chase WHY the slaves do not respond when there are two on the bus.

Using an oscilloscope, observe how a dialogue looks with a single slave on the bus. Observe voltage levels (both + and -), signal timing and the shape of the communications traffic.

Next attach a second slave and repeat the exercise.

Are the slaves REALLY not responding or are they responding and there is a collision on the bus?

If they are really not responding, then it points to the addition of the second slave causing the 485 bus to be going out of spec' (i.e. hardware). If they are both responding then it is software.

When you have identified whether it is hardware or software, you can then chase the problem further (with our help if you wish).

Hope that helps,
A.

admin's test signature
 

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

Hey guys,

Thanks for the help. I have finally figured it out. The slaves does not release the bus after use. So whenever one slave tries to use the bus, the data gets corrupted since other slaves take hold of the bus line. I just used the driver enable pin of the MAX1482 to turn on or off the transmitter so whenever the slave finishes the sending of data, it releases the bus free for others to transmit. I thought before that multiple slaves could be connected without ever turning off the transmitter. That solved my problems. I tested it by putting two slaves on the bus with two different addresses and both responded well. Thanks again!!

Alvin