Irregular Serial communication between MC and XBee


i've been working on small home automation project involving xbee nodes.
one of sensors detect if windows/doors (or whatever has door) open or close. it's simple build reed switches, gets more complicated when want run on batteries , well... want batteries last.

to save battery, i've set xbee pin sleep, controlled attiny84a @ 8mhz(initially used attiny85 @ 1mhz, realised needed more a/d pins simulate serial communication).

given door not opening , closing, specially on vacation periods, wanted make sure that, when xbee awaken mc, wait enough time able pair controller(or router) before information sent. in order control timing, decided configure xbee api end node, , use modified version (i'll that) of software serial library on attiny84a read status coming xbee. i've configured xbee rts , cts flow control, once again, managed mc.

concerning modified software serial library. in order save battery power (once again) i've put mc sleep , programmed detect pin voltages changes wake up. unfortunately software serial library making use of many pin interrupts...

code: [select]
//
// interrupt handling
//

/* static */
inline void softwareserial_mod::handle_interrupt()
{
if (active_object)
{
active_object->recv();
}
}

#if defined(pcint0_vect)
isr(pcint0_vect)
{
softwareserial_mod::handle_interrupt();
}
#endif

#if defined(pcint1_vect)
isr(pcint1_vect, isr_aliasof(pcint0_vect));
#endif

#if defined(pcint2_vect)
isr(pcint2_vect, isr_aliasof(pcint0_vect));
#endif

#if defined(pcint3_vect)
isr(pcint3_vect, isr_aliasof(pcint0_vect));
#endif



and attiny84a pin interrupts available detect pin voltages changes 2 , set possible ones used software serial. basically, commented in interrupt pin number wanted use awaking mc.

code: [select]
//
// interrupt handling
//

/* static */
inline void softwareserial_mod::handle_interrupt()
{
if (active_object)
{
active_object->recv();
}
}

#if defined(pcint0_vect)
isr(pcint0_vect)
{
softwareserial_mod::handle_interrupt();
}
#endif

// commented code *******************************
/*#if defined(pcint1_vect)
isr(pcint1_vect, isr_aliasof(pcint0_vect));
#endif*/
// **********************************************

#if defined(pcint2_vect)
isr(pcint2_vect, isr_aliasof(pcint0_vect));
#endif

#if defined(pcint3_vect)
isr(pcint3_vect, isr_aliasof(pcint0_vect));
#endif


my problem following... of times, works fine, there few times, let's 5% following behaviour:

after awaking don't serial communication indicating xbee status (although on tests "association" blinking, thus, modem associated. @ point request xbee it's status, (still within 5%) doesn't work also.

i wonder if commenting in pin interrupt in software serial library ended messing bad. seems, i'm possibly wrong, uses 1 of possibly available... , left remaining ones uncommented.

maybe need change mc 1 has dedicated serial tx/rx pins, or maybe it's else, timing read serial data sent xbee (normally wait 50 ms after waking before reading serial communication... anyway, i'm sort of controlling flow rts/cts, so...).

also 1 of latest things that's happening, that, sometimes, when move open reed switch, mc receives 2 interrupts instead of one, suggesting there voltage variation, high enough activate twice. still not clear what's happening here...

any new new idea appreciated.

thanks.



Arduino Forum > Using Arduino > Microcontrollers > Irregular Serial communication between MC and XBee


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'