'Handshake' between four Arduinos

Hi
I am working with led S2812b panels ; Eight 16X16 panels controlled by four Arduino Unos.
The Arduinos are running the same sketch but getting out of sync.
The problem was solved for two
Arduinos with the handshake code below:

First
I linked the two Arduinos with two wires running crisoss from 4 to 3 then 3 to 4.
In the sketch I defined pin in & pin out :
#define pinin 4
#define pinout 3

In the loop I added this code just before the problem area where the loss of sync showed up:
void loop()
{
// Hand Shake
digitalWrite(pinout, HIGH);
while (digitalRead (pinin) == (LOW));
delay (1)
digitalWrite(pinout, LOW);
This works beautifully fot the seperate two pairs
Then I tried syncing the two pair of Arduinos so I would have the four Arduinos working in sync:

So, I placed physical wires between pins 5&2 and 2&5 (As above with 3&4)
#define pinin 5
#define pinout 2
So the 4 Arduinos are all connected
I alsi added another code section of
"// Hand Shake
digitalWrite(pinout, HIGH);
while (digitalRead (pinin) == (LOW));
delay (1)
digitalWrite(pinout, LOW);

BUT
The problem is only three of the Arduinos sync while one stays out of sync.
Photo of wiring attached
Any ideas ?
Thanks
John

IMAGE LINK

https://www.screencast.com/t/9FLkuHaZn

Eight 16X16 panels controlled by four Arduino Unos.

running the same sketch ? does that mean they are showing the same pattern ? If so, then why ? You should provide us with a bit more info.
The system of trying to sync them all seems very unpractical, but if you think that is the way to go, i would let one Uno be in control of the other 3, but as i said i don't think this is the way. Please describe what is your eventual goal.

d333gs:
IMAGE LINK

2021-02-20_15-36-00

You can post an image by first attaching it, and then copy the link and paste it within the image tags

Thanks for the reply;

A video will best demonstrate why I am syncing 4 Arduinos

This is a short section of a long animation. If one Arduino gets out of sync it ruins the effect
John

I agree with Deva_Rishi. It is very unpractical, there are situations in which the handshake can fail.

You could make one board the "Controller", or add a 5th board as Controller.
The Arduino Uno does not have an extra serial port, but with SoftwareSerial or AltSoftSerial the Arduino boards can be connected.

The "Controller" would send a command to tell what the others should do. The TX of the Controller is connected to all the RX of the other boards.

Could it be possible to have just one Arduino board for everything ?
Are the four led bars with WS2812B always the same ? So you could connect them to the same Arduino pin ?

It is possible to have different patterns with just one Arduino board. That requires advanced programming with millis().

Rather than have two-way handshaking I would try having one Arduino send a single sync signal to the others. Just build enough slack into the repetition so that the "slaves" only start their next routine after detecting the handshake pulse.

...R

From your wiring picture, I do not detect any wire connecting the Arduino grounds all together. Perhaps you have three boards fed from one PSU and the 4th from a separate PSU?
Paul

Are the four led bars with WS2812B always the same ? So you could connect them to the same Arduino pin ?

That is what i was thinking, or given a board with bigger memory, just keep daisy chaining. 16X16 is already 256, so with 2x that you do get to 1.5kb just for the buffer. It is something to keep in mind anyway if your patterns would get more complex. But with a nodeMCU, there is no problem. (there might be if you would want to use the WiFi but you are not using that now)
If you find that the signal from the arduino pin (with the resistor inline) is not strong enough you could split it with a TTL chip (7400 series i'd use a 7404)
A solution with the syncing is always going to be cumbersome, but a single pulse from one of the UNO's to the other 3 should work. Master sends a pulse every 15ms or so, and the other 3 are waiting to receive it. Like that you make sure that all the boards are ready and a frame every 15ms is fine for the human eye and mind.
Still i'd just go for the nodeMCU, daisy chain them all and simply mirror the buffer , also because like that you remove all your future limitations.

7400 series is poor choice.
Use 74ACT, such 74ACT241, with +/- 24mA drive capability.
https://www.digikey.com/en/products/detail/texas-instruments/CD74ACT241E/1692008
Less expensive too.

Vs 400µA High, 16mA Low for a 7404
(yes just 0.4mA high output current)
https://www.digikey.com/en/products/detail/texas-instruments/SN7404N/555980

Thanks everyone
I will look at the master-slave solutions you have suggested.

I was wondering about using two Megas vs four Unos and using a handshake between just two ?

7400 series is poor choice.

Yeah, yeah 7404 is almost not available anymore, i mean 74LS, HC, HCT ACT, whatever really ! WS281x have a logical input (mind you not working without some current, but very little) the issue is not so much in the driving current as it is in the capacitance of the wiring. Since in this all of the capacitance of the data wires which are actually directly connected together, add up, the idea is to split them through a TTL chip, with a separate output each. Anything you have lying around will probably do the trick.

I was wondering about using two Megas vs four Unos and using a handshake between just two ?

Why would you need more than 1 Mega ? (or more than 1 UNO for that matter) Why don't you show us the code that creates the patterns, so we know what library you use.

Ok, Got it working with a handshake loop using the same simple code and two pins.

Thanks to everyone
John
Photo link
https://www.screencast.com/t/kQxhzARn9wP

Deva_Rishi:
Yeah, yeah 7404 is almost not available anymore, i mean 74LS, HC, HCT ACT, whatever really !

Not 74LSxx - that's no better than 74xx as its also TTL and can't pull up much.

74HCxx is the go-to CMOS logic family unless you need something more exotic.

Re; 74HCxx
How would you set this up?

Thanks

Not 74LSxx - that's no better than 74xx as its also TTL and can't pull up much.

It doesn't need to be any better, it doesn't need to pull much when you are driving a logic input (even if the internal resistance is not even 1M)

Re; 74HCxx
How would you set this up?

I use a 74xx04 which is 6 not-gates of which i would use 5 like this :
not gate Splitter.JPG
Still as i said before depending on you library you can also send the same buffer to different output pins (easily done with FastLED, but must also be possible to do something similar with neopixel.h though that would require a library modification, but i am a little tired of guessing how your sketch is set up)

not gate Splitter.JPG

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.