Implement TX switch activated buzzer in Alienwii

Post Reply
User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

I would like to know if it is possible to set up a buzzer connected to the Alienwii to be activated by a switch on the TX in the event of a lost quad. The processor in the Alienwii is the ATmega 32u4 and according to this
http://forum.arduino.cc/index.php?topic=241369.0
the MISO pin in the bootloader programming pins (6pin ICSP header) can be used as digital pin 14 and likewise the Mosi pin as digital pin 16. Using a Spektrum DX6, in Multiwii one switch is assigned to flight mode selection and I would like the other switch to be set to activate a buzzer powered from either Miso or Mosi upon activation of the appropriate TX switch. Motor arming would then be done via stick commands as this setup would use all six channels of the available on the DX6. Would anyone be able to take a look at the appropriate code in the Multiwii 2.4 files to see how this might be achieved please. Thanks in advance to anyone who might be able to help.

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

Re: Implement TX switch activated buzzer in Alienwii

Post by Hamburger »

In MWii you can override the default buzzer pin to whaever free pin you have.
Enable buzzer and in gui you can assign buzzer.on to an aux channel.

I do not know your board or alienwii. The 32u4 is capable of driving a buzzer.

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

Thank you for your reply Hamburger.

You are obviously a lot more skilled with coding and quadcopters than me. So in the Arduino forum link that I referenced in my initial question, the OP states that Miso and Mosi pins, which are broken out as bootloader programming pins on the Alienwii board, can be used as digital pins 14 and 16 respectively. Would you be able to take a look at the relevant code and advise me as to how to assign the buzzer to one of these pins so presumably I could then just wire a buzzer to that digital pin and ground and operate the appropriate switch to activate the buzzer. I would also have to be shown how to assign one of the two switches available to me on my TX. Excuse my rudimentary circuit image please. Thanks if you may feel inclined to help me with this and if not thank you for what you have told me so far :) Buzzer circuit schematic at http://imgur.com/me0sEUr

PatrikE
Posts: 1962
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by PatrikE »

MISO is digital pin 14. // PB3
So this should work.

Code: Select all

 #define BUZZER
 #define OVERRIDE_BUZZERPIN_PINMODE          pinMode (14, OUTPUT);
 #define OVERRIDE_BUZZERPIN_ON               PORTB |= 1<<3;
 #define OVERRIDE_BUZZERPIN_OFF              PORTB &= ~(1<<3);


To assign function to a switch is done in the Gui.
Simply check a box in the position of the AUX channel you want to activate with and save.

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

PatrikE thanks so much for your help.

I think that this is the relevant section in the Adruino files, config.h for the Alienwii FC which are available here

http://alienwii.com/brushed-alienwii-32 ... -flashing/


/******** override default pin assignments ********************/
/**************************************************************************************/

/* only enable any of this if you must change the default pin assignment, e.g. your board does not have a specific pin */
/* you may need to change PINx and PORTx plus #shift according to the desired pin! */
//#define OVERRIDE_V_BATPIN A0 // instead of A3 // Analog PIN 3

//#define OVERRIDE_PSENSORPIN A1 // instead of A2 // Analog PIN 2

//#define OVERRIDE_LEDPIN_PINMODE pinMode (A1, OUTPUT); // use A1 instead of d13
//#define OVERRIDE_LEDPIN_TOGGLE PINC |= 1<<1; // PINB |= 1<<5; //switch LEDPIN state (digital PIN 13)
//#define OVERRIDE_LEDPIN_OFF PORTC &= ~(1<<1); // PORTB &= ~(1<<5);
//#define OVERRIDE_LEDPIN_ON PORTC |= 1<<1; // was PORTB |= (1<<5);

//#define OVERRIDE_BUZZERPIN_PINMODE pinMode (A2, OUTPUT); // use A2 instead of d8
//#define OVERRIDE_BUZZERPIN_ON PORTC |= 1<<2 //PORTB |= 1;
//#define OVERRIDE_BUZZERPIN_OFF PORTC &= ~(1<<2); //PORTB &= ~1;

// Your additional buzzer code assigning buzzer to MISO being digital pin 14 / PB3

#define BUZZER
#define OVERRIDE_BUZZERPIN_PINMODE pinMode (14, OUTPUT);
#define OVERRIDE_BUZZERPIN_ON PORTB |= 1<<3;
#define OVERRIDE_BUZZERPIN_OFF PORTB &= ~(1<<3);



