
Demo video showing the Pilot Lamp in action:
http://www.youtube.com/watch?v=z-nKSD-eHsQ
Another Demo Video:
http://vimeo.com/28593248
Code: Select all
PilotLamp(PL_GRN_ON);
Code: Select all
#define BUZZERPIN_ON PilotLamp(PL_BZR_ON);
#define BUZZERPIN_OFF PilotLamp(PL_BZR_OFF);
Code: Select all
#define PL_INIT 0
#define PL_GRN_ON 111 // 4500Hz
#define PL_GRN_OFF 192 // 2600Hz
#define PL_BLU_ON 312 // 1600Hz
#define PL_BLU_OFF 385 // 1300Hz
#define PL_RED_ON 500 // 1000Hz
#define PL_RED_OFF 588 // 850Hz
#define PL_BZR_ON 689 // 725Hz
#define PL_BZR_OFF 800 // 625Hz
#define PL_PIN_ON PORTB |= 1;
#define PL_PIN_OFF PORTB &= ~1;
Code: Select all
PilotLamp(PL_INIT);
The device is controlled via PWM?
So is it possible to blink two LEDs and beep the buzzer!?
Code: Select all
PilotLamp(PL_GRN_OFF);
PilotLamp(PL_RED_ON);
PilotLamp(PL_BLU_ON);
// These devices will remain on until YOU send the codes to turn them off.
Please add you code as an optional part to buzzer.ino - I believe it fits there
I saw there are two versions, one with housing and one without.
I will put it into shared trunk as soon as I tested it
mr.rc-cam wrote:Has anyone tried out the code examples I posted? If so, is it working for you?
- Thomas
Buzzer works fine and i only added grn led indicator after the init calibration.
mr.rc-cam wrote:Buzzer works fine and i only added grn led indicator after the init calibration.
Thanks for the feedback. It's good to hear the basic Pilot Lamp code works for you.
- Thomas
jevermeister wrote:I am implementing it as we speak, my pilot lamp is still underway but the code is already integrated into buzzer.ino.
I will put it into shared trunk as soon as I tested it,
I implemented some blink patterns.
Nils
Hamburger wrote:jevermeister wrote:I am implementing it as we speak, my pilot lamp is still underway but the code is already integrated into buzzer.ino.
I will put it into shared trunk as soon as I tested it,
I implemented some blink patterns.
Nils
While you are at it
Will you combine the led flasher code with the buzzer code? Sounds like one of the rare chamces to reduce number of files.
Hamburger wrote:From the led flaaher thread it seems people struggle woth missing documentation for
Fumctionality
Pin usage
Does that code do amythimg not possible with the buZer/alarm output
Code: Select all
#define PILOTLAMP
#if defined(PILOTLAMP)
#define BUZZER
#endif
shall i zip them for u?
if you right click on the link you can download the zip file directly.
1. you have to define arm/disarm via sticks in the config.h
BLinking of the LED in Acro or Level mode:
In level mode the green LED is blinking 0,5Hz (1sec ON, 1 sec OFF)
in acro mode, the LED is blinking in 1HZ (0,5sec ON, 0,5sec OFF)
Maybe the difference is not big enough?
If you activate the beeper mode (activate the beeper via aux channel), the sequence should be started.
Low Voltage battery beeps are unchanged, you rerouted the signals to the pilotlamp, so the vbat beepber codes are using the pilotlamp now.
Did you activate vbat and set the limits?=
Code: Select all
for (i=0;i<4;i++) { // Create the freq signal to activate Pilot Lamp.
PL_PIN_ON;
delayMicroseconds(device);
PL_PIN_OFF;
delayMicroseconds(device);
}
Code: Select all
void PilotLamp(uint16_t device){
uint8_t i;
static union pl_reg mode;
if(device == PL_INIT) { // Initialize the Pilot Lamp.
mode.pl_ctrl_all = 0x00; // Reset all LED and Buzzer status states.
for (i=0;i<4;i++) { // Create the required freq waveforms to control the various modes.
PL_PIN_ON;
delayMicroseconds(PL_GRN_OFF);
PL_PIN_OFF;
delayMicroseconds(PL_GRN_OFF);
PL_PIN_ON;
delayMicroseconds(PL_BLU_OFF);
PL_PIN_OFF;
delayMicroseconds(PL_BLU_OFF);
PL_PIN_ON;
delayMicroseconds(PL_RED_OFF);
PL_PIN_OFF;
delayMicroseconds(PL_RED_OFF);
PL_PIN_ON;
delayMicroseconds(PL_BZR_OFF);
PL_PIN_OFF;
delayMicroseconds(PL_BZR_OFF);
}
}
else { // Check to see if the new state request is different than the current state.
if(device==PL_GRN_OFF && mode.ctrl.grn==1) {
mode.ctrl.grn = 0;
}
else if(device==PL_GRN_ON && mode.ctrl.grn==0) {
mode.ctrl.grn = 1;
}
else if(device==PL_BLU_OFF && mode.ctrl.blu==1) {
mode.ctrl.blu = 0;
}
else if(device==PL_BLU_ON && mode.ctrl.blu==0) {
mode.ctrl.blu = 1;
}
else if(device==PL_RED_OFF && mode.ctrl.red==1) {
mode.ctrl.red = 0;
}
else if(device==PL_RED_ON && mode.ctrl.red==0) {
mode.ctrl.red = 1;
}
else if(device==PL_BZR_OFF && mode.ctrl.bzr==1) {
mode.ctrl.bzr = 0;
}
else if(device==PL_BZR_ON && mode.ctrl.bzr==0) {
mode.ctrl.bzr = 1;
}
else { // No state changes
PL_PIN_OFF;
return; // Skip signal generation.
}
for (i=0;i<4;i++) { // Create the freq signal to activate Pilot Lamp.
PL_PIN_ON;
delayMicroseconds(device);
PL_PIN_OFF;
delayMicroseconds(device);
}
}
return;
}
Code: Select all
for (i=0;i<4;i++) { // Create the freq signal to activate Pilot Lamp.
PL_PIN_ON;
delayMicroseconds(device);
PL_PIN_OFF;
delayMicroseconds(device);
}
}
return;
}
Code: Select all
#if defined(PILOTLAMP)
// ****************************************************************
// * XAircraft Pilot Lamp *
// * LED & Buzzer Device for use with MultiWiiCopter. *
// * by Thomas Black / mr.rc-cam *
// * Org: June-19-2012 *
// * Upd: August-09-2012 *
// * Made in USA :) *
// ****************************************************************
//
// Need help using this code? Please see http://www.multiwii.com/forum/viewtopic.php?f=6&t=1794
//
// *********************************************************************************************************************
//
// These routines for XAircraft's Pilot Lamp LED/Buzzer module are preliminary functions that may
// change after additional reverse-engineering of the XAircraft communication protocol is performed.
//
// *********************************************************************************************************************
union pl_reg {
struct {
unsigned grn: 1;
unsigned blu: 1;
unsigned red: 1;
unsigned bzr: 1;
} ctrl;
uint8_t pl_ctrl_all;
};
// *********************************************************************************************************************
// PilotLamp() is called with the PL_XX parameter (see below). In order to prevent unneccessary
// increases in IMU cycle time, the bit-bang freq control waveform is only generated if the device (LED or buzzer)
// state update is different from the previous state.
// Available device parameters are:
// PL_INIT { MUST be called once in main sketch setup() }
// PL_GRN_ON, PL_GRN_OFF { Green LED control }
// PL_BLU_ON, PL_BLU_OFF { Blue LED control }
// PL_RED_ON, PL_RED_OFF { Red LED control }
// PL_BZR_ON, PL_BZR_OFF { Buzzer control }
//
void PilotLamp(uint16_t device)
{
uint8_t i;
static union pl_reg mode;
if(device == PL_INIT) { // Initialize the Pilot Lamp State Table, turn off LEDs and Buzzer.
mode.pl_ctrl_all = 0x00; // Reset all LED and Buzzer status states.
gen_pl_freq(PL_GRN_OFF); // Turn off Green LED.
gen_pl_freq(PL_BLU_OFF); // Turn off Blue LED.
gen_pl_freq(PL_RED_OFF); // Turn off Red LED.
gen_pl_freq(PL_BZR_OFF); // Turn off Buzzer.
}
else { // Check to see if the new state request is different than the current state.
if(device==PL_GRN_OFF && mode.ctrl.grn==1) {
mode.ctrl.grn = 0;
}
else if(device==PL_GRN_ON && mode.ctrl.grn==0) {
mode.ctrl.grn = 1;
}
else if(device==PL_BLU_OFF && mode.ctrl.blu==1) {
mode.ctrl.blu = 0;
}
else if(device==PL_BLU_ON && mode.ctrl.blu==0) {
mode.ctrl.blu = 1;
}
else if(device==PL_RED_OFF && mode.ctrl.red==1) {
mode.ctrl.red = 0;
}
else if(device==PL_RED_ON && mode.ctrl.red==0) {
mode.ctrl.red = 1;
}
else if(device==PL_BZR_OFF && mode.ctrl.bzr==1) {
mode.ctrl.bzr = 0;
}
else if(device==PL_BZR_ON && mode.ctrl.bzr==0) {
mode.ctrl.bzr = 1;
}
else { // No state changes
PL_PIN_OFF;
return; // Skip signal generation.
}
gen_pl_freq(device); // Send waveform to Pilot Lamp.
}
return;
}
// *****************************************************************************************************************
// Create the freq signal to activate Pilot Lamp. This is a bit-bang operation.
void gen_pl_freq(uint16_t device)
{
uint8_t i;
for (i=0;i<4;i++) { // Four waveforms are required.
PL_PIN_ON;
delayMicroseconds(device);
PL_PIN_OFF;
delayMicroseconds(device);
}
return;
}
// *****************************************************************************************************************
// PilotLampTest() can be used to troubleshoot the LED/Buzzer module. Place it in the main loop and you
// should see the three LED's sequence in order with a periodic short beep.
void PilotLampTest(void)
{
static uint8_t cam1 = 0;
static uint8_t cam2 = 0;
static uint8_t state = 0;
if(cam1++ > 40) { // Update rate is perhaps 2Hz, but will vary.
cam1 = 0;
if(cam2++ > 20 && state==1) { // Periodically beep the buzzer (every few seconds).
cam2 = 0;
PilotLamp(PL_BZR_ON);
delay(200); // Brute force delay is needed because main loop will immediately turn off buzzer.
}
else {
switch(state) { // Light-chase Cycle the LED's.
case 0:
state++;
PilotLamp(PL_BZR_OFF);
break;
case 1:
state++;
PilotLamp(PL_GRN_ON);
break;
case 2:
state++;
PilotLamp(PL_GRN_OFF);
PilotLamp(PL_BLU_ON);
break;
case 3:
state++;
PilotLamp(PL_BLU_OFF);
PilotLamp(PL_RED_ON);
break;
case 4:
state = 0;
PilotLamp(PL_RED_OFF);
break;
}
}
}
return;
}
// *********************************************************************************************************************
#endif