[SOLVED] CF 2.0 not restarting in firmware mode

Post here to get support
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: CF 2.0 not restarting in firmware mode after flashing

Post by tobias »

I tested your latest firmware with 100kHz I2C1 and changing the MB1242 device address to 0x50 (eeprom). I don't get any issues with the cfclient. Things seem to work as it should, very strange. Can you try changing the MB1242 device address as well?
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: CF 2.0 not restarting in firmware mode after flashing

Post by alex »

tobias wrote:Well to steps forward and one back :).

I'm thinking there is still something wrong with the i2c buss then. If you flash the release software I guess everything is working as it should (to rule out cfclient issue)?
Yes, with the original firmware everything's fine. Didn't even change the cfclient.
tobias wrote:I tested your latest firmware with 100kHz I2C1 and changing the MB1242 device address to 0x50 (eeprom). I don't get any issues with the cfclient. Things seem to work as it should, very strange. Can you try changing the MB1242 device address as well?
Had an address conflict in mind, too. I'll check this.
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: CF 2.0 not restarting in firmware mode after flashing

Post by alex »

Yesterday, I did some more testing:
  • Added function to change the I2C address of the sonar sensor. See my repo, branch "sonar-cf2"
  • Successfully changed the sensor's address to 0x30.
  • Verified the new address via sensor pin 2 by looking at the address announcement with an oscilloscope (pin 2 high for 4,8 ms on start-up represents 48 dec which equals 30 hex).
    pin2-address-announce.png
    pin2-address-announce.png (2.84 KiB) Viewed 7444 times
    pin2-address-announce-deltaX.png
    pin2-address-announce-deltaX.png (3.73 KiB) Viewed 7444 times
  • Changed the I2C address (MB1242_I2C_ADDRESS) in my code to 0x30 accordingly, of course.
I changed the sensor address with the same code (call to mb1242SetAddress is deactivated now) which runs into a hang-up later, so I suppose that I2C operation is ok in general.

Unfortunately, this doesn't solve the hang-up on copter's startup:

The motors spin up just normally and the red heart beat (low frequency) shows up. The latter is only visible as long as the copter is moving. As soon as I place it on the table and the self-test/IMU calibration passes, the red LED flashes one or two more times (with higher frequency) and then stays dark. At this stage I can find the copter with the PC Client, but connecting isn't possible. I was able to see a very short I2C communication (few milliseconds) on the oscilloscope when powering the copter so I'll try to trigger this again and take a screenshot. I could take a video of the copter's start-up, too.

Any suggestions?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: CF 2.0 not restarting in firmware mode after flashing

Post by tobias »

I got a MB1242 in the mail today!

I hooked it up to a breadboard and grounded pin 1 to set default address (0x70). I changed that in your code and tried it.
It started communicating right away however after ~10s it stopped and the CF2 froze. (timeout bug) because the MB1242 didn't answer for over 100ms.
I changed the code to only take readings every 100ms. it still froze after a while. Now I changed the I2C clock to 400kHz and now it seems to be communicating fine. One little problem though, the range reading is always 765 (0x02FD)... Have not yet investigated this.

You haven't by any chance wired the MB1242 wrongly, swapped SDA and SCL?
Attachments
mb1242 i2c com.png
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: CF 2.0 not restarting in firmware mode after flashing

Post by tobias »

Apparently my fat belly was not a good object for the sonar to take readings on and now it seem to work pretty fine. I also soldered the header on the MB1242 which I didn't want to do at first which could have made a difference.
Attachments
Sonar reading plotted.png
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: CF 2.0 not restarting in firmware mode after flashing

Post by alex »

Perfect, great job! Glad that my code works fine. Thanks for buying the sonar, even though I could have lent you mine! Where did you get it from?

I'm going to play around with my equipment again tonight, check my prototype soldering and breakout board wiring.

What's that software on your screenshot for I2C debugging called? Is there additional hardware needed for this?
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: CF 2.0 not restarting in firmware mode after flashing

Post by alex »

I followed your report step by step (except for grounding pin 1, I'm still using address 0x30), but no change. I double and triple checked the prototype board and also hooked the sensor up again from scratch without the board in between --> copter always shows the same symptoms i.e. freezing after flashing the red LED twice when switched on lying on the table.

I really don't have any clue what's going wrong here!
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: CF 2.0 not restarting in firmware mode after flashing

Post by tobias »

What's that software on your screenshot for I2C debugging called? Is there additional hardware needed for this?
Yes it requires additional hardware and I'm using the beagle from totalphase. There are many alternatives e.g. the bus pirate.

My best guess is that the MB1242 doesn't respond for some reason. As talking to the EEPROM works? the I2C bus should be functioning. An analyzer would help you find the problem quickly.
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: CF 2.0 not restarting in firmware mode after flashing

Post by alex »

It is working!! :D :lol:

Connected pin 1 to GND to set the sensor's address to default 0x70 and initialized I2C1_DEV with 100 kHz. It works for RANGING_CYCLE_MS = 80 or 100, doesn't matter.

I don't know what the reason was, actually. Tested with the same address in the beginning. To speak from my own experience: electronic components, especially in complex environments like this one with many dependencies (bus speed, read frequency, other peripherals on the same bus, sensor-specific details), sometimes behave unexpectedly. Still need to learn alot, though.

Thanks to everyone who spent time (and money!) on helping me.

Glad to have you in the forums more often again, Bitcraze guys!
Post Reply