Page 2 of 8
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Wed Jul 30, 2014 4:23 pm
by tobias
I'm on my mobile so it will be a bit short answer. Since the ext I2C is on anothet I2C bus you need to initialize it. Have a look in imu.c to see how it is done for the other i2c bus.
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Sat Aug 02, 2014 9:30 pm
by alex
tobias wrote:I'm on my mobile so it will be a bit short answer. Since the ext I2C is on anothet I2C bus you need to initialize it. Have a look in imu.c to see how it is done for the other i2c bus.
Ok, corresponding to your advice I've rewritten my code and placed it in a separate file mb1242.c. Where do I have to put this:
Code: Select all
i2cdevInit(I2C2);
mb1242Init(I2C2);
If I place the I2C initialization (I2C2, correct?) in stabilizerInit(), the copter stops responding after startup and the red/green LEDs won't flash normally but simply stay dark.
I don't have HAL functions implemented so far, so there isn't something like imu6Init() for initializing.
Can you help me out? Thanks for putting me on the right track, tobias.

Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Mon Aug 04, 2014 3:34 pm
by tobias
The problem might be that you are not running the latest FW where there was a bug in the i2cdevInit? Do you have your repo on github so I can have a look at your code?
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Mon Aug 04, 2014 9:40 pm
by alex
tobias wrote:The problem might be that you are not running the latest FW where there was a bug in the i2cdevInit? Do you have your repo on github so I can have a look at your code?
I pushed the changes to my own fork:
https://github.com/alexriegel/crazyflie ... nar-mb1242.
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Sat Aug 09, 2014 1:28 pm
by alex
Any idea, tobias? My fork should be up-to-date.
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Tue Aug 12, 2014 10:15 am
by arnaud
Tobias is on vacation so I had a look. Do you still have problems? I pulled your branch, compiled and the copter starts normally. I see that your latest commit corrects the I2C address so I assume something is working, or?
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Tue Aug 12, 2014 10:54 am
by alex
arnaud wrote:Tobias is on vacation so I had a look. Do you still have problems? I pulled your branch, compiled and the copter starts normally. I see that your latest commit corrects the I2C address so I assume something is working, or?
Thanks for taking over, arnaud.
No, my copter still doesn't initialize normally - as stated above. After switching it on, the copter isn't responding and the red LED stays dark. With the standard firmware everything's fine.

It seems like my copter doesn't get far enough, so I have no chance to verify the address thing.
Is my I2C2 initialization code correct? The I2C2 interface is the right choice if the device is connected to the expansion header, isn't it?! Can I find this correlation somewhere in the documentation or do I have to simply know it?
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Tue Aug 12, 2014 12:08 pm
by arnaud
The best to see which I2C is used is the schematic:
http://wiki.bitcraze.se/_media/projects ... _rev.f.pdf so yes the expansion port I2C is I2C2.
As for the crash at startup I do not see it, when flashing program from your branch my Crazyflie starts normally. It may be related to the presence of the I2C device. The best would be to see where it crash exactly, do you have a jtag debuger? Otherwise I would use the leds: lighting up led at different stage to see what is making program crash.
I see one point where it could block because of the hardware: i2cdev.c:347,
https://github.com/bitcraze/crazyflie-f ... dev.c#L347
If for some reason SDA is low it will never leave the i2cdevInit function.
Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Wed Aug 13, 2014 10:00 pm
by alex
arnaud wrote:As for the crash at startup I do not see it, when flashing program from your branch my Crazyflie starts normally. It may be related to the presence of the I2C device. The best would be to see where it crash exactly, do you have a jtag debuger? Otherwise I would use the leds: lighting up led at different stage to see what is making program crash.
No, I don't have a jtag debugger.
I should have stated the startup behaviour more precisely: the motors are spinning up synchronously as they are supposed to be. Afterwards, both the red and the green LED are blinking for about half a second before they stay dark in the end. The blue LED is on all the time. Does this help? If not, I have to try your "debugging" trick with the LEDs.
Ok, I see. For what reason should the SDA line stay low unexpectedly? Can't get the point somehow...

Re: [Hover] Selecting an ultrasonic sensor and interface
Posted: Thu Aug 14, 2014 10:12 am
by arnaud
This sounds like it is crashing somewhere when reading the sensor. It could help to look at the I2C lines to see if there is any communication going on. Also lighting up an LED just before reading a range value and lighting off just after will tell you if it crashes in this part of the code or somewhere else. Also a random though: try to increase the stack size of the task that runs your code. Having a stack overflow there it typically the kind of thing that would crash the copter.
Ok, I see. For what reason should the SDA line stay low unexpectedly? Can't get the point somehow...

The point is that SDA should not be pulled low. If it would happen it would most likely be a cabling or hardware error. But as the copter is passing the self-test this is not it.