XAircraft Pilot Lamp Accessory Hack

mr.rc-cam
Posts: 457
Joined: Wed Jul 27, 2011 11:36 pm

Re: XAircraft Pilot Lamp Accessory Hack

Post by mr.rc-cam »

Sorry to hear that the Pilot Lamp died. These sort of unexpected events can really be frustrating!

- Thomas

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

I wonder what is broken,
the speaker is very silent, but the whole module is still working, patterns are blinking and buzzing correctly...

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

Re: XAircraft Pilot Lamp Accessory Hack

Post by Hamburger »

the speaker itself maybe?

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

Got my Pilotlamp yesterday :? I hope you find a way to go on with your good work.

Maybe I wanna donate you a new one. :mrgreen:

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

http://ncopters.blogspot.com ->Paypal button "Spenden"
But beware, it is pretty rusty cause noone used it :-(

Nils

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

Oke, you've got it. :mrgreen:
http://www.ebay.com/itm/ws/eBayISAPI.dl ... 1054020131
I got this one in 10 days.

The code from 2 hours ago, is it working anyway?

I just came here to look for some improvements on this.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

I uploades a new revision of the ndroiid version today.
i will upload the same code without my config.h changes this evening.
it is working as best as possible with the current signal generation.

thank you for the donation

nils

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

Is it possible to place a complete zipped version, its easier for me.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

sorry svn is not working right now. cannot commit or upload.


KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

Thanks Nils, I'm gonna try it.

Tazzy
Posts: 75
Joined: Sun Jun 19, 2011 4:45 pm
Location: Sweden

Re: XAircraft Pilot Lamp Accessory Hack

Post by Tazzy »

I really like this pilot lamp on my quad and hexa i hope it can get in the sharpcode ....

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

is this feature not in the main shared code?

I just got my pilot lamp. smaller than I expected :)

Image

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Due to the fact that the current communication of the lamp is very laggy and depends on cycletime I did not dare to commit it. I will have a look an hambirgers cycletime fix and think about it. I think Alex and the community should decide. I will contac alex.

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

I dd the merge and it works fine. I only have gyro+accel and my cycle time is around 2500-2600 only. Cycle time increased to 2800-2900 with pilot lamp. Does the cycle time get too high with more components like GPS, Baro, etc.?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

I had serious problems with serial gps. The lamp did weird stuff like beeping forever.
Please contact alexinparis and ask for his opinion on that.

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

Re: XAircraft Pilot Lamp Accessory Hack

Post by Alexinparis »

I think the way to control this device is not clean.
It should be interrupt based to be independent from cycle time.
But as long as it doesn't interfere with other code (via a proper #define, and not a single bit dif when not defined) you can integrate it if you want.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

I tried different approaches but the current "hack" is the only one that does not intercere with the code. I thougt about using pwm output but I am not into that subject and I believe pwm outputs are to rare for that. We need an output that will keep its cycle stable.any ideas

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

as far as using interrupts, timer0 is available if using quad for promini (I only looked at promini code since I have atmega328). I think there is one counter left if you have a quad + servo for camera stab.
is the control signal based on frequency and not pulse width?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

You have to send three full periods of a given frequency to trigger a function of the lamp. I have to admit,that I am not good enough to code that with timer or counters.
The current solution does that with a for, and this is affected by cycletime. Please have a lool at alarms.ino on my branch. It is very simple. Every aspect of the lamp has its specific frequency.

Nils

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

only 1 pulse is needed, and its based on pulse width multiples of 100us. I think this is more exact than the original reverse engineering based on frequency.

I wrote a test sketch using timer0 interrupt for arduino UNO and sent GgBbRrZz in arduino serial monitor and these are the pulses captured by logic analyzer on pin 8.
Image
you can see above G is about 100us, g about 200us, etc.

I can try to modify the current pilot lamp code to make it interrupt driven. I think Pilot lamp support can be added with very minimal impact. I think this is one of the more useful accessory that can be added for around $10.

Code: Select all

#define PIN_HI PORTB |=1;
#define PIN_LO PORTB &= ~1;

#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
#define    PL_IDLE      250    // 1000us

void setup()
{
  pinMode(8,OUTPUT);
  TCCR0A = 0;
  TIMSK0 |= (1<<OCIE0A);
  OCR0A = PL_IDLE;
  Serial.begin(9600);
 
}

static uint8_t tick =0;

