MultiWii 2.4 - VBAT Alarms

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
dialfonzo
Posts: 62
Joined: Sun Nov 20, 2011 3:18 pm
Location: Quebec, Canada

MultiWii 2.4 - VBAT Alarms

Post by dialfonzo »

Hi All,

I was doing a complete testing in order to make a tutorial around the VBAT and BUZZER on MultiWii and i found an issue.
When the triggers are set for the different Levels, the "Critical" don't seems to do anything.

What i found so far (and i'm not a programmer). In the Alarms.cpp there is that block of code:

Code: Select all

  #if defined(VBAT)
    if (vbatMin < conf.vbatlevel_crit) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_CRIT;
    else if ( (analog.vbat > conf.vbatlevel_warn1)  || (NO_VBAT > analog.vbat)) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_OFF;
    else if (analog.vbat > conf.vbatlevel_warn2) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_INFO;
    else if (analog.vbat > conf.vbatlevel_crit) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_WARN;
    //else alarmArray[6] = 4;
  #endif


Seems like the vbatMin is never achieved there and if i changed it for this, i start to get the "Critical" beeps:

Code: Select all

  #if defined(VBAT)
    if (analog.vbat < conf.vbatlevel_crit) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_CRIT;
    else if ( (analog.vbat > conf.vbatlevel_warn1)  || (NO_VBAT > analog.vbat)) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_OFF;
    else if (analog.vbat > conf.vbatlevel_warn2) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_INFO;
    else if (analog.vbat > conf.vbatlevel_crit) alarmArray[ALRM_FAC_VBAT] = ALRM_LVL_VBAT_WARN;
  #endif


Does my change make sense ? Is there a reason why it use the "vbatMin" instead ?
Am i the only one with this problem (lol) ?

Also, that's a choice but the three fast beeps with a 2 second of wait seems not enough for me so i changed this like of code too:

Code: Select all

      else if ( IS_ALARM_SET(ALRM_FAC_VBAT , ALRM_LVL_VBAT_CRIT) ) patternDecode(resource,500,0,0,50,50);      //vbat critical


Note: Here is my Blog tutorial
http://www.robotshop.com/blog/en/lynxmotion-quadrino-nano-battery-monitoring-alarms-16207

Eric Nantel - DiaLFonZo

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: MultiWii 2.4 - VBAT Alarms

Post by QuadBow »

Hi dialfonzo,

you asked
dialfonzo wrote:Does my change make sense ? Is there a reason why it use the "vbatMin" instead ?
Am i the only one with this problem (lol) ?


Since vbatMin has been set earlier to analog.vbat in

Code: Select all

    #if defined(VBAT)
      if ( (analog.vbat > NO_VBAT) && (analog.vbat < vbatMin) ) vbatMin = analog.vbat;
    #endif
you have not changed much. So, there is no problem. But, I agree with you that the code could be more readable at this stage.

User avatar
dialfonzo
Posts: 62
Joined: Sun Nov 20, 2011 3:18 pm
Location: Quebec, Canada

Re: MultiWii 2.4 - VBAT Alarms

Post by dialfonzo »

Thanks, just not sure why it was set to "vbatMin" instead of "analog.vbat" like the other levels.
Is that a mistake or there was an intended purpose for it..?

:)

User avatar
dialfonzo
Posts: 62
Joined: Sun Nov 20, 2011 3:18 pm
Location: Quebec, Canada

Re: MultiWii 2.4 - VBAT Alarms

Post by dialfonzo »

After more investigation, it turn out that only the buzzer pattern was to be changed.
Now it work just fine.. ;)

Post Reply