Hi,
I found this nice blog post, how to run LEDs with the relay switch. I modified the software to work with AC 2.1 firmware. And I added functionality that you can set the limits for the low battery warning with mavlink parameters.
Overview what this software modification does and what hardware modifications you have to do:
- You need to add some LEDs or LED-Stripes in a way, that you can controll them with the relay switch on the IMU (blue PCB).
- You need a proper hardware setup to measure the voltage of the whole battery.
- If you arm the copter, the LEDs will turn ON.
- If you disarm they turn OFF.
- If you are flying (LEDs ON) and battery voltage drops under a certain level, they will start to flash slowly.
- If battery voltage drops under another level, they will start to flash fast. Go landing!
- The voltage levels can be adjusted via mavlink parameters, so you can tune them on the field and you don't have to compile again if you want to change them.
Now how it´s done:
First a WARNING: You use this modification at your own risk! On my tri, it works. Please leave a comment if it works also on your copter. I'm starting from ArduCopter code 2.1.
1 Add LEDs
If you using 3S Lipo, you can directly connect 12V LED stripes widely aviable. They consume ca. 600 mA per meter. The relay called AXICOM IM03 can switch 2A. In this blog post, its already explained how you can add the LEDs and voltage measurement to your hardware setup. But don't make mistakes, it can damage your board or even your battery. I did not modified my IMU PCB, I directly connected the LEDs to the 12V Battery and inserted the relay as switch in between.
2 Add voltage measurement
Here is a discription how to measure battery voltage.
3 Changing the code
Download this file: RunningLights.pde and put it in the ArduCopter directory.
Add the following to your "APM_Config.h" file and modify it to your needs:
#define BATT_WARNING_RELAY 1 // 1: Relay Switch controls LEDs an generates low battery warning. 0: no changes.
#if (BATT_WARNING_RELAY == 1)
# define BATTERY_EVENT ENABLED
# define LOW_VOLTAGE 9.8 // default values, editable via mavlink
# define LOW_VOLTAGE_PRE 10.5
# define VOLT_DIV_RATIO 3.27 // take care of this, it depends on your resistors
# define MOTOR_LEDS 0 // Do not use build in LED function
// The following two global variable definitions need to be added to the "Arducopter.h" file
int rl_state = 0 ; // this global variable is used to save the on/off state of the relay
int rl_counter = 0 ; // this global variable is used for the flash rate timer
#endif // (BATT_WARNING_RELAY == 1)
In file "ArduCopter.pde" in function "static void medium_loop()" modify (add 4 lines):
if (g.battery_monitoring != 0){
read_battery();
// Mod for Low.Batt.Warning with LEDs on Relay // ( add 4 lines from here)
#if (BATT_WARNING_RELAY == 1)
handle_relay_lights();
#endif
}
In file "Parameters.h" section public:
Increase the number after "static const uint16_t k_format_version" by one. Warning: This will make the APM erase your EEPROM and Log after flashing the new compiled firmware. So save your settings first! After this, you have to reload your settings and level the copter again.
On the following 3 blocks, look for the first line and add the second line:
k_param_super_simple, // search for this line
k_param_low_voltage_pre, // add this line below it
AP_Int8 super_simple;
AP_Float low_voltage_pre;
super_simple (SUPER_SIMPLE, k_param_super_simple, PSTR("SUPER_SIMPLE")),
low_voltage_pre (LOW_VOLTAGE_PRE, k_param_low_voltage_pre, PSTR("LOW_VOLT_PRE")),
Now, you can compile and flash. Connect with mission planer, go to settings and klick refresh parameters. You will see in the list on the left side LOW_VOLTAGE_PRE and LOW_VOLTAGE. The first is the treshold for slow flashing, the second for fast flashing.
Things to mention:
I hacked this HowTo together from several commits on my local git repository. I hope everything needed for this change is mentioned here. If it works for you, please write a comment! And use this at your own risk, you should know what you are doing if you modify hardware and software.
U4eake has also improved his original version! You can find it here !
Have fun!
Igor Van Airde
Comments
Igor, this is great stuff--congrats! Would you like to join the dev team to help incorporate them? If so, please PM me an email address linked to a Google account, and I'll add you to the dev list so you can get a sense of how the team works.