MegaPirateNG / ardupilot-mpng

MegaPirateNG
GNU General Public License v3.0
117 stars 105 forks source link

External LEDs and Piezo Buzzer with 3.0.1R4 #100

Open bmizes opened 10 years ago

bmizes commented 10 years ago

Lakis on rcgroups provided code changes and wiring diagrams for firmware versions less than 3.0 that enabled one to have external leds on A4 and A5 and a piezo buzzer on 32 when using a ULN2803A. Since the firmware code has changed, the coding changes that lakis provided on rcgroups are no longer applicable. Does 3.0.1R4 support external leds and piezo buzzers without any modifications, and if so, to what pins should they be wired? If not, have you or anyone else provided code changes that would allow us to use external leds and piezo buzzers on A4, A5, and 32 respectively (or any other pins for that matter) as we did before?

Thanks for the great work to date. Very much looking forward to your port of 3.1. .

Barry

djonsnel commented 10 years ago

Have you tried it yet? made some changes to the source code but cant test it out

bmizes commented 10 years ago

Djonsel,

I haven't tried it yet with 3.0.1R4 because I don't know which pins to access for what. As I said above, in the code provided by Lakis on rcgroups, A5 was for motor leds, A4 for GPS leds and 32 for the piezo buzzer. If you were the one who wrote the led code for 3.0.1R4, what pins did you write for in terms fo motor leds, gps leds, and a piezo buzzer. I can try it out if you let me know.

djonsnel commented 10 years ago

I'm not the one who wrote the origional code..... but as far as I can see 3.0.1R4 should be able to take the same A4 and A5 mod for the LEDs not sure about the buzzer though

bmizes commented 10 years ago

I've looked at the code too and I don't see anything that ports the leds to A4 and A5. In fact, in config.h, the code reads

define A_LED_PIN 13

define B_LED_PIN 31

define C_LED_PIN 30

If you look at the definitions of the # 13, 31, and 30 outputs, they are not A4 or A5. From my reading, A5 corresponds to 59. I'm going to try to use the code thomasbutler wrote but modify it to use output 59 and see what that does. Somebody out there I'm sure has already solved this and hopefully we can find the solution and be done with it.

On Thu, Feb 20, 2014 at 12:46 PM, djonsnel notifications@github.com wrote:

I'm not the one who wrote the origional code..... but as far as I can see 3.0.1R4 should be able to take the same A4 and A5 mod for the LEDs not sure about the buzzer though

Reply to this email directly or view it on GitHubhttps://github.com/MegaPirateNG/ardupilot-mpng/issues/100#issuecomment-35654812 .

Barry Mizes 7001 Washington Ave. St. Louis, MO 63130

314-721-1841 voice 314-484-0504 cell

bmizes@yahoo.com

djonsnel commented 10 years ago

The external LED mod is already in the source code.......just don't disable it in the APM_config.h

//////////////////////////////////////////////////////////////////////////////// // CopterLEDs //

ifndef COPTER_LEDS

define COPTER_LEDS ENABLED

endif

define COPTER_LED_ON HIGH

define COPTER_LED_OFF LOW

if CONFIG_HAL_BOARD == HAL_BOARD_APM2

define COPTER_LED_1 AN4 // Motor or Aux LED

define COPTER_LED_2 AN5 // Motor LED or Beeper

define COPTER_LED_3 AN6 // Motor or GPS LED

define COPTER_LED_4 AN7 // Motor LED

define COPTER_LED_5 AN8 // Motor LED

define COPTER_LED_6 AN9 // Motor LED

define COPTER_LED_7 AN10 // Motor LED

define COPTER_LED_8 AN11 // Motor LED

elif CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL || CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_SMACCM

define COPTER_LED_1 AN8 // Motor or Aux LED

define COPTER_LED_2 AN9 // Motor LED

define COPTER_LED_3 AN10 // Motor or GPS LED

define COPTER_LED_4 AN11 // Motor LED

define COPTER_LED_5 AN12 // Motor LED

define COPTER_LED_6 AN13 // Motor LED

define COPTER_LED_7 AN14 // Motor LED

define COPTER_LED_8 AN15 // Motor LED

elif CONFIG_HAL_BOARD == HAL_BOARD_MPNG

define COPTER_LED_1 AN4 // Motor or Aux LED

define COPTER_LED_2 AN5 // Motor LED

define COPTER_LED_3 AN6 // Motor or GPS LED

define COPTER_LED_4 AN7 // Motor LED

define COPTER_LED_5 -1 // Motor LED

define COPTER_LED_6 -1 // Motor LED

define COPTER_LED_7 -1 // Motor LED

define COPTER_LED_8 -1 // Motor LED

