I have a dilemma but I'll explain what I'm trying to do in order to make the problem easier to understand:
I'm making a lazertag system. I have two IO pins controlling a multiplexer so that the correct sensor from the sensors connected to the multiplexer is chosen as the receiving sensor and that is connected to RXD.
The TXD pin is connected to the output lazer.
I made a similar system for the PC in which it emits lazer for transmit and has a sensor for receive so that I can do testing.
Now, what needs to happen is that once the game starts, I want to transmit only 2 bytes then wait until all the other players had a chance to transmit their bytes. So if I were to make a 50-player system and it took 1ms to transmit 2 bytes for the 1st player, then that player should wait 49ms before he can transmit again. I want the timing to be close to exact as possible to minimize waiting time.
I made a similar system to this in the past but the only way I was able to achieve some success was to resort to incorporating a software UART which takes up a lot of variables and code.
I want to avoid software UART.
Now here's the dilemma...
If I give timer the priority for every player's unit, then waiting time for each player can be minimized however the data transmission may be inaccurate, especially if the timer needs to be called right before the second byte needs to be received.
If I give serial the priority for every player's unit, then the timing could be off and some receivers will receive incorrect data due to data overlapping by say a few hundred microseconds.
The speed of the data is 4800bps or 9600bps. I haven't figured out which one to use yet.
So how do I improve timing and be able to always send correct data without two players sending a bit simultaneously and without resorting to creating a software UART?
Also, this micro I'm programming will also interface with another micro as well and that part I don't need to give priority to.
I have provided a poll as ideas for an answer to this, but the checksum option for me is a bit crazy because if two players are constantly firing at a third player then transmissions will happen at the same time and maybe that will invalidate each shot to the third player thereby making the third player invincible until the dual shooting stops.
I'm making a lazertag system. I have two IO pins controlling a multiplexer so that the correct sensor from the sensors connected to the multiplexer is chosen as the receiving sensor and that is connected to RXD.
The TXD pin is connected to the output lazer.
I made a similar system for the PC in which it emits lazer for transmit and has a sensor for receive so that I can do testing.
Now, what needs to happen is that once the game starts, I want to transmit only 2 bytes then wait until all the other players had a chance to transmit their bytes. So if I were to make a 50-player system and it took 1ms to transmit 2 bytes for the 1st player, then that player should wait 49ms before he can transmit again. I want the timing to be close to exact as possible to minimize waiting time.
I made a similar system to this in the past but the only way I was able to achieve some success was to resort to incorporating a software UART which takes up a lot of variables and code.
I want to avoid software UART.
Now here's the dilemma...
If I give timer the priority for every player's unit, then waiting time for each player can be minimized however the data transmission may be inaccurate, especially if the timer needs to be called right before the second byte needs to be received.
If I give serial the priority for every player's unit, then the timing could be off and some receivers will receive incorrect data due to data overlapping by say a few hundred microseconds.
The speed of the data is 4800bps or 9600bps. I haven't figured out which one to use yet.
So how do I improve timing and be able to always send correct data without two players sending a bit simultaneously and without resorting to creating a software UART?
Also, this micro I'm programming will also interface with another micro as well and that part I don't need to give priority to.
I have provided a poll as ideas for an answer to this, but the checksum option for me is a bit crazy because if two players are constantly firing at a third player then transmissions will happen at the same time and maybe that will invalidate each shot to the third player thereby making the third player invincible until the dual shooting stops.