[NEW FEATURE] Start-up Melody

Firmware/software/electronics/mechanics
Surrender
Expert
Posts: 100
Joined: Tue May 14, 2013 8:31 pm
Location: Austria

[NEW FEATURE] Start-up Melody

Post by Surrender »

Good midnight!

This evening I was developing on something new. You ever wanted a melody-making crazyflie but you didn't want to add a loudspeaker?

With this new feature you hear on start-up (when powering on the CF with the on/off button) a short melody.
Wonder how this works? With PWM and the motor coils!
I hope you like this sound sequence! If not then tell me and I will create another one.

In the future there will be more melodies available. The music player is a easy to use function in the motor.c file.

I can explain it in in detail if wished.

Here a demo from the startup sequence:
https://www.youtube.com/watch?v=7TI7a-okrE8

Here are the firmware binaries for the crazyflie:
https://bitbucket.org/Surrender/crazyfl ... /downloads

One is for the esky et6i and the other one is for the crazyradio.
High RP= high roll/pitch (90 deg/rate)

The changes from jodell's fork (eskylink.c) are already integrated and are commited tomorrow to the main firmware repo.


Greetings from the rainy austria

Sent from my GT-I9100 using Tapatalk 4 Beta
foosel
Expert
Posts: 175
Joined: Sat Feb 02, 2013 9:59 pm
Location: Obertshausen, Germany
Contact:

Re: [NEW FEATURE] Start-up Melody

Post by foosel »

Bloody awesome! :D
Image
Also: AR.Drone 2.0 (RC-enabled thanks to self-soldered MiruMod) and Hubsan X4 H107
DesTinY
Member
Posts: 97
Joined: Sat Feb 09, 2013 5:18 pm
Location: Bünde, Germany

Re: [NEW FEATURE] Start-up Melody

Post by DesTinY »

Really great Surrender! Sounds like FUN! :lol:

I have played around with your new feature :D http://youtu.be/qL1fa3oEzT8
I remembered at the time of self made ringtones of my old Siemes phone and found a nice site (LINK)with ringtone notes which easy can converted to your implementation.
Looks like "D2(1/8) P(1/16) D2(1/16)..." (1/8) =e.g. QUAD and P= STOP.

And i indeed the sound generation is very useful as outdoor finding mode! Is someone working on that!?

BTW: The sound is louder if the propellers not turn (held with the fingers). And some notes are missing (e.g. CES6, FES6). :D

Mission impossible theme (moderate):

Code: Select all

uint16_t startup[] = {
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    F6,OKTA,
    STOP,OKTA,
    G6,OKTA,
    STOP,OKTA,
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    C6,OKTA,
    STOP,OKTA,
    CES6,OKTA,
    STOP,OKTA,
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    STOP,QUAD,
    D6,OKTA,
    F6,OKTA,
    STOP,OKTA,
    G6,OKTA,
    STOP,OKTA,
    D7,OKTA,
    DES7,OKTA,
    STOP,STOP
};
Surrender
Expert
Posts: 100
Joined: Tue May 14, 2013 8:31 pm
Location: Austria

Re: [NEW FEATURE] Start-up Melody

Post by Surrender »

Thanks! Yes this is fun, i like it too :D

Yes, I'm working on that 8-) - this was just a test implementation for making a sound and after that a melody. Now i can add it e.g. after disconnect etc. I'll have to try it but this was the first important step to generate sound.

The problem is that these motors can only turn in one direction. If they would be controllable into both directions, then the sound is much more louder and the propeller is not turning.
To prevent turing the motors I have to set a lower ratio (now it is divided with 20, @ 100 it is not turning).
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: [NEW FEATURE] Start-up Melody

Post by marcus »

That is really cool!! :D
danhamilt1
Beginner
Posts: 13
Joined: Wed Jul 17, 2013 1:59 pm

Re: [NEW FEATURE] Start-up Melody

Post by danhamilt1 »

Hi Surrender!

This code is awesome, as soon as I heard my flie make a tune I completely went against the idea of adding a speaker of some kind.

I have made it so that my crazyflie beeps at me when it is disconnected for more than a set time (though my code is a bit hacky).
I have used your melody stuff to do this.

I have implemented it within "commander,c", when the flie goes into self stabalisation, followed by 0 thrust. I have found that once the melody starts it struggles to reconnect when back in range, I am still getting to grips with how the code works and am pretty new to real time stuff. I am guessing that because the motors are spinning up, when it makes the connection the motors have to stop etc... and I assume this does not happen quick enough for the connection to be made, if you try and connect again after they are stopped it works fine.

How are you implementing it?

Code: Select all

if (ticktimeSinceUpdate > COMMANDER_WDT_TIMEOUT_SHUTDOWN)
  {
    targetVal[usedSide].thrust = 0;

    //Lost mode, only set if not charging and inactive
    if (isInactive){
    	if ((ticktimeSinceUpdate > COMMANDER_WDT_TIMEOUT_CRYOUT) && !pmGetChargingState()){
    		playMelody(lost);
      	}
    }

    isInactive = TRUE;

  }
Surrender
Expert
Posts: 100
Joined: Tue May 14, 2013 8:31 pm
Location: Austria

Re: [NEW FEATURE] Start-up Melody

Post by Surrender »

Hello danhamilt1,

Thanks! It is saving much weight ;)

I also don't know that much about the whole firmware code, just parts of it.

When you play the melody, the motor are spinning up, this is to get more amplitude of the sound.
As of my post before, just decrease the value: ratio value in the motors.c to e.g. 100.

I did not implement it on the disconnect yet. No time ... :?
danhamilt1
Beginner
Posts: 13
Joined: Wed Jul 17, 2013 1:59 pm

Re: [NEW FEATURE] Start-up Melody

Post by danhamilt1 »

Yes I agree! Not worth adding weight! I guess the only thing with the motors is the amplitude isn't that high. I changed the ratio to lower to see what happened and the crazyflie took off on its own (woops), that is the fun with playing around with this stuff! :lol:

Here is the download of my implementation of "lost mode" it sort of works but is very hacky. Issues with trying to reconnect etc etc... This is the first open source stuff I have done so I am prepared for my coding standards/methods to get hammered upon.

:arrow: https://bitbucket.org/danhamilt1/crazyf ... /downloads
Surrender
Expert
Posts: 100
Joined: Tue May 14, 2013 8:31 pm
Location: Austria

Re: [NEW FEATURE] Start-up Melody

Post by Surrender »

Yes i know, it is not that loud, but better than nothing and if you are not far away you can hear it. ;D

Oh, i forget to note this that changing ratio can be dangerous ;D
The cf has hit my nose and then the floor very hard after setting to high ratio (the smaller the divider, the higher the ratio :D

I have also to fix small things and then this code is in the main repo ;)


Sent from my GT-I9100 using Tapatalk 4 Beta
Daniel
Beginner
Posts: 11
Joined: Tue Apr 30, 2013 9:38 am

Re: [NEW FEATURE] Start-up Melody

Post by Daniel »

Thank you for this cool feature ... could you explain me how this motor_beep fuction works? especially how it works physically would be really nice.

Tank you =)

Greets

Daniel
Post Reply