[Solved] Communication with multiwii board with Pilotlamp

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
nicop4
Posts: 2
Joined: Fri Dec 05, 2014 11:10 pm

[Solved] Communication with multiwii board with Pilotlamp

Post by nicop4 »

Hello people of multiwii

I’m new to this forum, so a bit about me: I play with multicopters for not a very long time, hardly a couple of months… I started with a nice Hubsan X4, and since I built my own mini-quad based on a Hobbyking 328p MW board, and it flies quite nicely for now :)


So now I’m looking for a way to get information from the multiwii FC while in flight (essentially for now current flight mode, and alarms).
My goal is to feed a secondary custom arduino-based board with that to do lighting stuff and other things, depending on these data.

And I could use a little help form you…

I began by using buzzer output which was nice but not enough for my final purpose.
I though of different ways to get the data I need : using pilot lamp output or serial connection, ….

The pilot lamp would be nice, because we can have four « channels » of information (red, green and blue lights + buzzer) and set them as we want by configuring the alarms by flight mode. To use it, I basically recreated my own pilotlamp module to do want I want with the analyzed signals.

But I have trouble getting clear pilotlamp signals from my arduino board.


By analyzing multi code we have

Code: Select all

  #define    PL_GRN_ON    25    // 100us
  #define    PL_GRN_OFF   50    // 200us
  #define    PL_BLU_ON    75    // 300us
  #define    PL_BLU_OFF   100    // 400us
  #define    PL_RED_ON    125    // 500us
  #define    PL_RED_OFF   150    // 600us
  #define    PL_BZR_ON    175    // 700us
  #define    PL_BZR_OFF   200    // 800us


which is eventually used by the interrupt service routine of the pilot lamp in MultiWii.

This is where I’m getting lost : if I understand correctly, it will set the pilot lamp output to high for 300us to activate blue led, and for 400us to turn it off, am I correct on that?


If this is right, I didn’t manage to have a precise enough timing reading from my arduino board, my own implementation of pilot lamp receiver doesn’t work very well.
Basically, in my code I store microsecond value at each change in level of the multi pilot lamp output and calculate the time where the signal was HIGH.
My green channel seems OK, but not 100% accurate though, but blue and red are recognized~ish and I don’t have the buzzer.

I also tried a pre-compiled version of a pilot lamp on an ATTiny 85 (from here: http://fernitronix.fr/fr/multi-copters/les-gadgets-multiwii/module-pilot-lamp-buzzer-intelligent) but it wasn’t working well either…
So it might be my code, it might be my board, it might be my multiwii settings (because I changed the buzzer output to A2 and had to adapt some portion of MW code (there maybe a bug around this in multiwii btw - at least for my board))…. Hard to debug. :(
I don’t have an oscilloscope so I can’t check my signal reliably.

Do you have a correct or better way to read pilot lamp output ?


Well… I tried to keep my explanations and questions short and simple (I might have failed on that ^^), but if I’ve been clear enough, and you have feedback or ideas, please share and discuss :)
I still have a lot in mind about all this, but it was a bit too much for a first post :mrgreen:
Last edited by nicop4 on Sun Dec 07, 2014 6:37 pm, edited 1 time in total.

nicop4
Posts: 2
Joined: Fri Dec 05, 2014 11:10 pm

Re: Communication with multiwii board with Pilotlamp [solved

Post by nicop4 »

I managed to get my homemade pilotlamp to work.

But I had to to some modification in multiwii code because pilotlamp's buzzer was not correctly defined (the standard full buzzer signal (5V basically) was sent on the output port).

I had to add the folowing code in Alarms.cpp (toggleResource function, line 359):

Code: Select all

void toggleResource(uint8_t resource, uint8_t activate){
     switch(resource) {     
      //--nicop4--  modification to handle correctly buzzer in pilotlamp!
        #if defined (BUZZER)[color=#FF0000]  && !defined (PILOTLAMP)                      // -- nicop4 -- added  "&& !defined (PILOTLAMP)"
          case 1:
            if (activate == 1) {BUZZERPIN_ON;}
            else BUZZERPIN_OFF;
            break;
        #endif
        #if defined (PILOTLAMP)
         case 1:                                                        // -- nicop4 -- added  case 1
            if (activate == 1) PilotLamp(PL_BZR_ON);                    // -- nicop4 -- added  case 1
            else PilotLamp(PL_BZR_OFF);                                 // -- nicop4 -- added  case 1
            break;                                                      // -- nicop4 -- added  case 1
          case 2:
            if (activate == 1) PilotLamp(PL_GRN_ON);
            else PilotLamp(PL_GRN_OFF);
            break;
          case 3:
            if (activate == 1) PilotLamp(PL_BLU_ON);
            else PilotLamp(PL_BLU_OFF);
            break;
          case 4:
            if (activate == 1) PilotLamp(PL_RED_ON);
            else PilotLamp(PL_RED_OFF);
            break;
        #endif
        case 0:
        default:
          if (activate == 1) {LEDPIN_ON;}
          else LEDPIN_OFF;
          break;
      }
      return;
  }


Also, to be able to use other led than green for flight mode pattern definitions (if you do not have GPS you might want use the blue LED as well) you need to prevent them to systematically turning them off! That was messing around my tests...

Alarms.cpp around line 150

Code: Select all

      #if GPS
        if (alarmArray[2]==1) patternDecode(resource,100,100,100,100,100);                      // blue fast blink -->no gps fix
        else if (f.GPS_HOME_MODE || f.GPS_HOLD_MODE) patternDecode(resource,100,100,100,100,1000); //blue slow blink --> gps active
        else setTiming(resource,100,1000);                                                        //blue short blink -->gps fix ok
      #else
        //turnOff(resource);                    // --- nicop4 --- to use blue LED without GPS, do not turn it off
      #endif   
      resource = 4;
      if (alarmArray[1] == 1)       setTiming(resource,100,100);                                  //Red fast blink--> failsafe panic
      else if (alarmArray[1] == 2)  patternDecode(resource,1000,0,0,0,2000);                    //red slow blink--> failsafe find me
      //else turnOff(resource);             // --- nicop4 --- to use red LED, do not turn it off - be careful, it might stay on after an alarm!!


If it can help somebody, and if it can be used for buzzer correction in future versions of multiwii ;)

Post Reply