void loop() {
  while(Serial.available()) {
    if (tick!=0) continue; //last command not done yet
    char ch = Serial.read();
    switch (ch) {
      case 'G' : tick = PL_GRN_ON;
                 break;
      case 'g' : tick = PL_GRN_OFF;
                 break;
      case 'B' : tick = PL_BLU_ON;
                 break;
      case 'b' : tick = PL_BLU_OFF;
                 break;
      case 'R' : tick = PL_RED_ON;
                 break;
      case 'r' : tick = PL_RED_OFF;
                 break;
      case 'Z' : tick = PL_BZR_ON;
                 break;
      case 'z' : tick = PL_BZR_OFF;
                 break;
      default: tick = 0;
    }
    OCR0A = 0;
  }
 
}

ISR(TIMER0_COMPA_vect) {
  static uint8_t state = 0;
  if (tick==0) return; //no new command
  if (state==0) {
    PIN_HI;
    OCR0A=tick;
    state=1;
  } else if (state==1) {
    PIN_LO;
    OCR0A = PL_IDLE;
    tick = state = 0;
  }
}

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Interesting.I will look at it tomorrow.we have a public holiday. Thank you!

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

I modified the code to use timer interrupts and seems to work well. I need others to test it further just to make sure.

Attached are the full source as well as the svn patch file.

Let me know your test results.

Thanks!
Attachments
r1155_pilotlamp.zip
patch to r1155
(3.27 KiB) Downloaded 211 times
MultiWii.zip
full r1155 source + PilotLamp code
(122.41 KiB) Downloaded 202 times

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

some logic analyzer screenshots

chaser lights pattern to the left, find me pulses to the right
Image

zoom in to chaser light pulses. the light signals are in groups of 3 and 100ms apart. the single fatter pulse is for buzzer and is 50ms apart
Image

zoom in to the buzzer pulse and the Green Blue Red pulse. Only a single pulse is needed to control the light or buzzer.
Image

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

That is looking very good.

I adapted the code to my old branch and will try to test it tonight.

As I am running a mege 2560 is there anything to know?

I was pretty happy with the extra info the PL gave me so I was very dissapointed when I noticed that it was not usable for me running a GPS on a mega.

Nils

ps.: I am still in the process of understanding your code - please be patient with me ;-)

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

In def.h PL_INIT, you just need to change the timer register to one that is available in mega. If its an 8 bit timer, then the rest of the code stays the same. You can look at how camstab servo is setup for mega, and its pretty much the same. Just need to find the available timer register

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Hi,

I checked which timers are free on mega, it seems to me, that timer0 is available on the mega
in output.ino the timer0 is only used in promicro abd promini.

The whole timer theme is very new for me, so I do not know if I do this correctly.

I will try to see which timer is available.

Nils

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Hi,
I think I found a small error:

Code: Select all

#if defined PILOTLAMP 
  #if not defined(PROMINI) && NUMBER_MOTOR >4
    #undef PILOTLAMP
  #else


imho the undefinde should be before the if defined of pilotlamp.

The if statement

Code: Select all

 #if not defined(PROMINI) && NUMBER_MOTOR >4


is not correct, if you use a pro mini with 6 motors you will use the pl on timer0 although it is not available.

we should carefully test this with different setups, I made a lot of these mistakes with my specific setup in the past, that gave me a lot of evil looks. ;-)

Nils

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

you don't want to use timer0 unless you absolutely have to. mega has 15 timers, less 2 for timer0 so that leaves 13 timers. it'll probably be a 16bit timer though, but the rest of the code can remain the same if you set the timer resolution to 4us per increment. I can look into adding mega support this weekend, but I don't have a way to test since I don't have a mega based FC board.

you are right, that is a bug. if support for mega, promicro, etc are to be added, then that is the place to add more #if conditions.

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

I took a quick look at output.ino, and it looks like all 13 timers are used in mega! To minimize changes, I think you can use timer0 OCR0B for mega as well, so I think you can change the if condition to allow promini as long as motors<=4, and mega. To use timer0 for other cpu, you just need to find the additional restrictions like 4 motors, etc. I'm thinking support for other cpu can be added only as needed (if someone asks for it).

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Hi, thank you for the info.

I did a testrun with Pilotlamp and it works as usual with timer 0 on mega.
Is there any circumstance that the mega canno run the Pilotlamp on timer0?

I did the stresstest by activating GPS and did not have the hickups and lags I had with the old pilotlamp code,

I think you nailed it doughboy! Good work!!!

Nils

ps.: I will update my branch asap,
when I go some betatesters with gps I will put that into the trunk with you in credits!

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

