MultiWii with Lights

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
mgros
Posts: 90
Joined: Thu Jan 20, 2011 12:32 am

MultiWii with Lights

Post by mgros »

I have adadpted a code that y saw in Megapirate to have different pattern Lights related with flight mode or battery alarm inside MultiWii.
Tested in MultiWii 1.8Patch2

You can see here the effect (only one pattern light) http://www.youtube.com/watch?v=JsjTqMQUfg8

I know that is possible to optimize and integrate the code into MultiWii but I have prepared a version with minimums modifications to MultiWii code.
It’s only necessary add the LED.pde file to the directory where you have the multiwii code and do 4 small changes in MultiWii_1_8_patch2.pde file

Change 1 before:

Code: Select all

static float    EstVelocity = 0.0f;
static float    EstAlt = 0.0f;

//for log
static uint16_t cycleTimeMax = 0;       // highest ever cycle timen
static uint16_t cycleTimeMin = 65535;   // lowest ever cycle timen

Change 1 after:

Code: Select all

static float    EstVelocity = 0.0f;
static float    EstAlt = 0.0f;
static uint8_t buzzerFreq; // LED

//for log
static uint16_t cycleTimeMax = 0;       // highest ever cycle timen
static uint16_t cycleTimeMin = 65535;   // lowest ever cycle timen

Change 2 before:

Code: Select all

  static uint8_t  buzzerState = 0;
  static uint32_t vbatRaw = 0;       //used for smoothing voltage reading
  static uint8_t buzzerFreq;         //delay between buzzer ring
  uint8_t axis;
  uint8_t prop1,prop2;

Change 2 after:

Code: Select all

  static uint8_t  buzzerState = 0;
  static uint32_t vbatRaw = 0;       //used for smoothing voltage reading
//  static uint8_t buzzerFreq;         //delay between buzzer ring  //LED
  uint8_t axis;
  uint8_t prop1,prop2;

Change 3 before:

Code: Select all

  #if defined(POWERMETER)
    for(uint8_t i=0;i<=PMOTOR_SUM;i++)
      pMeter[i]=0;
  #endif
}

// ******** Main Loop *********
void loop () {

Change 3 after:

Code: Select all

  #if defined(POWERMETER)
    for(uint8_t i=0;i<=PMOTOR_SUM;i++)
      pMeter[i]=0;
  #endif
  sq_led_init(); //LED 
}

// ******** Main Loop *********
void loop () {

Change 4 before:

Code: Select all

  if (currentTime > (rcTime + 20000) ) { // 50Hz
    rcTime = currentTime;
    computeRC();
    // Failsafe routine - added by MIS
    #if defined(FAILSAFE)

Change 4 after:

Code: Select all

  if (currentTime > (rcTime + 20000) ) { // 50Hz
    rcTime = currentTime;
    sq_led_heartbeat(); //LED
    computeRC();
    // Failsafe routine - added by MIS
    #if defined(FAILSAFE)


I will add both files (LED.pde and MultiWii_1_8_patch2.pde)

There are 5 different LED sequences:
• ACRO
• STABLE
• BATTERY ALARM 1
• BATTERY ALARM 2
• BATTERY ALARM 3
Once a battery alarm start can’t be used Acro and stable patterns. You can see some small erratic modes given that the transitions between battery levels have some hysteresis (rapid changes between levels in the limit)

The patterns can be defined in LED.pde file (see comments inside the file)

Connection diagram
You can use any available PIN that it’s not used by MultiWii
In Flyduino you can use A1, A2, A3 (A4, A5 it’s not possible to use see ATMega 1280, 2560 documentation, page 89 (Idont know how disable JTAG) 4, 9, 10, 11.
In Mega or Seeduino Mega you can use lots of PINs.

You can connect directly a LED (limit the current to 15mA) or use a ULN2803A to draw more Amp.
Pin usage definition in LED.pde.

Let me know if you need any help please
Attachments
LED.zip
(7.83 KiB) Downloaded 156 times

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: MultiWii with Lights

Post by Alexinparis »

Hi Mariano,

Interesting !
In the same idea, I recently ordered this device:
http://www.dfrobot.com/index.php?route= ... uct_id=487

I expect it to be useful for indicating status things trough the I2C bus : inclination / north direction / battery / sensors activation / LED effects ...
So, there will probably be a LED.pde file soon :)

User avatar
mgros
Posts: 90
Joined: Thu Jan 20, 2011 12:32 am

Re: MultiWii with Lights

Post by mgros »

Alexinparis wrote:In the same idea, I recently ordered this device:
http://www.dfrobot.com/index.php?route= ... uct_id=487


Realy interesting device!! ;)

rcflyrodeo
Posts: 18
Joined: Sun Jul 31, 2011 12:34 pm

Re: MultiWii with Lights

Post by rcflyrodeo »

This one is a similar interesting light controller used by some microcopters (page is only in german)

http://www.mikrokopter.de/ucwiki/LEDStr ... 28-*%29%28\r%29%3F\n%29%28.*%29KategorieBeleuchtung%29

Post Reply