Go Down

Topic: Serial Communication Between 2 Arudino Unos (Read 599 times) previous topic - next topic

spidervann

Thanks Arrch, I tried the (else if) but stil experience the 6 sec lag. How close to simultaneous should I expect?

wildbill

I don't think this is the cause of your issue, but the sending arduino is spamming the other with continuous writes. It's really only necessary when the LED state needs to change. Keep the state in a variable and only when you need to change it would you transmit anything.

I'm not sure why the receiver echos back to the sender if it doesn't get an 'H' either.

What I'd do though first is test each module independently with the IDE as I alluded to above.

PeterH

#17
Jan 23, 2013, 10:03 pm Last Edit: Jan 23, 2013, 10:06 pm by PeterH Reason: 1
There seem to be three mistakes.

The sender is sending data as fast as it can without regard for the limitations of the serial link. This means that the link is permanently congested so any message indicating a change in the input value has to sit in the serial buffer while the previously queued messages slowly trickle across the link.

The receiver is outputting several character each time it receives an 'L' character. This means that while it is receiving 'L' its serial output stream will be congested since it has to wait to output several characters for each one it receives. Meanwhile of course its receive buffer is full of stale messages that all have to be read and processed before the new input value is finally noticed.

Finally, the sender is not consuming the output from the receiver so the return serial stream will be stalled anyway.

If your goal is to have low latency then you need to throttle the transmission frequency so that the sender's outgoing serial buffer remains clear, and take out the code from the receiver to trace the incoming values, or change the output format so that it outputs no more than one output character per input character and then add code to the sender to read from the return serial stream.
I only provide help via the forum - please do not contact me for private consultancy.

gnusso

Hi , maybe you can try to use virtual wire or wire library  in i2c.. For use serial you never to disabile serial use for program arduino ... My understanding was that ...

Regards
Gnux

Go Up