Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

ANT broadcast RX and TX in a single device

Rank

Total Posts: 7

Joined 2020-10-16

PM

Hello,
I'm new to ANT and I having been testing ANT examples in the Nordic SDK 16.0.

I have seen that there are TX and RX broadcast channel initialization separately. Is there a way to we can setup a device as transmitter as well as receiver with both channel types?

I have tried to setup two channels, one transmitter, other receiver in a single project and it throws errors.

The basic concept is that device receive data on RX channel and retransmits to all devices in field using TX channel (with an incremented message ID).

I have also seen the multichannel example, but that too is with single type of channel either TX or RX.

Thanks.      
RankRankRankRank

Total Posts: 210

Joined 2012-06-27

PM

Yes you can open multiple channels on a single device, and they can be a mix of master and slave channels. Please share code and/or the error you are seeing to help determine what your issue is.

There are also bidirectional channels, which support a response message from slave to master. However, it sounds like you want two separate channels for your use case.      

Signature

Ian Haigh

Rank

Total Posts: 7

Joined 2020-10-16

PM

Hi,
Thanks for reply.

The idea is that a device can send and receive messages at the same time.

I was able to use two channel, error was removed by incrementing NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED in the sdk_config.h file. I am checking data reliability with this setup.

I have also tried single bidirectional channel. There are certain issues though:

1. I reply in the EVENT_RX whenever data received from master, however, the actual data received is half that of sent from slave. The master misses every other packet. Say I'm sending packet 1, 2, 3, 4, 5, 6, ....; the master receives 2, 4, 6, 8, .....
2. What is right time for slave to send data back to master? It seems like there are data collisions in the air while sending back the data which cause master to miss some of the data.
3. Do the channel period has be same to send/receive data in this given scenario?

Please check the logs I got in a master/slave arrangement while I reply to master on EVENT_RX or default event in the ant_evt_handler() function.      

File Attachments

Rank

Total Posts: 7

Joined 2020-10-16

PM

Hi,
I did some testing using two channel with master and slave. The master send an 8 byte data packet to slave and slave returns it back to the master. Every time master sends data to slave, it increments first byte. The logs are taken at channel periods of 20ms and 50ms. I can still see packets missing. I wonder why data reliability is not improving despite using separate channels for Tx and Rx.
See attached files.      

File Attachments

Rank

Total Posts: 7

Joined 2020-10-16

PM

tested two more settings

#1:
Device 1: Master freq=66Mhz, slave freq=76Mhz
Device 2: Master freq=76Mhz, slave freq=66Mhz

#2:
Device 1: Master ch period=328, slave ch period=496
Device 2: Master ch period=496, slave ch period=328

No improvement in performance.      
RankRankRankRank

Total Posts: 210

Joined 2012-06-27

PM

Bidirectional channel: You have to send the message to the radio before the rx for the channel period you want the message to go out. You can send 1 backchannel message per channel period.

Radio Rx A
Radio Tx B
Rx event C
Send backchannel message to radio D

ABCD ABCD ABCD

Note: Spacing between sets is much greater than set duration for normal channel periods and system latencies. You are using a very short channel period beyond what is normal for ANT, so this may not hold for your case. Your system latencies around communication with the radio may be causing the backchannel message to the radio to fall more than a channel period after the radio rx. Typical channel periods are 8192, or 4096 for most ANT+ profiles.

Radios can only operate on a single channel during the tx and rx window. If you have more than one channel, then you should choose the channel periods to match, so that the two channel periods are phase offset. Alternatively you can have them offset significantly, so that the two channel periods sweep across each other rapidly. When you choose two channel periods that are very close to one another, then the two channels can slowly drift across conflicts for the same airtime. The stack tries to resolve this issue, but is not always able to. You will get a channel collision event when the stack is unable to handle one of the channels.

When you are testing the bidirectional channel, do you have another channel established on your device, or another device in the vicinity with ANT (other than the device on the other side of the channel)? Just as two channels on a single device can fight over airtime, so too can multiple devices on the same channel parameters. The stack tries to detect other devices on the same channel parameters and shift the transmit and receive windows, but again is not always able to prevent interference.      

Signature

Ian Haigh

RankRankRankRank

Total Posts: 210

Joined 2012-06-27

PM