/*************************************************************************************************/

So would I be correct in assuming that seeing as all the buzzer code here is commented out, I would just add your buzzer code directly under that code extract and save the resulting code. Then re flash the Alienwii with this new code?

I have two spare channels available on my TX so I would be assigning one to flight mode selection, performing arming and disarming via stick commands which would leave one channel for the buzzer to be switched from. In the Multiwii GUI that the Alienwii uses I know how to assign a switch to flight mode selections and arming / disarming but am unsure of how to assign a switch to this new buzzer function. How might I do this please. As you are no doubt aware, I have extremely limited skills in all this. Am I correct in summising that every different FC board sets the Multiwii GUI up depending on the requirements of that particular FC board. Every image that I see of different FC's has different features available. I have attached an image of what is available in the Alienwii GUI, but no facility for buzzer implementation.

Once again thank you so much for your help, there are a lot of people with this FC that would love to have access to this feature if it can be incorporated for which you would, of course receive full acknowledgment :)
Attachments
Alienwii FC  GUI.jpg
Last edited by Pedro14755 on Thu Sep 10, 2015 10:20 am, edited 1 time in total.

PatrikE
Posts: 1962
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by PatrikE »

You might have to press the reset button in the gui.
And maybe uncomment some more buzzer options in config.

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

Thank you PatrikE.

I will adjust that code, reflash and reset the GUI. So does the GUI, for want of a better term "adjust itself" according to the options that are flashed into the flight controllers micro controller.

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

PatrikE
So I adjusted the code to what you suggested, re flashed the board and reset the GUI and now I have a buzzer option available. With the Deviated Devo 7E that I am using, the hold switch is Aux 1 and in the GUI you can see the switch turning the buzzer "box" on and off, but instead of a buzzer I wired an LED between Miso (LED anode) and ground (LED cathode) but there is no switching or illumination of the LED. There is however random flashing of the LED. I thought that maybe the USB power provided while connected to the GUI might be insufficient to switch the LED on and off so I closed the GUI and disconnected the FC from USB and connected the lipo to the FC and tried the TX switching action but still the same result Can you think of anything else that I might try because it all seems so close to happening thanks to your help :) I would assume that the Miso breakout pin is operational seeing as these pins have been provided for bootloader flashing.
Attachments
MultiWii beeper GUI_2.jpg

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

Hi PatriKe
Thank you for replying but that did not change the behaviour at all. There is still that flashing of the LED connected to ground and Miso but it seems to be pretty regular like on for 1 second and then off for 1 second. There must be something in the code to is stopping Miso from being set as a digital output. Do you have any other ideas to try or do you know anyone else who might be able to work around this. Thanks again for helping me I really appreciate your time.
Pedro

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

Well persistence paid off, and after receiving some help from Loeten this project finally came to fruition. If anyone is interested here is how it was done :)

http://community.micro-motor-warehouse. ... u=pedro147

saponga
Posts: 5
Joined: Mon Aug 31, 2015 5:23 pm

Re: Implement TX switch activated buzzer in Alienwii

Post by saponga »

Hello guys... @Pedro, thanks for posting that link. But what if i want something less complicated like wiring a 3 pins (+ s -) buzzer direct in to the receiver's channel 6 ? I've already tried that but buzzer keeps buzzing no matter the switch at transmitter is on or off. Can anyone help me with that ? Do i need to (un)comment anything on config.h ? Thank you all. :D

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

@saponga exactly what FC and RX are you using please

saponga
Posts: 5
Joined: Mon Aug 31, 2015 5:23 pm

Re: Implement TX switch activated buzzer in Alienwii

Post by saponga »

Crius SE 2.5 and FlySky FS-6TB. Thank you Pedro !

User avatar
Pedro14755
Posts: 49
Joined: Tue Jul 14, 2015 12:56 am
Location: Canberra Australia
Contact:

Re: Implement TX switch activated buzzer in Alienwii

Post by Pedro14755 »

Sorry my post was about AlienWii with a Lemon sat RX. I am not familiar with either your FC or RX sorry. I assume that you have looked but just in case, does any of this help you Good luck :)
https://goo.gl/EEnjlm

Post Reply