Pages: 1 [2]   Go Down
Author Topic: Serial Communication Between 2 Arudino Unos  (Read 478 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3412
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11170
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 23, 2013, 04:06:34 pm by PeterH » Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 [2]   Go Up
Jump to: