one master , many slaves

Hi all
I am having a project that using readers with multi arduino micro controllers.
I'll have many slaves(arduino pro mini) in which i am trying to connect to master one.
The master may receive one signal or many at the same time.
The problem is that all of the tutorials i found that saying the master will request from slave.

In my project the master doesn't need to request , it should recieve only.

How can that be programed and what is the best way to do so.

:blush:

This is very difficult.

If the slaves can transmit at any time, you have no way of preventing two or more from sending at the same time, which will make it impossible for the master to serve all the slaves, unless you make a very complex protocol with collision check.

It's much easier to make the master ask each slave for data one at a time.

What kind of media / protocol are you using ?

Thanks Mik

so you suggest to send from one slave once ?

i am using SPI protocol.

I have another problem how can i connect the master to PC through usb using which port

A major question: What is the response time needed when a "slave" has data that needs to be transmitted to the "master"??

AsimSan1:
Thanks Mik

so you suggest to send from one slave once ?

i am using SPI protocol.

I have another problem how can i connect the master to PC through usb using which port

Your master can send an 'ask' command to each slave,one after one. If slave as a data, then it answer : I've data.

so, the pseudo code could be (Master):

Loop forever
for Each Slave
do
sendCommand('DATA_FOR_ME?') to Slave
GetAnswer
if Answer is 'I HAVE DATA FOR YOU'
sendCommand('FEED_ME_PLEASE') to Slave
endfor
endLoop

and for each slave:

Loop
DoSomeJob (ge temp, light leds, etc...)
if Master ask 'DATA_FOR_ME?'
if I have new data
Send 'I HAVE DATA FOR YOU'
wait for 'FEED_ME_PLEASE' command
Send DATAS
else
Send 'NO DATA FOR YOU, F..K'
EndLoop

When you connect a Duino boardtoa pc with usb, it's in fact a serial port. So from you can exchange to the Duino with serial protocol.

And, as Terry King wrote, all depends of the time these datas must reach the master, and also how often, with which frequency (1 time par hour, minutes, seconds ? Several time par seconds ? every 60ms ?)