0
\$\begingroup\$

I need to design a LED chaser that expands as you add modules, modules are daisy chained to each other over long distance.

I was thinking of using a master and N number of slaves, my first though is to use UART as I can transmit commands from one module to the other. But how do I transmit the number of connected modules in the system to the master. The master will be a MCU that will control the pattern of activation and timings. The slaves can also either be small cheap MCUs or some LED drivers or something else.

Here is an illustration. enter image description here

\$\endgroup\$
3
  • 1
    \$\begingroup\$ See cpldcpu.wordpress.com/2014/11/16/ws2812_length \$\endgroup\$
    – Passerby
    Feb 19, 2018 at 18:33
  • \$\begingroup\$ There are plenty of schemes which allow bidirectional communication on a single signal wire. Simplest are those that operate mostly in one direction, but occasionally feature questions which request a reply in the reverse direction. On an ATmega any special function pin you might use in one direction could be temporarily re-purposed and bit-banged or monitored by software in the other, perhaps at a lower speed. Or you can tie transmit and receive pins together, but generally keep the transmit pin configured as a GPIO input. \$\endgroup\$ Feb 19, 2018 at 19:48
  • \$\begingroup\$ Measuring power consumption of an addressable LED string is a good technique, though I'd be tempted to walk a single activated pixel down the line and look for where it stopped causing the usual voltage dip at the point where the command becomes addressed to something that doesn't exist. \$\endgroup\$ Feb 19, 2018 at 19:52

4 Answers 4

1
\$\begingroup\$

You can implement a GetSlaveCountCommand. You send the command to OUT channel. That slave on OUT channel will answer with its "child" count. When being asked, you answer "child" count of your slave +1. You only need to implement a RX on master.

If you change your chaining to create a ring, you can also implement a chirp command where Master sends 0 to slave 1. Slave 1 sends 1 to slave 2 and so on. The last slave loops back to master. You will get your count. This technique is interesting because you can add another byte to indicate whether the chirp first started from master. If not, you actual counter value indicates which slave is orphaned.

By example, if you have 5 slave and, master would expect to receive 5. If connection between slave 3 and 4 is broken, slave 4 will send 1 (with flag indicating not from master), 5 will send (2 with not from master flag) and master will know that 2nd slave in a 0-indexed mode from end is disconnected from the chain. When all slaves are connected correctly, master receives 5 and not from master flag won't be set, so it is actual count.

If you use only a single UART port for this slave 1 tx to slave 2 rx; slave 2 tx to slave 3 rx and so on, it will take exactly the same amount of wiring and you will get your feedback back to master with device failure detection.

\$\endgroup\$
4
  • \$\begingroup\$ ok, I think I understand what you meant, but I cant loop back to the master because slaves are all the same and I don't know how many will be attached. could be 3 could be 7. \$\endgroup\$
    – Seeker
    Feb 19, 2018 at 20:22
  • \$\begingroup\$ @Seeker you jumper the exit TX and RX on the last one in the chain. \$\endgroup\$
    – Trevor_G
    Feb 19, 2018 at 21:29
  • \$\begingroup\$ i don't know which one will be the last one, the slaves should be all the same. connected in any order \$\endgroup\$
    – Seeker
    Feb 20, 2018 at 8:29
  • \$\begingroup\$ It doesn't matter which order they are connected. Point is that each slave is the master of the next. The real "master" will sent a digit to its direct slave (0). That slave, no matter its order will simply pass down that number to the other slave +1. The last one will only chain back to either itself or directly to the master. The only difference between slaves is wiring, no the actual "pcb" or "code". \$\endgroup\$
    – Mishyoshi
    Feb 20, 2018 at 12:53
0
\$\begingroup\$

As @Mishyoshi suggests you need to have a way to get the length of the string as you dynamically extend it.
You can do this by sending a command that gets the last module to respond, however that implies that each module knows when there is a downstream partner connected.

In conventional RS232 land you'd do this with CTS/RTS so you know there is a client connected to the output port. Since this involves extra wires I'm sure you'd want to avoid it as a solution.

As a simple protocol without any inter module connection test you could send a command to which each module responds with its ID number, so for one out command character you'd get say a one character reply from each module ...so for 4 modules south of the master you'd get four characters in sequence back to the master. Send the command on a regular basis and you'd have a viable schema. Here you have each module separately identified (if you have unique module ID numbers, which is a good idea IMO) with the character order telling you it's position in the string.
The downside here is that when the out command reaches the end of the module string you have to use a timeout value to know the end of the string was reached.

If you want to reduce the number of character replies involved or don't have ID numbers for modules, one thought is to use a current detector on the Vin power line. Draw say a fixed number of mA (your downstream MCU may be enough) and assume that if current is drawn there is a southside client connected. The last module now knows if there is another module connected, and if there is not, it sends a reply character. So the command out gets a single character reply from the query command.
To get a string count the modules would have to increment the count for the return character as it passes through each module on the way back to the master. Each module records the count value as it's own position number in the string. So modules have a count value from the south end starting at 1.

While on the subject of Vin, I'd suggest it would be better to use a much higher supply voltage (say 48 V DC) to reduce the current flowing down the wires. You will have voltage drop to contend with in both Vin and Gnd so increasing the voltage reduces this problem.

If you are using RS232 Tx/RX then your baud rate needs to reflect the distance between modules, with 10m I'd suggest no more that 9600 baud ...this gives you a character space of about 1 ms and you'd need to decide if this is fast enough fro your application.

\$\endgroup\$
0
\$\begingroup\$

If your micro of choice has a single micro you can chain them like this.

enter image description here

In that scheme messages are normally send as a packet of data that includes an address byte or bytes. If the first slave received the packet and sees it is not address to it, it simply sends on the data to the next one.

If the packet IS for that slave, the slave does what it is ordered and sends a response packet, this is again simply forwarded by the following slaves.

A special "WhoIsThere" command can also be sent and received by each slave which causes them to send on the command after first altering the command to increase a count, or, if the slaves have different functions, add a byte on the end of the packet to identify what that particular slave does. In the process of doing that, each slave then knows it's address in the line from the data already added to the received command.

Because the last slave has its TX and RX tied together, everything should end up back at the master to deal with appropriately.

Note the slaves should also buffer the return line so the line length is controlled to the hops between slaves.

You can also add logic to the boards to allow the micro to bypass the pass-the-parcel chain once the addresses are configured. This significantly improves performance, especially on long chains.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
0
\$\begingroup\$

Yiou may want to consider yusing a Texas Instruments TLC5973 3-Channel, 12-Bit, PWM Constant-Current LED Driver with Single-Wire Interface.

Rather than use the outputs to drive an RGB LED, use one output with a resistor as your PWM Gate driver.

TLC5973 Connector Design

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.