LedFlasher used for LowBatt indication

Post Reply
fjulian79
Posts: 4
Joined: Wed Jan 22, 2014 8:35 pm

LedFlasher used for LowBatt indication

Post by fjulian79 »

Hello !!

I have just created a account in this forum because i have created a new light wight feature ...

I have build a medium size Quadcopter with 4 HobbyKing High Power Led's used as Navigation Lights (one red led on each front arm, one green led on each rear arm). I operate them by using a small led driver with a control input. This input is driven by D7 which i have configured as LEDFLASHER output pin. I want to use the LOWBATT indication but I was not happy with the beeper used for low battery alarms as i can't hear it when airborne. Another led as pilot lamp? .. noooo .. i have already leds which can be controlled by the MultiWii so I want to use them.

So I have created a patch which attaches to the low battery alarm and sets the led flasher sequence .. but see your self:

Code: Select all

Index: src/MultiWii/Alarms.cpp
===================================================================
--- src/MultiWii/Alarms.cpp   (revision 1648)
+++ src/MultiWii/Alarms.cpp   (working copy)
@@ -541,6 +541,30 @@
     }
     #endif
 
+   #if defined(LED_FLASHER_SEQUENCE_LOWBAT1)
+   /* do we have a special led sequence for battery alarm 1 ? */
+   if (alarmArray[6] == 1) {
+     led_flasher_set_sequence(LED_FLASHER_SEQUENCE_LOWBAT1);
+     return;
+   }
+   #endif
+
+   #if defined(LED_FLASHER_SEQUENCE_LOWBAT2)
+   /* do we have a special led sequence for battery alarm 2 ? */
+   if (alarmArray[6] == 2) {
+     led_flasher_set_sequence(LED_FLASHER_SEQUENCE_LOWBAT2);
+     return;
+   }
+   #endif
+
+   #if defined(LED_FLASHER_SEQUENCE_BATCRIT)
+   /* do we have a special led sequence for critical battery voltage ? */
+   if (alarmArray[6] == 4) {
+     led_flasher_set_sequence(LED_FLASHER_SEQUENCE_BATCRIT);
+     return;
+   }
+   #endif
+
     #if defined(LED_FLASHER_SEQUENCE_ARMED)
     /* do we have a special sequence for armed copters? */
     if (f.ARMED) {
Index: src/MultiWii/config.h
===================================================================
--- src/MultiWii/config.h   (revision 1648)
+++ src/MultiWii/config.h   (working copy)
@@ -581,15 +581,18 @@
     //#define LED_RING
 
   /********************************    LED FLASHER    ***********************************/
-    //#define LED_FLASHER
-    //#define LED_FLASHER_DDR DDRB
-    //#define LED_FLASHER_PORT PORTB
-    //#define LED_FLASHER_BIT PORTB4
+    #define LED_FLASHER
+    #define LED_FLASHER_DDR DDRD
+    #define LED_FLASHER_PORT PORTD
+    #define LED_FLASHER_BIT PORTD7
     //#define LED_FLASHER_INVERT
-    //#define LED_FLASHER_SEQUENCE        0b00000000      // leds OFF
-    //#define LED_FLASHER_SEQUENCE_ARMED  0b00000101      // create double flashes
-    //#define LED_FLASHER_SEQUENCE_MAX    0b11111111      // full illumination
-    //#define LED_FLASHER_SEQUENCE_LOW    0b00000000      // no illumination
+    #define LED_FLASHER_SEQUENCE          0b00000000     // leds OFF
+    #define LED_FLASHER_SEQUENCE_ARMED    0b00000101     // create double flashes
+    #define LED_FLASHER_SEQUENCE_LOWBAT1  0b01100110     // used for low bat threshold 1
+    #define LED_FLASHER_SEQUENCE_LOWBAT2  0b01010101     // used for low bat threshold 2
+    #define LED_FLASHER_SEQUENCE_BATCRIT  0b00000000     // used for critical battery voltage
+    #define LED_FLASHER_SEQUENCE_MAX      0b11111111     // full illumination
+    #define LED_FLASHER_SEQUENCE_LOW      0b00000000     // no illumination
 
 
   /*******************************    Landing lights    *********************************/


So the user has to configure the low battery thresholds as usual, and when the led flasher is used the LED_FLASHER_SEQUENCE_LOWBAT1, LED_FLASHER_SEQUENCE_LOWBAT2 and/or LED_FLASHER_SEQUENCE_BATCRIT can be used to signalize the alarm.

I think this is a very light wight feature which will help a lot of pilots out there by adding a very practical method of low battery indication :-D

I will upload a video to youtube to demonstrate the feature and post the link here.

Hope you like it, br
Julian F.
Last edited by fjulian79 on Wed Jan 22, 2014 10:21 pm, edited 1 time in total.

fjulian79
Posts: 4
Joined: Wed Jan 22, 2014 8:35 pm

Re: LedFlasher used for LowBatt indication

Post by fjulian79 »


User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: LedFlasher used for LowBatt indication

Post by Hamburger »

In which way is this superior to attaching leds to the buzzer output?

fjulian79
Posts: 4
Joined: Wed Jan 22, 2014 8:35 pm

Re: LedFlasher used for LowBatt indication

Post by fjulian79 »

Good point *ggg* ...

# But i don't want my nav leds to beep! And is even possible to let the buzzer beep in the way my leds flash when the copter is armed? .. if so I habe not seen so far how this has to be enabled/configured.
If this is not possible you need some hardware (dependant on the way your led driver control input works) to combine the buzzer pin and the led flasher pin when controlling the led driver. .. and the buzzer pin has to overrule the led flasher pin as the low bat alarm signal has to have priority. I think this more effort then this code change as is based on allready existing code.

# When I'm hovering next to me i can clearly her the buzzer when changing the flight mode, I dont know if this would be the case the buzzer is beeping periodically all the time.

# It is possible to define your own flash patterns just by editting config.h ... which is imho pretty cool

br J.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: LedFlasher used for LowBatt indication

Post by Hamburger »

so you want your nav lights to not beep but flash for low.voltage? Not sure if we play tricks with words here -
Sorry, I am not convinced, does not sound like a general purpose issue to me. I'd rather transfer the idea to generalize the 'buzzer' signaling to support multiple outputs.

fjulian79
Posts: 4
Joined: Wed Jan 22, 2014 8:35 pm

Re: LedFlasher used for LowBatt indication

Post by fjulian79 »

@ "so you want your nav lights to not beep but flash for low voltage"
.. yes .. i want the led flasher pin be capable of signalling low batt alarms ..

@ "Not sure if we play tricks with words here"
.. no as the buzzer and the led flasher outputs have no "common" beahvior, ore are equivalent in any way ;-)

