Communication with second Arduino

Added by Adam Holdsworth about 4 years ago

Hey Kwabena,

I have two Arduinos running for my application, a Mega connected to the CMUcam4 to run only the code to track a line, and an Uno that is running a program that tracks speed (among other things). I want to send the speed reading to the Mega so that it can adjust the steering control based on speed (sometimes it'll be going slow, other times fast, and it needs to adjust for proper steering control). What are some good ways to do this? I wrote simple barebones master/slave programs that properly sent/received the information, but when I put this same code in with the CMUcam4 code and the code on the Uno, it wasn't getting accurate readings. I checked the code and it matched with what worked but was wondering if there was something I may be missing...

Thanks in advance! Let me know if you need any other information.

Replies (4)

RE: Communication with second Arduino - Added by Kwabena Agyeman about 4 years ago

You can do everything on just the mega. Have you seen this:

RE: Communication with second Arduino - Added by Adam Holdsworth almost 4 years ago

I took a look at those files and am curious if it will work for me. To track speed and other parameters, I have an interrupt that counts rises from an infrared emitter/detector inside one of the wheels for 0.2s at a time. Will adding the two together throw off the timing? I may be thinking of it incorrectly, but running through my head seems that it'll take whatever time (I think currently .16s) to process the image on top of the .2s it takes to figure out speed and throw off calculations. Maybe I'm wrong...? I'm not totally sure but you will probably know. Thanks!!

RE: Communication with second Arduino - Added by Adam Holdsworth almost 4 years ago

Actually I think I answered my own question. I swapped my configuration just to test it out and, although I haven't turned on the steering to make sure it's working properly yet, the timing seems to be pretty good, and at least close enough to what I need it to be. It's running a full loop at about .211 seconds with speed control and steering calculations tossed into the mix. I'll be playing around with it some more and see how I do. In my mind I didn't think running everything on the one board was going to be a good way to go but it will do just fine :)