Led indication for voltage monitoring on AtMega

Post Reply
brewski
Posts: 483
Joined: Tue Apr 29, 2014 12:04 am
Location: Cleveland Qld Australia

Led indication for voltage monitoring on AtMega

Post by brewski »

I set up voltage monitoring as well as high intensity LED for low voltage with my previous Crius SE 2.5 board. I now run a Crius AIOP ATMega2560 on my quad & have a ULN2003 buffer board feeding a hi intensity blue LED for visual confirmation of number of satellites before arming. I use another one of the buffers to turn on LED strips when armed. I thought with 5 spare buffers I might as well set up a high intensity red LED (or use one of the LED strips) to alert for low Lipo voltage.
I have accurate voltage monitoring setup but a quick search didn't show which output on AtMega board will flash with the three detection states of low voltage.
Can anyone tell me which output pin & whether I need to modify any lines in Config.h or Def.h

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

Re: Led indication for voltage monitoring on AtMega

Post by Hamburger »

Low voltage triggers alarm handling. Alarm uses buzzer for signaling.
So best search for buzzer/beeper pin or override its default.

brewski
Posts: 483
Joined: Tue Apr 29, 2014 12:04 am
Location: Cleveland Qld Australia

Re: Led indication for voltage monitoring on AtMega

Post by brewski »

Hamburger wrote:Low voltage triggers alarm handling. Alarm uses buzzer for signaling.
So best search for buzzer/beeper pin or override its default.

I came across several solutions. This one is only a few lines of code but I can't understand how it could work. Author claims port A4 will go low on Arming & pulse when voltage triggers alarm points. A4 is an input & I see no code to command it as an Output.
bejo52 wrote:
I got it.
Don't care about the LEDPIN. Just configure the LED_FLASHER_PORT...
I use
#define LED_FLASHER_DDR DDRF
#define LED_FLASHER_PORT PORTF
#define LED_FLASHER_BIT PORTF4
on the Crius AIOP for the analog port A4. Leave the //#define LED_FLASHER_INVERT commented
Now the LEDs switch on when arming and flash while battery alarm is on.

I also found this by Quadbow which is for controlling 3 LED strips but I could just use the Red (voltage alarm section) I'm thinking.
#if defined(MEGA)
#if defined(LED_MONITOR)
#undef GPS_LED_INDICATOR
#undef PILOTLAMP
#define LEDPIN_PINMODE pinMode (13, OUTPUT);
#define LEDPIN_TOGGLE PINB |= (1 << 7);
#define LEDPIN_ON PORTB |= (1 << 7);
#define LEDPIN_OFF PORTB &= ~(1 << 7);
#define LED_GREEN_PINMODE pinMode (30, OUTPUT);
#define LED_BLUE_PINMODE pinMode (31, OUTPUT);
#define LED_RED_PINMODE pinMode (33, OUTPUT);
#if defined(LED_MON_REV)
#define LED_GREEN_ON PORTC &= ~(1 << 7);
#define LED_GREEN_OFF PORTC |= (1 << 7);
#define LED_BLUE_ON PORTC &= ~(1 << 6);
#define LED_BLUE_OFF PORTC |= (1 << 6);
#define LED_RED_ON PORTC &= ~(1 << 4);
#define LED_RED_OFF PORTC |= (1 << 4);
#define LED_ALL_ON PORTC &= ~(1 << 4); PORTC &= ~(1 << 6); PORTC &= ~(1 << 7);
#define LED_ALL_OFF PORTC |= (1 << 4); PORTC |= (1 << 6); PORTC |= (1 << 7);
#else
#define LED_GREEN_ON PORTC |= (1 << 7);
#define LED_GREEN_OFF PORTC &= ~(1 << 7);
#define LED_BLUE_ON PORTC |= (1 << 6);
#define LED_BLUE_OFF PORTC &= ~(1 << 6);
#define LED_RED_ON PORTC |= (1 << 4);
#define LED_RED_OFF PORTC &= ~(1 << 4);
#define LED_ALL_ON PORTC |= (1 << 4); PORTC |= (1 << 6); PORTC |= (1 << 7);
#define LED_ALL_OFF PORTC &= ~(1 << 4); PORTC &= ~(1 << 6); PORTC &= ~(1 << 7);
#endif
#else
#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 STABLEPIN_PINMODE pinMode (31, OUTPUT);
#define STABLEPIN_ON PORTC |= (1 << 6);
#define STABLEPIN_OFF PORTC &= ~(1 << 6);
#endif
#define BUZZERPIN_PINMODE pinMode (32, OUTPUT);
#if defined PILOTLAMP
#define PL_PIN_ON PORTC |= 1<<5;
#define PL_PIN_OFF PORTC &= ~(1<<5);
#else
#define BUZZERPIN_ON PORTC |= 1<<5;
#define BUZZERPIN_OFF PORTC &= ~(1<<5);
#endif

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

Re: Led indication for voltage monitoring on AtMega

Post by Hamburger »

Hamburger wrote:Low voltage triggers alarm handling. Alarm uses buzzer for signaling.
So best search for buzzer/beeper pin or override its default.

Enable in config.h
Find Pin for mega in def.h

brewski
Posts: 483
Joined: Tue Apr 29, 2014 12:04 am
Location: Cleveland Qld Australia

Re: Led indication for voltage monitoring on AtMega

Post by brewski »

Hamburger wrote:
Hamburger wrote:Low voltage triggers alarm handling. Alarm uses buzzer for signaling.
So best search for buzzer/beeper pin or override its default.

Enable in config.h
Find Pin for mega in def.h


I see Lipo alarm is pin32 in Def.h but without a schematic of my Crius AIOP V2 (& boy I've tried searching) it is very difficult to determine if this pin comes to header or not. Does anyone have a schematic diagram for this board?

Post Reply