Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Uart Daisy chaining, possible ?

Status
Not open for further replies.

henninggs

Member level 2
Member level 2
Joined
Nov 10, 2011
Messages
45
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Denmark
Visit site
Activity points
1,688
Hi

Although I've been making PC-software for quite some years now, I'm just at the beginning of my journey into the world of microcontrollers. I'm trying to figure out how I can build a computer controlled audio mixer. (8 inputs 16 individually stereo outs)

To build this mixer, I plan to divide it into 9 "boxes": 1 "master" box and 8 identically "slave" boxes.
Now, the master box receives a command from my PC via USB, like:
SET VOLUME TO 188 AT SLAVE 4 CHANNEL 6
The PIC16F628 within the master, sends (the same) command via uart to the first slave connected:
SET VOLUME TO 188 AT SLAVE 4 CHANNEL 6
The first slave checks the slave number if it is zero, if not it sends the command to the next slave (decreasing the slave number by one)
SET VOLUME TO 188 AT SLAVE 3 CHANNEL 6
This is repeated in slave 2 ect.
SET VOLUME TO 188 AT SLAVE 0 CHANNEL 6
SET VOLUME TO 188 AT SLAVE 2 CHANNEL 6
SET VOLUME TO 188 AT SLAVE 1 CHANNEL 6
Now slave 4 (number 5) evaluate SlaveNO==0 and thus sets the volume for channel 6 to 188.

I was thinking of connections like this (uart Daisy chain) (Only showing 2 slaves)
serial_con_uart.jpg
The devices will be placed in the same rack, so 1 feet of cable is needed to connect the devices.
I don't need light speed.

1. Is this possible ?
2. Is there a better solution ?
3. Do I need extra components or can I just connect Tx to Rx directly ?
4. Any thoughts/ideas ?

Any comments are greatly appreciated.
regards
 

I use a similar system for an industrial controller. A better solution is to feed all the UARTs in parallel and add an address number at the start of the message. It reduces the amount of parts needed and allows each module to work individualy. Daisy chains work fine until one breaks and the remainder of the chain goes 'deaf'. Also, although you say speed isn't important, consider there will be a delay equal to the time to send the whole message between each module receiving and passing it on.

In my application each slave module has to report it's status back to the master so it is wired like this:
Master output connects to all slave inputs,
Each slave outputs data and an enable signal. The enable signal turns on a driver circuit that feeds the data back to the master.
All the driver outputs are in parallel back to the master.

For example, my master sends "3 READ SENSOR A", all slaves hear the message but only module 3 responds, it enables the driver back to the master, sends the output of sensor A, then disconnects the driver again.

Brian.
 
Thank you Brian.

I would agree that a parallel setup is better. Two questions about a parallel solution.

1. If I want to have the same software on all slaves hence unable to define different slave addresses in code how can I set the addresses ? The only way is to have some extern "thing" that a slave must read in order to determine its address. A simple jumper setting perhaps ?

2. Why the enable signal ? If I make the slaves so they will not speak unless spoken to and ensures that the master only speaks to one slave at a time, I don't need an enable signal, do I ? (Master sends "3 READ SENSOR" and waits for an answer before doing anything else)

regards
 

1. all of my slaves have different uses so each has it's own firmware and hard-coded address although the communication routines are basically the same in all units. You can use a switch or jumper to set the address manually or if your rack has sockets in it, you might be able to wire spare pins to set the address according to physical 'slot' within the rack. As you are using PICs with EEPROM, you could store the address in one location and make it programmable with an external ICSP socket. A final solution would be to automatically assign addresses, this is a bit trickier but the idea is that you add a random delay generator in the PIC software. You then follow this method:

At power-up all the modules generate a random number, the more digits the better although two is probably enough.
Send an 'assign address' command, all the units receive it simultaneously.
If the module does not already have an address, it responds by sending the random number back to the master. The module with the shortest random delay will get attention first.
The master then sends "module reporting random number xxxx is assigned address 1".
The process is repeated until all modules have been assigned an address. A module already given an address ignores the 'assign address' command and the one with the next shortest delay is serviced next.

2. You must consider what happens on the outgoing and incoming lines to the master. The outgoing line from the master is a single source feeding many loads but the incoming line is lots of competing sources feeding one load. all the slave outputs would be competing on the same wire. The 'enable' signal is to ensure that unless a module is selected to reply, it disconnects itself from the link back to the master so other devices can use it instead.

I actually use ADM489 (or MAX489) transceivers which have a single receiver and driver in one package. Each direction has an enable signal but I keep the receive permanently active and control the transmit enable to connect and disconnect from the return lines. I use differential RS432 connections because my modules are physically separated by several hundred metres but for short distances you could use signal and ground connections.

Brian.
 
Thanx again, Brian. This was very helpfull.
I'll try and experiment with all this as soon as my PICs arrives.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top