Author Topic: Communication only works one way regardless of device  (Read 15693 times)

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #30 on: April 22, 2016, 07:13:34 AM »
I managed to get the RX RSSI reported correctly by changing where we go into sleep. Instead of doing it globally in setMode, I put into sleep, than standby in the beginning of receiveBegin. Like this:

setMode(RF69_MODE_SLEEP);
setMode(RF69_MODE_STANDBY);

This solves both the reception of acknowledgements problem and reports the correct signal strength.

On a happy note I don't think the range issue is related to the receiver sleeping, but I have posted a separate thread on this issue to see if someone can help me out.

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Communication only works one way regardless of device
« Reply #31 on: April 22, 2016, 07:59:13 AM »
Cool, you've solved the acknowledgements in both directions now? Looks like we have a smoking gun, there's definitely a bug with the standby to RX mode transition not fully resetting the receiver.
Mark.
Edit: You may find that call to set standby mode after the call to go to sleep is redundant, since it is now transitioning from sleep to RX the sequencer will deal with that and the set mode call will be waiting for mode ready.
« Last Edit: April 22, 2016, 08:07:23 AM by perky »

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #32 on: April 22, 2016, 08:43:58 AM »
Thanks, I will remove the extra standby and see what happens.

It still has problems with receiving messages at the node from the gateway. While it gets an acknowledgement more or less on the first try of every message from the node to the Gateway, the messages from the gateway to the node are still seldom received. If it is received, the acknowledgement back to the Gateway seems to work fine. Note that the Gateway has zero retries on the messages it sends to the node, but still, most of them should have gotten through.

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #33 on: April 22, 2016, 10:51:42 AM »
I remove the extra _SLEEP as you suggested, and as you expected, things continued to work fine.