as far as I can tell just from reading output.ino, you can use timer0 for all (promini, promicro and mega cpu), with promini having the restriction of 4 motors only and no restriction on use with mega and promicro.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Hi,

I did some minor modifications to you code and uploaded it into my branches.

I moved the restriction of more than 4 motors into the define blog of the pro mini to undefine pilotlamp as soonm as possible to avoid the first chain defines.

I will try some flight tests the next days to be sure that the buzzer is working now and if you think everything is okay we can merge it into the shared trunk.

I like your way of creating the sequences, I think I will adapt that to the global alarm handling after I understood it.

Nils

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

Code tested and flown. I checked it with GPS inflight - no problem.

I checked it into the shared trunk - hope you all like it.

Thank you mr.rc-cam and doughboy - nice working with you!

Nils

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

I like to test it but can't get r1171 working.
Attachments
foutmelding r1171.jpg

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by doughboy »

you obviously are not using the unmodified r1171 as your line numbers are all different and the error line should be SerialOpen(0,SERIAL0_COM_SPEED); and not SerialOpen(0,SERIAL_COM_SPEED); like in your screenshot.

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: XAircraft Pilot Lamp Accessory Hack

Post by KeesvR »

Thank you very much, it's working now.

Next problem I need to solve is, my voltage reading is dropping when I give some throttle.
But not from my external lipo alarm. Maybe a short somewhere or a bad connection.

Opal
Posts: 5
Joined: Thu Sep 27, 2012 8:48 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by Opal »

Quitely interesting show... Thx for sharing!

cGiesen
Posts: 188
Joined: Wed Jul 18, 2012 7:53 am
Location: Bochum, Germany

Re: XAircraft Pilot Lamp Accessory Hack

Post by cGiesen »

Hello,

I'm in the club to.

Is there a docu, how in detail the Pilot Lamp work?

I see a blue blink when I plug the accu.
And a green blinking if the kopter is armed!

Thanks for the great work.

Carsten

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by jevermeister »

take a look at the code under alarms.ino.

i also wrote something into the official multiwii wiki.

slow green: acc fast green:acro
fast blue: no gps fix slow blue gps fix.
slow red failsafe 1 fast red failsafe panic.
all simultaneous: i2c error.

haley0918
Posts: 28
Joined: Tue Mar 06, 2012 9:09 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by haley0918 »

Hi,

I'd just acquired a Pilotlamp for my quad. I'm loading my quad with v2.2.

The arm indication with green LED works fine. But when I turn on Beeper, it occasionally skips the green LED. The buzzer on the Pilotlamp also seems to have trouble picking up the pulse signals. The Pilotlamp buzzer occasionally either beeps continuously or doesn't at all. I can't get it to beep like when using normal buzzer.

Is the timing on the multiwii not stable enough to produce the pulse or is there other problem?

haley0918
Posts: 28
Joined: Tue Mar 06, 2012 9:09 am

Re: XAircraft Pilot Lamp Accessory Hack

Post by haley0918 »

I'd just solved it. The problem was from my define of buzzer pin override. I'm using HK Multiwii 328 board that has no D8 so I have to re-route to A2.

With the override defined, the normal buzzer functions were enabled and it's pulses interfere with the Pilotlamp pulses. But when the override undefined, BUZZER_PINMODE in def.h has to be changed to my prefered A2. The port and bits for PL_PIN_ON and PL_PIN_OFF have to be changed too to A2.

I would like to suggest a pin override option for Pilotlamp too in v2.3.


jevermeister wrote:OK, thats it for me, I killed my PilotLamp today. I accidently laoded normal buzzer code while testing the cycletimes and now the Piezo Buzzer is very faint and is useless.


The cause for killing the Pilotlamp by loading the normal buzzer code is because the Pilotlamp has no protection on it's signal line. Therefore, the longer pulses of the buzzer code could potentially supply too much current into Pilotlamp and burn the controller. As the Pilotlamp's buzzer and LEDs are driven by another transistor array, I can't see why it's buzzer or LED could burn out unless there was over current.

To protect Pilotlamp's signal line, add a 1Kohm resistor in series before plugging into flight controller. Adding another 1Kohm resistor for pull down is recommended for signal integrity.

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: XAircraft Pilot Lamp Accessory Hack

Post by felixrising »

To protect Pilotlamp's signal line, add a 1Kohm resistor in series before plugging into flight controller. Adding another 1Kohm resistor for pull down is recommended for signal integrity.


