hi all,
i am on the project of a race timer. having 2 timers in it. Mega is in main unit and 2 Nanos are at end. Nano are working for P10 module as stopwatch. using RS485.
Mega starts the race. Both P10 module are running.
My issue is, while both players tapped the touchpad near P10 module, timing needs to come to Mega for display.
getting fustraited.
I am using softwareserial library
Software serial can only work one channel at a time. The Mega has three free serial hardware channels plus the console, why not use them. Also post a schematic showing exactly how this is wired and note any wires over 10" in length. Why separate units, the Mega should be able to process two channels.
Without seeing the rest of your code, I bet you are invokiing software serial twice in your program. Only the LAST one invoked will be active. There is only a single software serial possible at a time. Why not use a hardware serial port?
its a timing device for race. Mega is used with btns like start, reset etc with plug and play tft screen. 2 Nanos with P10 modules are at endpoint of race. Communication is through RS 485, because of distance is 30 mtrs.
when i am calling timing by pressing btn or coding from 1st, it comes. when calling from 2nd, it comes.
but my issue is why to call seperately ?
aftering triggering touchpads at both endpoints, Timings should come automatically, whichever is first or second.
i am trying to code on this line "timing should come immediatelly after hitting touchpads, in any sequence."
u r correct. the last one invoked is active.
thats why, i am using xxx.listen() for half or a minute there and calling timing. thereafter again using yyy.listen() for half or a minute and calling 2nd timing.
my plan is Mega is calling both timings from both Nanos simultaniously (i.e. using if available).
i am calling unsigned long using millis() to display it in clock style.
calling timing simultaniously with 2 triggers successfully
but why to use trigger, it should come automatically with coding, after hitting touchpad at endline of race, whichever 1st or 2nd.
that is my issue
now....
can i use hardwareserial for RS485 ?
can hardware serial can accept multiple timings at a time ?
any example please....
But you have not invioked the second serial by just doing a listen. You have to go through the WHOLE set up procedure first so the address will point to the new connection. So much easier to just use the hardware uarts that your board already has.
The MEGA has 4 serial ports, each totally independent of the others. The MEGA hardware serial ports are interrupt driven for both TX and RX. when incoming data is received it gets copied in a software buffer that you can read later, the default size is about 64 bytes . Conversely be send gets copied into a software buffer (except for the first byte when the transmit register is empty, that will be placed straight into the transmit register).
You can change the serial buffer size() with something like this. #define SERIAL_RX_BUFFER_SIZE 128