3689486770?profile=original

 

I am using the APM 2 for both my quads and it is tricky to get the barometer covered to avoid errant airflow since it is below the daughterboard. To solve this, I ended up pretty much filling up my stack cover with breathable foam. But once that was done, I could barely see the on-board LED indicators.

Fortunately, the current code supports remote indicators without too much trouble.

If you look at the pin-out images on the Wiki, you will see that the AN pins are labeled Motor LEDs. They really don’t have a lot to do with the motors – but they do serve as pretty handy indicators.

3689486868?profile=original

If you look in the code, you will find defines for these pins as follows:

AN4 – Motor or Aux LED

AN5 – Motor or Beeper

AN6 – Motor or GPS

AN7 – Motor

AN8 – Motor

For my purposes, I focused on AN5 for the Beeper, AN6 for GPS indicator and AN7 as an Armed indicator.

The default seems to be to have the beeper enabled and the LEDs on. That is easy to change however. The different possibilities are set using bit masks to build the LED_mode parameter. A bit mask (if you already know, feel free to skip ahead) is simply a way of packing a bunch of on/off settings into one byte of data. A Byte is 8 bits, so you can have 8 different switches in one byte.  If you look at the following table, you will see a single bit is set to ‘1’ and the rest to ‘0’ in each row. To build the mask, you just add all the rows together and convert to a decimal number (or convert then add).

Bit Number

7              6              5              4              3              2              1              0

0              0              0              0              0              0              0              1      =      1              Motor LEDs On/Off

0              0              0              0              0              0              1              0      =      2              GPS On/Off

0              0              0              0              0              1              0              0      =      4              AUX Function On/Off

0              0              0              0              1              0              0              0      =      8              Beeper On/Off

0              0              0              1              0              0              0              0      =      16            Low Battery Flash – fast/slow

0              0              1              0              0              0              0              0      =      32            Motor LEDs NAV blink On/Off

0              1              0              0              0              0              0              0      =      64            GPS LEDs Nav Blink On/Off

1              0              0              0              0              0              0              0      =      128          Not used

 

Note that the NAV settings cause the LEDs (either the motor LEDs, the GPS LED, or both) to blink 3 times when you hit a waypoint in AUTO flight.

The low battery flashing defaults to fast flash so setting that bit to 1 will enable slow flash. 

 

I really only want the beeper, the GPS and the Motor LEDs on, so I set the mode to decimal value 11 (which is binary 00001011). This should equate to: GPS Nav blink off, Motor LED Nav blink off, low battery flash fast, beeper on, AUX off, GPS on, Motor LEDs on..

 

The way you set this to be the value used is through the Mission Planner.

 

Establish a connection with the APM and the Mission Planner software. Go to the parameters list and find LED_Mode. It should be set to something like 9. Change that to 170 (or whatever you decide to use) and write the settings to the APM.


The outputs on the APM are 5V, so for most LEDs, you’ll need a resistor on the positive lead (the longer leg of the LED). In my case, the blue LED I was using required a 100 Ohm resistor and the red one required a 150 Ohm resistor (note – not going to explain it here, but there are a ton of online resources and calculators to figure out the resistor values needed for a given LED). I soldered up the resistors and LEDs to leads and cemented them at the edge of my stack cover’s base. For the beeper, I just used a 5V piezo beeper I happened to have lying around. Radio shack sells one that will work, but it isn’t very loud. If you want volume, you may need to shop around,

 

When you connect to the AN outputs, you need to run the negative lead to the ground pin (the one nearest the edge of the board) and the positive lead goes to the signal pin (the one farthest from the edge of the board). The middle pin is always 5 Volts so if you plugged in there, the LED or beeper would be always on.

 

Beeper goes to AN5, GPS to AN6 and the ARMED light goes to any other motor LED output, but I chose to just use AN7.

 