This needs to be in the wiki too. Someone else also left a comment on the wiki indicating something similar.. I think I just killed mine and it was avoidable.... :(

EDIT: No update to the Documentation_Pilotlamp here https://code.google.com/p/multiwii/w/list

Wiki is here: http://www.multiwii.com/wiki/index.php?title=Extra_features#Pilot_Lamp
Last edited by felixrising on Wed May 29, 2013 5:24 am, edited 1 time in total.

ovaltineo
Posts: 15
Joined: Sun Apr 28, 2013 11:41 pm

Re: XAircraft Pilot Lamp Accessory Hack

Post by ovaltineo »

I don't understand why a resistor is necessary. The signal line does not supply the power to the LEDs or buzzer. It goes to INT1 of the STC11F01 CPU. It is a high impedance input. The power comes from the 5v rail and there are resistors for the LEDs and the buzzer has built-in current limiting resistance. If the buzzer is faint, it is probably just defective.

fotophanatic
Posts: 3
Joined: Tue Jun 11, 2013 7:00 pm

Re: XAircraft Pilot Lamp Accessory Hack

Post by fotophanatic »

I've looked through most of this thread and a lot is Greek to me. I'm new to the MultiWii side of things so I apologize for any redundant question. I've been using DJI naza and XAircraft for the last couple years. I have a MultiWii PRO EZ3.0 from Witespy and am slowly learning how things work. I have an XA pilot lamp and was wondering what I need to do to get it to work with my board? Be gentle please ;)

maxraschke
Posts: 1
Joined: Sun Jun 16, 2013 9:38 pm

Re: XAircraft Pilot Lamp Accessory Hack

Post by maxraschke »

Would also love to know if theres a way to use the xaircraft PL with the Witespy MW2 Pro board. The board has no buzzer port, but in my case there are unused outputs (for example D46- cam trigger). Would it be possible to get another port to work as a buzzer port? Spent lots of querys on google, but no results so far.

Thanks!

Greg Covey
Posts: 11
Joined: Tue Feb 05, 2013 11:20 pm
Location: Rochester, NY USA
Contact:

Re: XAircraft Pilot Lamp Accessory Hack

Post by Greg Covey »

I got the MWC Pilot Lamp fixed. It suffered from the same MEGA-Death code bug that the buzzer had. This will work on either Pro2 or Pro3 boards.

Sorry for the poor photos but you get the idea. Enjoy!

1) Use the normal BUZZER pin D8 and supply power to the device from a known 5v source (not the D8 header row). D8 signal, 5v, and GND go to the Pilot Lamp (just like the buzzer)

2) In config.h select your choices (no need for the define BUZZER)

/******************/
/**** Buzzer ****/
/*****************/
//#define BUZZER
#define RCOPTIONSBEEP // uncomment this if you want the buzzer to beep at any rcOptions change on channel Aux1 to Aux4
//#define ARMEDTIMEWARNING 330 // (*) Trigger an alarm after a certain time of being armed [s] to save you lipo (if your TX does not have a countdown)
#define PILOTLAMP //Uncomment if you are using a X-Arcraft Pilot Lamp

In def.h, make the following code changes in BOLD:

/************************** all the Mega types ***********************************/
#if defined(MEGA)
#define LEDPIN_PINMODE pinMode (13, OUTPUT);pinMode (30, OUTPUT);
#define LEDPIN_TOGGLE PINB |= (1<<7); PINC |= (1<<7);
#define LEDPIN_ON PORTB |= (1<<7); PORTC |= (1<<7);
#define LEDPIN_OFF PORTB &= ~(1<<7);PORTC &= ~(1<<7);
// #define BUZZERPIN_PINMODE pinMode (32, OUTPUT);
#define BUZZERPIN_PINMODE DDRH |= (1<<5) ;

#if defined PILOTLAMP
// #define PL_PIN_ON PORTC |= 1<<5;
// #define PL_PIN_OFF PORTC &= ~(1<<5);
#define PL_PIN_ON PORTH |= (1<<5);
#define PL_PIN_OFF PORTH &= ~(1<<5);

#else
// #define BUZZERPIN_ON PORTC |= 1<<5;
// #define BUZZERPIN_OFF PORTC &= ~(1<<5);
#define BUZZERPIN_ON PORTH |= (1<<5);
#define BUZZERPIN_OFF PORTH &= ~(1<<5);

#endif
Attachments
PilotLamp2b.jpg

Post Reply