Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

nRF24AP2 question

Rank

Total Posts: 5

Joined 2013-02-24

PM

Hi, ererybody. I'm working with nRF24AP2 module in asynchronous mode. And i get comfused about something.
Here is my problem.

1, What does RTS signal use for in asynchronous mode, it seens useless. I set RTS to low in the whole time, is that right?

2, How the host know the ANT have received data fromm remote node? And how the ANT module will react when
it receive data from the other ANT node?
     
Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi,

The RTS signal is very important, particularly for the nRF24AP2. It is controlled by ANT, not the MCU, and signals when ANT is "busy" and cannot accept any new messages or signals at that moment.

Only once RTS is de-asserted by the module should you send any messages or assert/de-assert the SLEEP line, otherwise messages may be missed/interfered with.

ANT sends any received messages from other wireless nodes immediately to the host, so for instance if ANT receives a broadcast message from a remote sensor, the host MCU will immediately be sent the broadcast message.

For example:
[A4][09][4E][00][00][00][00][00][00][00][00][00][E3] //UART, Broadcast, Ch 0, Payload 00-00-00-00-00-00-00-00

You may enable extended messaging to see, among other things, the device ID details of the remote node which broadcast that message.

Cheers      
Rank

Total Posts: 5

Joined 2013-02-24

PM

Hi, Harrison. Thanks for the reply. It turns out that my message length is wrong.
Now the connection between host and ANT seens all right. Every message the host sent to ANT got reply properly.
But in the slave node, the host could not read any data from master.
How do the host know there is data should read from ANT. I set a dead loop to read from the ANT after the open channel message had been sent, is that right?
How do i confirm the connection between master and slave had been setup?
Here is my main.c. Any advice would be great.
#define SYNC_BYTE 0xA4
uint8 system_reset_msg[3]={0x010x4A0x00};
uint8 channel_status_msg[4]={0x020x520x000x00};
uint8 channel_open_msg[3]={0x010x4B0x00};
uint8 channel_unassign_msg[3]={0x010x410x00};

uint8 channel_brdcst_data_msg_master[11]={0x090x4E0xDD0xDD0xDD0xDD0xDD0xDD0xDD0xDD0xDD};

uint8 channel_assign_msg_master[5]={0x030x420x000x100x00};
uint8 channel_id_msg_master[7]={0x050x510x000x310x000x010x03}
uint8 channel_period_msg_master[5]={0x030x430x000x000x10};
uint8 channel_freq_msg_master[4]={0x020x450x000x00}

uint8 channel_assign_msg_slave[5]={0x030x420x000x000x00};
uint8 channel_id_msg_slave[7]={0x050x510x000x310x000x010x03}
uint8 channel_period_msg_slave[5]={0x030x430x000x000x10};
uint8 channel_freq_msg_slave[4]={0x020x450x000x00};

uint8 ant_init(void)
{
 GPIO_Enable
(136);
 
GPIO_SetDirection(136SCI_FALSE);//set RTS as input

 
SCI_Sleep(100);
 
 
ant_ComInit(COM_0);

 
SCI_Sleep(100);

 return 
0;
}

//check the RTS signal to see whether the ANT is ready to receive message
BOOLEAN ant_is_busy(void)
{
 BOOLEAN gpio_value
;

 
gpio_value GPIO_GetValue(136);

 if(
gpio_value == SCI_TRUE)
  return 
SCI_TRUE;
 else
  return 
SCI_FALSE;
}

uint8 ant_send_msg
(uint8 *msguint8 cnt)
{
 uint8 i
=0com_buf[128]wr_buf[128]checksum 0;

 
SCI_MEMSET(wr_buf0128);
 
checksum SYNC_BYTE;
 
wr_buf[0] SYNC_BYTE;
 for(
i=1<= cnti++)
 
{
  wr_buf[i] 
msg[i-1];
  
checksum checksum wr_buf[i];
 
}
 wr_buf[i] 
checksum;
 
 while(
ant_is_busy() == SCI_TRUE)  {;}

 ant_ComWrite
(wr_bufcnt+2);
 
SCI_Sleep(100);
 
 
SCI_MEMSET(com_buf0128);
 
ant_ComRead(com_bufsizeof(com_buf));
 
SCI_Sleep(100);

 return 
0;
}