endif

bmizes commented 10 years ago

That code won't work because the references are to AN4, AN5, AN6 and AN7. Those are pins on the APM board, not Crius board.

On Thu, Feb 20, 2014 at 1:31 PM, djonsnel notifications@github.com wrote:

The external LED mod is already in the source code.......just don't disable is in the APM_config.h

//////////////////////////////////////////////////////////////////////////////// // CopterLEDs //

ifndef COPTER_LEDS

define COPTER_LEDS ENABLED

endif

define COPTER_LED_ON HIGH

define COPTER_LED_OFF LOW

if CONFIG_HAL_BOARD == HAL_BOARD_APM2

define COPTER_LED_1 AN4 // Motor or Aux LED

define COPTER_LED_2 AN5 // Motor LED or Beeper

define COPTER_LED_3 AN6 // Motor or GPS LED

define COPTER_LED_4 AN7 // Motor LED

define COPTER_LED_5 AN8 // Motor LED

define COPTER_LED_6 AN9 // Motor LED

define COPTER_LED_7 AN10 // Motor LED

define COPTER_LED_8 AN11 // Motor LED

elif CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD ==

HAL_BOARD_AVR_SITL || CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_SMACCM

define COPTER_LED_1 AN8 // Motor or Aux LED

define COPTER_LED_2 AN9 // Motor LED

define COPTER_LED_3 AN10 // Motor or GPS LED

define COPTER_LED_4 AN11 // Motor LED

define COPTER_LED_5 AN12 // Motor LED

define COPTER_LED_6 AN13 // Motor LED

define COPTER_LED_7 AN14 // Motor LED

define COPTER_LED_8 AN15 // Motor LED

elif CONFIG_HAL_BOARD == HAL_BOARD_MPNG

define COPTER_LED_1 AN4 // Motor or Aux LED

define COPTER_LED_2 AN5 // Motor LED

define COPTER_LED_3 AN6 // Motor or GPS LED

define COPTER_LED_4 AN7 // Motor LED

define COPTER_LED_5 -1 // Motor LED

define COPTER_LED_6 -1 // Motor LED

define COPTER_LED_7 -1 // Motor LED

define COPTER_LED_8 -1 // Motor LED

endif

Reply to this email directly or view it on GitHubhttps://github.com/MegaPirateNG/ardupilot-mpng/issues/100#issuecomment-35659642 .

Barry Mizes 7001 Washington Ave. St. Louis, MO 63130

314-721-1841 voice 314-484-0504 cell

bmizes@yahoo.com

djonsnel commented 10 years ago

try and remove the N to change it to A2, A3, A4 and A5 that worked in the last version

SirAlex commented 10 years ago

That code won't work because the references are to AN4, AN5, AN6 and AN7. Those are pins on the APM board, not Crius board.

AN0-AN7 is the same on ArduCopter and CRIUS, except AN6, AN7 was only on CRIUS v2. So to use LEDs on CRIUS v1, you may try to change provided code to:

#elif CONFIG_HAL_BOARD == HAL_BOARD_MPNG
#define COPTER_LED_1 AN4 // Motor or Aux LED
#define COPTER_LED_2 AN5 // Motor LED
#define COPTER_LED_3 32 // Motor or GPS LED
#define COPTER_LED_4 33 // Motor LED

And connect LEDs to A4,A5,32,33

bmizes commented 10 years ago

I've tried that and you get compile errors because A4 and A5 are not defined

Barry Mizes 7001 Washington Ave St. Louis, Mo 63130

314-721-1841 home 314-484-0504 cell On Feb 20, 2014 3:25 PM, "djonsnel" notifications@github.com wrote:

try and remove the N to change it to A4, A5, A6 and A7 that worked in the last version

Reply to this email directly or view it on GitHubhttps://github.com/MegaPirateNG/ardupilot-mpng/issues/100#issuecomment-35670765 .

bmizes commented 10 years ago

I modified the arming led code and now have it working on A5. I will tackle the GPS led code tomorrow. Keep your fingers crossed. I don't really know C++ and the code is so complicated and tasks use multiple files such that it's very difficult to follow at times. No promises. If I get lucky I'll post the code changes.

Barry

On Thu, Feb 20, 2014 at 3:25 PM, djonsnel notifications@github.com wrote:

try and remove the N to change it to A4, A5, A6 and A7 that worked in the last version

Reply to this email directly or view it on GitHubhttps://github.com/MegaPirateNG/ardupilot-mpng/issues/100#issuecomment-35670765 .

Barry Mizes 7001 Washington Ave. St. Louis, MO 63130

314-721-1841 voice 314-484-0504 cell

bmizes@yahoo.com