@ "generalize the 'buzzer' signaling to support multiple outputs."
.. can you explain this more into detail?

br J.

argotera
Posts: 17
Joined: Sun Oct 20, 2013 1:40 pm
Location: Athens, Greece

Re: LedFlasher used for LowBatt indication

Post by argotera »

Thank you Julian,

Very nice feature.

deejayspinz
Posts: 23
Joined: Thu Feb 20, 2014 12:01 pm

Re: LedFlasher used for LowBatt indication

Post by deejayspinz »

Exactly what I need. Thx Julian!

regzgz
Posts: 23
Joined: Mon Mar 10, 2014 11:55 pm

LedFlasher used for LowBatt indication

Post by regzgz »

A video on how to add this to the code will be a welcome for us new to the quad world!

Looks like something I need now!
Great work Julian!

bejo52
Posts: 11
Joined: Mon Feb 18, 2013 3:01 pm
Location: Germany, Berlin

Re: LedFlasher used for LowBatt indication

Post by bejo52 »

I just discovered this nice feature and like to implement it at my Crius AIOP.
Therefor I have to overwrite the used pin and there begins my problem. I am not sure if I have to change OVERRIDE_LEDPIN... in config.h or LED_FLASHER_PORT.
I tried both. In the first case the leds show me the copter status like arm, acc calibration etc. but no battery alarm. In the second case I get the battery alarm but no
copter status. I guess the LEDPIN is used for a physically different led. Am I right? What is it used for? How can I link all alarms to the ledflasher?

bejo52
Posts: 11
Joined: Mon Feb 18, 2013 3:01 pm
Location: Germany, Berlin

Re: LedFlasher used for LowBatt indication

Post by bejo52 »

I got it.
Don't care about the LEDPIN. Just configure the LED_FLASHER_PORT...
I use
#define LED_FLASHER_DDR DDRF
#define LED_FLASHER_PORT PORTF
#define LED_FLASHER_BIT PORTF4
on the Crius AIOP for the analog port A4. Leave the //#define LED_FLASHER_INVERT commented
Now the LEDs switch on when arming and flash while battery alarm is on.
Thanks at Julian

covert
Posts: 3
Joined: Thu Jun 19, 2014 1:17 pm

Re: LedFlasher used for LowBatt indication

Post by covert »

What LED driver are you using ?

bejo52
Posts: 11
Joined: Mon Feb 18, 2013 3:01 pm
Location: Germany, Berlin

Re: LedFlasher used for LowBatt indication

Post by bejo52 »

What do you mean with LED driver?
Software you don't need to care about, just configure your port. For the connection of LEDs I use the same circuit as for the buzzer (LED in stead of buzzer, you can find in the net)

Post Reply