I also figured out the problem with the node never receiving messages from the gateway. It turns out that the cycle from sending a message from the node to receiving the acknowledgement from the gateway (I have reduced the bit rate slightly, but I don't think that is the major factor) takes around one second. The node transmits messages to the Gateway every 150 to 1000 ms, which means that it transmits immediately after receiving the acknowledgement. I guess it will then discard any message it gets from the radio that is not the acknowledgement it is waiting for in sendWithRetry. Increasing the transmission interval allowed the node to receive everything from the gateway.

I'm not sure what is the cause of this long message/acknowledgement round-trip, maybe it is caused by the sleep? I thought the node will only wait a few hundred milliseconds for an acknowledgement, so I guess the delay is on the receiving side?

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Communication only works one way regardless of device
« Reply #34 on: April 22, 2016, 01:32:56 PM »
Not sure, but RF69_CSMA_LIMIT_MS is set to 1000ms, and in the sendACK routine there's this:
Code: [Select]
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone();

which waits until it can send but with a 1s timeout after which it sends anyway. This could mean that canSend() is not returning true. You could try changing  RF69_CSMA_LIMIT_MS to something much smaller to check.

Edit: This may be down to RSSI reading, I had terrible trouble with this and so did WhiteHare. WhiteHare tested a solution that works well and there's a huge thread about it somewhere (basically you need to set the RSSI threshold to below the noise floor to trigger a read, then manually reset the receiver once it triggers to start another read. The mechanism for triggering a read by writing to the RSSI_START bit does not work. There's an additional problem if it happens to start to receive a legitimate packet as well, but it's all covered in the thread).

Mark.
« Last Edit: April 22, 2016, 01:52:06 PM by perky »

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #35 on: April 22, 2016, 02:08:15 PM »
Thanks for the info. Before reading your edit I have managed to increase the RSSI threshold after noticing that the irises I reported while waiting was -67. Setting the threshold at -60 allowed it to send its packet immediately without waiting a second.

I will read your edit once more and see if I can figure out what you're saying.

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #36 on: April 22, 2016, 02:38:11 PM »
I think I found the thread (https://lowpowerlab.com/forum/index.php/topic,1468.15.html). However, I think my RSSI readings are correct. A plug my node into my laptop and walked around the house and I saw values varying between -60 and -85. Apparently I have a very noisy RF environment. It could be because I have a z-wave network throughout the house. Is it possible/legal/recommended to nudge the moteino frequency up or down a bit?

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Communication only works one way regardless of device
« Reply #37 on: April 22, 2016, 03:28:38 PM »
Have you tried a different power supply? Better yet run both moteinos from batteries and check if that changes anything. If your noise level is above the csma level that will cause huge problems.

I've generally found the csma code to be more trouble than useful and I often just turn it off.

You can certainly detune the radio. But I doubt that an active Rf signal would regularly cause 1s csma failures. I think it's likely noise that comes in via the power supply.

kolaf

  • NewMember
  • *
  • Posts: 30
  • Country: no
Re: Communication only works one way regardless of device
« Reply #38 on: April 22, 2016, 04:07:43 PM »
Thanks for the suggestion, but how will I see what happens if I do not connect them to my computers? I connected one to my laptop without external power, but that didn't help. I'm using the USB moteino as my PC gateway which means that it has to be powered by the computer, or can I do something to cut the power connection? I guess the same goes for the FTDI adapter I use, I could cut the power coming through it, but will that really help as long as the serial lines are connected?

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Communication only works one way regardless of device
« Reply #39 on: April 22, 2016, 04:21:27 PM »
Quote
Thanks for the suggestion, but how will I see what happens if I do not connect them to my computers?

Tricky, isn't it? Here's what I do: I run tests between two battery powered Moteinos and report the results back to a third Moteino that's connected to a computer. Well actually I send the results to my esp8266 based gw which forwards it to a syslog daemon on one of my servers - but that's a story for another day.

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Communication only works one way regardless of device
« Reply #40 on: April 22, 2016, 04:50:59 PM »
It's unlikely that noise is happening at that kind of level for a full second with no gaps IMO. There are serious issues with the mechanism for reading the RSSI using RSSI_START (it's even been commented out of the RadioHead library with a comment stating the author couldn't get it to work properly), it simply doesn't work reliably (sometimes it gets frozen and reads the same value over and over again for example). That thread you saw (https://lowpowerlab.com/forum/index.php/topic,1468.15.html) has the details, and a fix.
Mark.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Communication only works one way regardless of device
« Reply #41 on: April 22, 2016, 04:54:37 PM »
@Kolaf You can also write the results to the winbond flash memory and review them sometime later.  I did that when taking RSSI noise measurements inside a sealed metal box. 

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Communication only works one way regardless of device
« Reply #42 on: April 22, 2016, 05:48:57 PM »
Sorry I didn't remember this earlier, but would another option for you to consider/investigate be to go into FS mode and shift from there back into Rx mode instead of first going into either idle mode or sleep mode and then (whichever one you pick) from there back to Rx mode?  Moving from FS mode back into Rx mode should make for a faster transition, because the latter two modes (idle or sleep) require traversing FS mode before getting back to Rx mode anyway (the sequencer just does it automatically, so it may not be glaringly obvious that's what's actually happening):  https://lowpowerlab.com/forum/index.php/topic,1468.msg11711.html#msg11711

Instead of going into sleep mode, perhaps that would more efficiently work around the smoking gun bug you may have discovered?  I was tempted to consider it anyway, just because it seems like it would be faster.
« Last Edit: April 22, 2016, 06:01:38 PM by WhiteHare »

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Communication only works one way regardless of device
« Reply #43 on: April 23, 2016, 06:51:21 AM »
Given it appears going from standby into RX doesn't seem to work correctly and that would transition through the FS state in the sequencer, while going from sleep to RX mode does I don't think it would work. I tried lots of things, including issuing a restart, with no effect (can't remember if I explicitly tried that one). I'm not sure what the failing mechanism is but it looks like the firing up of the oscillator and subsequent deep reset of internal logic has something to do with it. Anyway, it would be a good thing to reduce this to a very simple failing scenario and find out if there's any other solution than sleeping.
Mark.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Communication only works one way regardless of device
« Reply #44 on: April 23, 2016, 08:50:58 AM »
@kolaf How long ago did you acquire the RFM69HW modules?

« Last Edit: April 23, 2016, 11:15:01 AM by WhiteHare »