uint8 ant_channel_setup_master
(void)
{
 ant_send_msg
(system_reset_msg3);
 
ant_send_msg(channel_assign_msg_master5);
 
ant_send_msg(channel_id_msg_master7);
 
ant_send_msg(channel_period_msg_master5);
 
ant_send_msg(channel_freq_msg_master4);
 
ant_send_msg(channel_open_msg3);
 
ant_send_msg(channel_brdcst_data_msg_master11);

 return 
0;
}

uint8 ant_channel_setup_slave
(void)
{
 uint8 i
=0com_buf[128];
 
 
ant_send_msg(system_reset_msg3);
 
ant_send_msg(channel_assign_msg_slave5);
 
ant_send_msg(channel_id_msg_slave7);
 
ant_send_msg(channel_period_msg_slave5);
 
ant_send_msg(channel_freq_msg_slave4);
 
ant_send_msg(channel_open_msg3);

 while(
1)
 
{
  SCI_MEMSET
(com_buf0128);
  
ant_ComRead(com_bufsizeof(com_buf));//here i didn't get any data
  
SCI_Sleep(100);
 
}
 
return 0;
     
Rank

Total Posts: 5

Joined 2013-02-24

PM

Here is the log data.
Master node:
TX:a4, 1, 4a, 0, ef
RX:a4, 1, 6f, 20, ea
TX:a4, 3, 42, 0, 10, 0, f5
RX:a4, 3, 40, 0, 42, 0, a5
TX:a4, 5, 51, 0, 31, 0, 1, 3, c3
RX:a4, 3, 40, 0, 51, 0, b6
TX:a4, 3, 43, 0, 0,1 0, f4
RX:a4, 3, 40, 0, 43, 0, a4
TX:a4, 2, 45, 0, 0, e3
RX:a4, 3, 40, 0, 45, 0, a2
TX:a4, 1, 4b, 0, ee
RX:a4, 3, 40, 0, 4b, 0, ac

RX:a4, 3, 40, 0, 1, 3, e5
RX:a4, 3, 40, 0, 1, 3, e5
RX:a4, 3, 40, 0, 1, 3, e5
RX:a4, 3, 40, 0, 1, 3, e5
...

Slave node:
RX:a4, 1, 6f, 81, 4b
TX:a4, 1, 4a, 0, ef
RX:a4, 1, 6f, 20, ea
TX:a4, 3, 42, 0, 0, 0, e5
RX:a4, 3, 40, 0, 42, 0, a5
TX:a4, 5, 51, 0, 31, 0, 1, 3, c3
RX:a4, 3, 40, 0, 51, 0, b6
TX:a4, 3, 43, 0, 0, 10, f4
RX:a4, 3, 40, 0, 43, 0, a4
TX:a4, 2, 45, 0, 0, e3
RX:a4, 3, 40, 0, 45, 0, a2
TX:a4, 1, 4b, 0, ee
RX:a4, 3, 40, 0, 4b, 0, ac
dead loop read here get zero.
     
Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi,

From first glance it looks like it should connect, but as I noted earlier, if the connection settings between the ANT Master and Slave channels are aligned then when it connects the ANT slave channel should immediately begin sending messages to the Host, otherwise if the slave channel never finds a master channel, it should send the host a timeout and automatically close the channel after a specific period of time.

I noticed your log did not include a time out on the slave node, did you receive it?

In order to minimize some of the possible failure points, you could set up your master channel only using the Assign Channel, Set Channel ID, Open Channel commands, and set up the slave channel using Assign Channel, Set Channel ID (All Wildcards), Open Channel, relying on the defaults for the other parameters.

Cheers      
Rank

Total Posts: 5

Joined 2013-02-24

PM

Hi Harrison, thanks for all the help. You're a really nice guy.
Now my problem solved. I make a stupid mistake, didn't set the channel id right when i broadcast data.
As you mention, i did receive the time out notification.