This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

INSTASPIN-FOC: How to make the motor "beep"?

Other Parts Discussed in Thread: LAUNCHXL-F28027F, BOOSTXL-DRV8301, MOTORWARE

Hello -

First of all I just want to say that I love INSTASPIN-FOC and the TI support community!

I am currently designing my own hardware, but am using a LAUNCHXL-F28027F/BOOSTXL-DRV8301 for now.

Most hobby-grade BLDC motor controllers have the ability to make audible sounds by sending harmonics to the motor. I am looking to accomplish this using Motorware/INSTASPIN.

Are there any examples of this? If not, please take this as my formal request for such an example :-) I am sure that I'm not the only one who desires this functionality.

-asifjahmed

  • Hello Asifjahmed,

    Thank you for using InstaSPIN.  I'm glad to hear that it is working well for you.

    Actually, I just recently bought a drone, and I think they do the same thing you are talking about to make their beeps.  To make the beeps come through the motor, I don't think there is any advantage to injecting the signal into the synchronous frame.  I would do it right at the PWM level.  At the end of the mainISR() function is where the PWM values get written as a structure "gPwmData.Tabc.value[ ]".  If you are just interested in a "beep", you could do that with a squarewave fairly easily.  I would set up a decimation counter in the mainISR() which just counts ISR ticks and alternates between writing two PWM values centered around 50% every time the counter hits its limit.  The decimation count limit determines the period of the beep waveform.  The difference between the two PWM values that you write determines the loudness of the beep.

    This is something we will consider for future MotorWare releases.  But considering how easy it should be to do this, I wouldn't wait for us to get it through the approval process.  I suggest that you just do it yourself.

    Best Wishes for 2016,

    Dave

     

  • Thanks Dave!! Your videos are what got me started in the first place :-)

    OK - thanks for the guidance there. I've had some luck with the following code:

    in the globals section:

    uint16_t beepCnt = 0;
    uint16_t beepCntLimit = 5000;
    bool beepAlt = false;
    float beepOffset = 10.0;

    and then in mainISR:

      if (beepCnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / beepCntLimit))
      {
    	  if (beepAlt)
    	  {
    		  gPwmData.Tabc.value[0] = _IQ(50.0 + beepOffset);
    		  // gPwmData.Tabc.value[1] = _IQ(50.0 + beepOffset);
    		  // gPwmData.Tabc.value[2] = _IQ(50.0 + beepOffset);
    	  }
    	  else
    	  {
    		  gPwmData.Tabc.value[0] = _IQ(50.0 - beepOffset);
    		  // gPwmData.Tabc.value[1] = _IQ(50.0 - beepOffset);
    		  // gPwmData.Tabc.value[2] = _IQ(50.0 - beepOffset);
    	  }
    
    	  beepAlt = !beepAlt;
    	  beepCnt = 0;
      }

    I do in fact get a beep coming from the motor. However, changing the "beepOffset" value has no effect unless I set it to 50.0, and then the beep tone is still present but much less prominent. Also, varying the interval ("beepCnt") does change the tone of the beep, but i can only get 3 or 4 distinct tones out of it. All in all, I feel like I'm missing something in order to get it working properly.

    Oh, and I tried sending the PWM to 1, 2, and 3 PWM channels. Still do not get the desired behavior.

    Any help is appreciated!

    -asifjahmed

  • Isn't the gPwmData.Tabc.value is limited to _IQ(-1.0)/0% duty cycle to _IQ(1.0)/100% duty range? Centered at _IQ(0.0)/50% duty cycle.
  • Here are my findings:
    You have to control the other 2 phases as well to make the beep louder. Essentially same as Rs detection, the current I(U) flowing into phase U need to go somewhere, which are I(V) and I(W), where I(V) = I(W) = 0.5 * I(U).

    Try this:

    _iq beepOffset=_IQ(0.1); //up to _IQ(1.0)

    in mainisr():

    if (beepAlt)
    {
    gPwmData.Tabc.value[0] = beepOffset;
    gPwmData.Tabc.value[1] = -_IQdiv(beepOffset,_IQ(2));
    gPwmData.Tabc.value[2] = -_IQdiv(beepOffset,_IQ(2));
    }
    else
    {
    gPwmData.Tabc.value[0] = -beepOffset;
    gPwmData.Tabc.value[1] = _IQdiv(beepOffset,_IQ(2));
    gPwmData.Tabc.value[2] = _IQdiv(beepOffset,_IQ(2));
    }
  • Thanks Soon, ...good point. I failed to mention that you need to generate differential duty-cycles between the phases to enable current flow in the motor.
  • Thanks Dave and Soon! I now have this working quite well! Now to write a library to play little "tunes" on the motor to indicate its current state!

    -asifjahmed
  • Has anyone made a library for this or have any recent findings on this topic? I'm just getting started with adding this functionality and looking for a better starting point if you're willing to share code.

    It'd be awesome to have a function where you'd specify a string of notes on a 4/4 music time scale.. and then have a scalar to change the tempo of the entire thing. I suppose the tuning would be somewhat motor specific, so some calibration would be necessary, but very little.