Since you are seeing every second channel period missing, and not sporadic issues, I suspect that you are trying to use a channel period higher than your system latency can support. Are you using an SOC solution, or a radio network processor separate from the processor you are setting up messages with? If the former, then you may need to increase the priority of ANT event handling, or shift unrelated processing to a lower priority. If you are using the latter, then you may need to switch to an SOC solution.      

Signature

Ian Haigh

Rank

Total Posts: 7

Joined 2020-10-16

PM

Hi,
Thanks for the reply.
I am using Nordic SoC (nRF52840) for this development so I guess I need to adjust task priorities to get better results.

About the back channel message analogy I don't fully understand (the ABCD analogy).

Say I am using a bidirectional channel. I come to know that a message is received by a slave through EVENT_RX event. Now I want to send a reply to the master.
1) Should I reply in the same EVENT_RX, or reply should be in EVENT_TX?
2) A reply should also be called by sd_ant_broadcast_message_tx() function? or a different functional call is used?

In our application, we want to use single master and multiple slaves. The slaves send periodic data to the master. The master can also send a command to a) all the slaves, b) any one of the slave. I assume this can be done by setting message byte 0 with address of device. 0=> all devices, 1-any=> specific device (multicast vs unicast).

I have studied shared addresses but cannot find an example of it (only advanced sharing in the experimental folder which seems too complicated for our application).

1) Does changing CHANNEL_TYPE_MASTER to CHANNEL_TYPE_SAHRED_MASTER make it shared channel or there are some other settings/config as well?
2) How does master know addresses of slaves in the field? For unicast we need to know address of all slaves in the field.      
RankRankRankRank

Total Posts: 210

Joined 2012-06-27

PM

You will want to send your reverse direction (backchannel) message to the radio in response to EVENT_RX. This is the event that you get every time a message is received by the slave. What I am pointing out is that the backchannel message will not actually get sent as a response to that received message, but as a response to the next received message. By the time you have received the EVENT_RX the radio has either replied with the backchannel message it had pending prior to receiving the message from the master, or has not sent a backchannel message because none was pending.

sd_ant_broadcast_message_tx is used for both the master and bidirectional slave. Acknowledged messages are also possible with sd_ant_acknowledge_message_tx, and burst messages with sd_ant_burst_handler_request.

If you want to send periodic data from what you have as ANT slave to ANT master, and the rate of commands is allowed to be lower than the periodic data rate, then you may want to swap which is master and which is slave. If the command rate is typically much lower than the periodic data rate then this is a much better approach. ANT works most efficiently when sending periodic data from the master to the slave. If the number of masters is small, then the slave can open up a channel for each master. If the number of masters is large, then a scanning slave should be used. The slave can send a command in response to each received message, but some will fail due to RF conditions. A slave that wishes to send a command to multiple masters must send a message to each master independently.

If you would need to implement a scanning slave, but the power consumption of scanning is too high, then a shared channel is an option. What would have been a scanning slave becomes a shared channel master. With shared channels the slaves are polled by the master. The master sends a message to the slave by address, and the slave can respond. This means that commands based on data received from the slave must wait until the next time that slave is polled. The master can send a message to all slaves (address 0), but they cannot respond in this case. See section 5.6 of the ANT Message Protocol and Usage document (https://www.thisisant.com/resources/ant-message-protocol-and-usage/). Note: This shared channels may not be more power efficient than a scanning channel if you have very short channel periods and don't send a new command each time data is polled. With the scanning channel the radio is spending a lot of time receiving. With the shared channel it is spending time sending and receiving. The power spent by the shared master sending is only useful if it is more than a simple polling command, and would have been similarly spent on backchannel messages from the scanning slave.

All that is required for shared channels is to set the channel type using CHANNEL_TYPE_SHARED_SLAVE or CHANNEL_TYPE_SHARED_MASTER from the nRF SDK, and for slaves to send a broadcast message to the radio to set the shared address. https://www.thisisant.com/resources/an07-auto-shared-channel-master-example/ has a PC based example. ANT Message protocol and Usage section 5.6 and 8.2 will be very useful.

Addresses of slaves on the shared channel are out of the scope of ANT. They are usually handled through a one time setup tool, or by discovering devices broadcasting as an ANT master and assigning them shared addresses and commanding them to join the shared channel over the channel they are a master on.      

Signature

Ian Haigh

Rank

Total Posts: 7

Joined 2020-10-16

PM

Thank you very much for the detailed reply. I will try this options and share the results.