auto acknowledge failed with nrf24L01+ and arduino uno

my transceivers are running fine. i 've written a few code and got them running.then i decided to check the auto acknowledgement feature wherein we can return data back to the sender WITHOUT manually changing the radio modes on both units.but i find that the serial monitor always shows “failed to transmit”.why is this happening cause otherwise they work fine.
it is a very simple code that just transmits integers.
i am using maniacbug’s RF24master library.
the Tx code is-

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>

int msg[1] = {1};
int rec[1] = {0};
bool stat = true;
RF24 radio(9,10);
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};

void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(1000);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  radio.openWritingPipe(pipe[0]);
  radio.setRetries(15,15);
 }
void loop()
{
  if(stat)
  {
    radio.stopListening();
    bool ok = radio.write(msg,sizeof(msg));
    delay(100);
    if(ok)
    {Serial.println("transmitted successfully !!");}
    else
    {Serial.println("faileed to transmit");}
    msg[1]++;
    if(msg[1]>=200)
    {msg[1]=1;}
    stat = false;
    //delay(20);
  }
  if(!stat)
  {
    if(radio.isAckPayloadAvailable())
    {
      radio.read(rec,sizeof(rec));
      Serial.print("received ack payload is : ");
      Serial.println(rec[1]);
      stat = true;    
    }
  }

}

and the Rx part is -

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
const uint64_t pipe = 0xF0F0F0F0E1LL;
RF24 radio(9,10);
int rec[1] = {0};
int ack[1] = {1};
void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(100);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
  radio.setRetries(15,15);
}
void loop()
{
  if(radio.available())
  {
    Serial.println("payload available....");
    bool ok = radio.read(rec,sizeof(rec));
    if(ok)
    {
        Serial.println("message received !!");
        Serial.print("integer got is : ");
        Serial.println(rec[1]);
        radio.writeAckPayload(1,ack,sizeof(ack));
    }
    else
    {Serial.println("failed to receive the message");}
  }
}

well my previous tx code had a lot of bugs. i fixed them and the auto ack is happening but there is this new observation i made:
first of all my tx code is:

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
int msg[1] = {1};
int rec[1] = {5};
bool stat = true;
bool ok;
RF24 radio(9,10);
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(1000);
  //radio.setDataRate(RF24_250KBPS);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  radio.enableDynamicPayloads();
  //radio.stopListening();
  radio.openWritingPipe(pipe[0]);
  radio.setRetries(15,15);
 }
void loop()
{
  if(stat)
  {
    radio.stopListening();
    Serial.println("enteed the if loop");
    if(radio.write(msg,sizeof(msg)))
    {
      Serial.println("transmitted successfully !!");
      if(radio.isAckPayloadAvailable())
      {
        radio.read(rec,sizeof(rec));
        Serial.print("received ack payload is : ");
        Serial.println(rec[0]);
      }
      else
      {
        stat = false; //doing this completely shuts down the transmitter if an ack payload is not received !!
        Serial.println("status has become false so stop here....");
      }
      msg[0]+=3;;
    if(msg[0]>=100)
    {msg[0]=1;}
    //delay(100);
    }
    else
    {Serial.println("faileed to transmit");}
  }
}

and the rx code is(minor changes):

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
const uint64_t pipe[1]= {0xF0F0F0F0E1LL};
RF24 radio(9,10);
int rec[1] = {0};
int ack[1] = {990};
void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(100);
  //radio.setDataRate(RF24_250KBPS);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  //radio.enableDynamicPayloads();
  radio.openReadingPipe(1,pipe[0]);
  radio.startListening();
  radio.setRetries(15,15);
}
void loop()
{
  if(radio.available())
  {
    if(radio.read(rec,sizeof(rec)))
    {
      radio.writeAckPayload(1,ack,sizeof(ack));
      Serial.println("message received !!");
      Serial.print("integer got is : ");
      Serial.println(rec[0]);
    }
    else
    {Serial.println("failed to receive the message");}
  }
  /*else
  {Serial.println("payload not available");}*/
}

THE OBSERVATION :
the tx serial monitor shows this–

enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop
faileed to transmit
enteed the if loop
transmitted successfully !!
received ack payload is : 990
enteed the if loop

why is it alternating??why is it not able to transmit properly after a previous transmit??
please comment

finally a detailed solution and a video can be found -

http://wp.me/p4Mna0-3a

http://wp.me/p4Mna0-32

http://youtu.be/MOMZrCw6ql8

shantam: why is it alternating??why is it not able to transmit properly after a previous transmit?? please comment

Did you figure out the exact reason why every other transmit failed? I ran into something a bit similar myself, except that if i tried to send the same data more than once I never got an ack after the first one... changing the data, and everything was fine. I'm not using data in ack, just a plain ack.

I somehow got rid of this bug I had, but I've seen it come and go, so would rather be prepared next time it arrives.