I2C woes


Stepped the wireless down to 11megabit & the range definitely increased.  It uses a lot more power because the transmitter is on longer, but the penetration is much better. 

Found another 64k of RAM on the STM32F4.  It's the fabled core coupled memory, bringing the chip up to 192k.  That increased the framerates.

640x480 color: 5fps  1.4 megabits
640x480 greyscale: 7fps   1.8 megabits
320x240 color: 23fps 2.5 megabits
320x240 greyscale: 30fps 2.5 megabits

The trick with the core coupled memory is it can't be accessed by any peripherals.  The network now needs a memcpy.  The mane benefit is there's enough RAM to have the largest buffers, all the time.  The camera can be in 320x240 greyscale for navigation, than briefly switch to 640x480 color for a photo, without having to shuffle buffers around.

There are also 320x480 & 160x240 modes.  The theory with this is a rolling shutter camera can be used in pushbroom mode, capturing a wider field of view by compressing the vertical lines.  The resolution becomes equivalent to 2 320x240 images stacked on top of each other.

320x480 greyscale: 14fps
320x480 color: 9fps

160x240 color: 30fps

160x200 is Commodore 64 resolution. 

The camera was damaged from pointing at the sun.  It didn't generate hot pixels, but made areas more blue.  Between hot air melting & sun damage, it's real fragile. 

Spending 2 days optimizing different video modes was a waste, but it might have come in handy for any job interviews.  Times have changed.  Job interviews today are straight programming tests from Google's interviewing style.  They're not interested in applications, but very specific knowledge about a programming language.  Google is presumed to be the handbook for everything.

The tasks of PWM, battery sensing, & magnetometer reading, which are the bread & butter of aviation, sure look mundane once you get video going.  The STM32F4 makes life a lot easier with pullups on all the GPIO pins & 2 32 bit timers, allowing 8 channels of 200 Hz PWM with no funky interrupt handling.

The magnetometer used in Marcy 1 & Marcy 2 was a freebie AK8975, which came at a cost.  It's sold in 32 piece minimum quantities & costs $6.  You're looking at $200 just to get started.  Almost anything is cheaper.   The HMC5883 is $4 & has an I2C interface.  It's most certain that every production run of Marcy 2's would have completely different parts.

There's actually a chance video could do the job of the magnetometer.  To be sure, Chinese toys have used video of sorts to stay in a certain horizontal position forever.


Airframe assembly begins.



It's been ages since I ever removed the photoresist or actively tinned anything.  Tinning would definitely make it heavier.


That is a heavy board.  The bottom of the camera faces the leading edge, so the scanlines cover a longer distance than a single frame.

This arrangement immediately caused the RF emissions to crash I2C.




Various attempts to defeat it failed.  Lower pullup resistors on I2c, routing the I2C away from the wifi, moving the wifi away from the motherboard didn't work.  It's just going to be limited to 40 samples/sec by the RF.  The same thing happened on Vika 1 with the XBee. 

Marcy 1 needed 112 samples/sec & got that with a long I2C cable, but a very low power radio.  Cell phones must have a lot of shielding between their I2C sensors & the RF.  The AR drone has the Wifi on the opposite side as the analog sensors.

Seem to recall having a dream about fixing I2C on this board.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • You may have already seen these, but, nice info for differential I2C implementation (P82B96, PCA9600 NXP)

    "Reliable I2C-bus communication at high data rates, and over many meters, can be achieved using widely available twisted-pair communication cable (e.g. Category 5e and similar 4-pair cables, as typically used for Ethernet communications)." 



    Keep up the good work!

  • I2C is seriously fragile in the first place, it's got no inherent protection against EMI.

    One thing that might help is to twist SDA and SCL with 0V, but probably not enough for that kind of length.
    - Twisting SDA and SCL together does nothing at all except make the wiring look neater.

    Level-shifting to a higher voltage along the wire may also help if you can get the threshold voltages far enough apart for the noise level.

    However, the real problem is the distance. I2C was never intended to be used like this so you should try to get the master and slave closer together by any means necessary.

    In cellphones I2C lines are a couple of cm long at the maximum, less if they can manage it.

This reply was deleted.