[SOLVED] Selecting an ultrasonic sensor and interface
Re: [Hover] Selecting an ultrasonic sensor and interface
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
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: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.
Code: Select all
i2cdevInit(I2C2);
mb1242Init(I2C2);
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
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
I pushed the changes to my own fork: https://github.com/alexriegel/crazyflie ... nar-mb1242.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?
Re: [Hover] Selecting an ultrasonic sensor and interface
Any idea, tobias? My fork should be up-to-date.
Re: [Hover] Selecting an ultrasonic sensor and interface
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
Thanks for taking over, arnaud.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?
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
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.
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
No, I don't have a jtag debugger.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.
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...arnaud wrote: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
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.
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.Ok, I see. For what reason should the SDA line stay low unexpectedly? Can't get the point somehow...