December 9, 2012 at 6:07 am #392
Hello! I recently purchased the VE shield and it’s been working wonderfully, however I’ve run into a problem: When I try and include an external library other than the ones required for the VE, the code simply does not run.
Right now I’m trying to include Wire.h, for transmitting data to a second Arduino, but simply adding “#include
” to the top of even the simplest VE project makes the code not run. It stops at the very beginning of setup(). I tried printing out the serial immediately at the start of setup() to see if the code is being run at all. It was meant to print, “Beginning setup” at the start, but it just prints “Be” then stops. No loop(), no rest of setup(). This is fixed and the code runs normally if I comment out the “#include ” line.
Is this normal? Any help?
-TerryDecember 9, 2012 at 2:14 pm #1528MichaelKeymaster
The video processing code (TVOut library) is interrupt driven and depends on very precise timing. Trying to use other interrupt driven protocols will interfere with the Video Experimenter. Basically, it takes all the muscle that the ATmega328 has to generate video with correct timing.
I successfully used I2C communication with a very trimmed down version of the I2C library when I implemented the Wii nunchuck controller for my Hackvision product. The important part is only doing I2C communication during the vertical blanking interval in the video. That is, the only time you have time to communicate is at the end of each frame.
See the Hackvision Controllers library (specifically the nunchuck controller) and i2c.c, i2c.h for some info on how to do this. It’s tricky.
The Controllers library can be downloaded from:
http://nootropicdesign.com/hackvision/games.htmlDecember 9, 2012 at 3:01 pm #1529
Thanks for your reply, it was very helpful. Looking at the nunchuck library I can see there are begintransmission, endtransmission, and send functions similar to the Wire library. Would you be able to briefly explain how I could use these in a similar manner, as well as how I should properly connect two Arduinos in order to communicate using these? If not, is there a specific tutorial or example I should look to for how to do this?
Thanks!December 9, 2012 at 4:24 pm #1530MichaelKeymaster
It would be much easier to use serial communication between the Arduinos. TVout comes with a polling version of serial communication (versus interrupt driven). See the “pollserial” library in TVout. There are examples in the “examples” folder.
This allows you to perform serial communication between the devices even if one is using TVout. Connect RX to TX and TX to RX between the Arduinos. Also connect the grounds. Use pollserial on the Arduino using TVout, and use the normal Serial library on the other Arduino. I’d use a speed of 9600.
Hope that makes sense. This will allow you to communicate in the easiest manner. I would avoid I2C unless you can find a polling version. My trimmed down I2C implementation is only suitable for very tiny amounts of data (like nunchuck readings).December 9, 2012 at 4:39 pm #1531
That sounds good, thank you very much!
- You must be logged in to reply to this topic.