That’s all there is to it. When you turn on the APM, you the LEDs will stay off until it is booted, then will flash the same as the on-board ones. When a GPS lock is achieved, the GPS LED will stay lit. When the bird is armed, the red LED will blink out and once it is fully armed, it will light a solid red. The beeper will beep twice on arming, and once on disarm.

 

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • What is happened in AC 3.1 with the AN5 output. It´s driving me crazy to get it working, but I am out of luck I suppose. In ac 3.0.1 I had a buzzer on the AN5 and it was beeping on arming, and then later continuous beep on low battery until disarmed. Very well. But since the update to AC 3.1 it is still beeping on arming like before but not on low battery anymore. I tried several things, in mission planner is the correct voltage displayed. It is still not beeping on low voltage and I have a feeling that I am overlooking something. Does anybody has an advice or solution for this ? 

  • seems that it doesn't work anymore in latest firmware... :(

  • does this work on apm:plane? or just for arducopter

  • What configuration or code needs to be change to disable the Buzzer when connecting to the APM only through USB?

  • I just installed per instructions in the First Post. Works Great!

    For many who keep asking the same question about function - Read THE First Post - Again And Again.

    The functions can be: GPS: Not Locked, Blue LED: Blinking; GPS: Locked, Blue LED: Solid; Motors: Disarmed, Red LED: Blinking; Motors: Armed, Red LED: Solid; Motors: Disarming, Beeper: One Beep; Motors: Arming, Beeper: Two Beeps pause Two Beeps. This is with the bitmask setting in MP of: 11. I am using APM 2.5 running firmware version 3.0.1.  This was plug-and-play.

    Note:  If you are getting a faster Red LED Blinking upon Arming you are not passing the internal safety check. You have your motors disconnected? Or have configured some other hardware feature and it is not connected or it is disabled? I had the fast blinking Red when I was rebuilding. I found that I was initiating the Arm without my ESC & Motor hooked up - Then later my Volt & Amp meter was disconnected but, was configured in the MP. So, check your systems. Be Safe too!

  • When Randy gets done figuring out which IO lines are available for which functions I will include this on a Wiki LED page suitably modified.

    This is really a placeholder so I can find it.

  • Does anyone have a link to a specific part for an inexpensive and small piezo buzzer? When I was purchasing some other parts I threw http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001... into my cart because I thought it would work. this product DOES NOT PLUG AND PLAY for my application because it needs a driver circuit. Instead of building something that generates a compatible square wave, I'd much rather just find a similar sized part that generates a tone.

  • Moderator

    @ William C Bonner

    I use the number 11 (8+2+1) which gives me what you want except the buzzer is continuous not beeping (v3.0.1 and v3.1rc5). I haven't figured how to make the buzzer "blink". (A5 = buzzer, A6 = LEDgreen, A7 = LEDred)

  • Well, I'm trying to understand the code and maybe learn how to edit it...

    I have modified the last param that says ''//if motors are not armed, blink motor leds''   I have changed to ''copter_leds_off();''

    So I think that when the copter is not armed no the output motor leds will not flash... Is it right?

    static void update_copter_leds(void)

    {
    if (g.copter_leds_mode == 0) {
    copter_leds_reset(); //method of reintializing LED state
    }

    // motor leds control
    if (g.copter_leds_mode & COPTER_LEDS_BITMASK_ENABLED) {
    if (motors.armed()) {
    if (ap.low_battery) {
    if (g.copter_leds_mode & COPTER_LEDS_BITMASK_BATT_OSCILLATE) {
    copter_leds_oscillate(); //if motors are armed, but battery level is low, motor leds fast blink
    } else {
    copter_leds_fast_blink(); //if motors are armed, but battery level is low, motor leds oscillate
    }
    } else {
    if (g.copter_leds_mode & COPTER_LEDS_BITMASK_MOTOR_NAV_BLINK) {
    if (copter_leds_nav_blink > 0) {
    copter_leds_slow_blink(); //if nav command was seen, blink LEDs.
    } else {
    copter_leds_on();
    }
    } else {
    copter_leds_on(); //if motors are armed, battery level OK, all motor leds ON
    }
    }
    } else {
    copter_leds_off(); //if motors are not armed, blink motor leds
    }
    }

    If it is right, now I have some questions... 

    - How could I make the HEX file to upload to the APM... I have tried and always the same error

    Building for ArduPilot Mega 2.x

    Excluding arduino core from include paths

    - When I upload the HEX file... could I config all the params with mission planner as always?

    Thank you very much !

  • -------------------------------------
    Comment by Tom McCullough on September 7, 2013 at 6:53pm

    What should the default behavior be if the bitmask is set to 3? Right now i have blinking blue on no GPS fix, and solid on fix which is great. However the red LED blinks slow on disarm and faster on arm. Is it still necessary to edit the "leds" source code to get red off (or blinking) on disarm and red solid on arm?

    -------------------------------------------

    I am having the same behavior. Slow blink when disarmed and fast when armed. Sometimes it goes solid when I try to arm. Can anyone advise where to edit these flashes etc?

    Thanks

This reply was deleted.