Author Topic: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?  (Read 106 times)

martin7743

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
I am using 2 Simblee devices (sparkfun breakoutboards) and want to establish a power efficient wireless communication via SimbleeCOM between them.
Therefore I used the 2 standard sample sketches for sending and receiving via SimbleeCOM.
The first device ist continuously sending every second and the other devices continuously receiving.
Everything works but is using a lot of power.
So a modified the sending part by changing the loop to: 
Code: [Select]
void loop()
{
 SimbleeCOM.begin();
 SimbleeCOM.send(payload, sizeof(payload));
 SimbleeCOM.end();
 Simblee_ULPDelay(1000); 
}

Everything still works fine!

But if trying a similar power saving trick with the receiving part, the SimbleeCOM_onReceive callback is never called.
(see the complete receiving sketch below)

Code: [Select]
#include<SimbleeCOM.h>

void setup()
{
 pinMode(2, OUTPUT); //this is the red LED (sparkfun simblee breakoutboard)
 SimbleeCOM.mode = LOW_LATENCY;
 SimbleeCOM.begin();
}

void loop()
{
  Simblee_ULPDelay(1000); //without this line everything works
}

void SimbleeCOM_onReceive(unsigned int esn, const char *payload, int len, int rssi)
{
 digitalWrite(2, HIGH);
}

So I am asking, is this normal desired behaviour or a bug or am I doing something wrong?

Best regards,
Martin

Wayne

  • RFduino Jr. Member
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #1 on: December 06, 2017, 06:07:09 AM »
I think with the delay in the loop it is in always delay.  The loop runs really fast and always sees the delay being set to 1000. 
In the receiver, that is the issue.  Every time the loop loops, it refreshes the delay.  The receiver never gets to function.  Thats why when you remove the ulpdelay it works.

Or it can be that your timing of 1000 ms are not syncing with each other.

U have never did a UPLDelay in time, my stuff has been with pinwakes and my receiver is always on. So, if the loop is the issue or not.. Not sure.  By the way loops goes, I'm thinking it can be resetting the 1000ms and or sync issue.

martin7743

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #2 on: December 06, 2017, 07:06:09 AM »
Hi Wayne,

thanks for your answer!
But I think this is the way how these Radio Callbacks should work! By interrupting the main loop.
If I use a regular "delay(1000)" everything works. But this does not help in powersaving.

If I am doing this Simblee_ULPDelay - "power saving trick" with the SimbleeBLE callback functions, everything works as supposed.

So "SimbleeBLE_onReceive(char *data, int len)" callback works during Simblee_ULPDelay and "SimbleeCOM_onReceive(unsigned int esn, const char *payload, int len, int rssi)" callback does not work.

Best regards,
Martin
 

Wayne

  • RFduino Jr. Member
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #3 on: December 06, 2017, 09:08:03 AM »
Yup, you are right about that callback on receive.  I keep forgetting that.. as much as I look at my own program, it always escapes my thinking.
can you attache the complete send program..

martin7743

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #4 on: December 06, 2017, 09:49:28 AM »
Sure, here is the sending part:

Code: [Select]
#include<SimbleeCOM.h>

char payload[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

void setup()
{
 SimbleeCOM.mode = LOW_LATENCY;
}

void loop()
{
 SimbleeCOM.begin();
 SimbleeCOM.send(payload, sizeof(payload));
 SimbleeCOM.end();
 Simblee_ULPDelay(1000); 
}

Wayne

  • RFduino Jr. Member
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #5 on: December 06, 2017, 12:07:16 PM »
Maybe try Delay(SECONDS(1));  ???

martin7743

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #6 on: December 08, 2017, 06:34:16 AM »
I did some current measurements to see if ULPDelay() is maybe stopping the SimbleeCom activities.
But now I am really confused!
I used the "Simblee COM Receiver"-sketch as posted and modified some lines.

These are my results:

- SimbleeCom.begin() with delay() loop: ~3.7mA
- delay() loop alone: ~ 4.2mA
- SimbleeCom.begin() with Simblee_ULPDelay() loop: ~3.7mA
- Simblee_ULPDelay() loop alone: ~5µA

So, during ULPDelay the same current is drawn as with delay(), but the callback does not work in the case of ULPDelay() but works with delay().
But there is more:

- if SimbleeCom.end() is called, the current consumption stays unchanged!
  So once called, you come never back to power saving ULPDelay()!
- all these measurements were done with the "void SimbleeCOM_onReceive" Callback present in the sketch. If this callback code is removed,    Simblee_ULPDelay() seems to work!

So this is a serious limitation for all battery powered applications. Instead of consuming 5µA most of the time, nearly 4mA are drawn!
Can anyone confirm this?
I cannot believe, that this is the desired behaviour of the SimbleeCOM.
So any help/input/ideas are welcome!  :D


Wayne

  • RFduino Jr. Member
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #7 on: December 08, 2017, 09:27:02 AM »
Well, In my case i'm using a wireless foot switch and a receiver.
The receiver has power all the time and is not on a battery source.
The foot switch is using 2 batteries (AA) with out the DC-DC converter.

The software uses a LOW action to wake up the simblee.  Reason is that I found out going HIGH ad issues on EMF.  Around the cell phone range, the device triggered. Not good.
So the input lines are HI all the time.

I start the SimbleeCOM.begin() in startup.  So right off the bat current is around 4ma.  But we ask if they press a button (battery test) to check battery each day. If the battery is low,
RED LED will light during the button press and goes of once release. The Receiver has a RED LED and will light and stay on if battery is low. Will relight if power is restored from off.

When any buttons are press, I send the signal that it relates too and a END signal when the button is release. After that I do a Simblee_systemOff().
At this point the Simblee goes into a deep sleep and draws ~400na.
I could never put in the loop the Simblee_systemOff(), for I had issues.  Otherwise I would draw 400na at the get go.
Of course, if I worked on the program more, I could probably fix the issues I have with the current.

Again, I have no DC-DC converter.  I work with the AA batteries voltage in series to about a trigger around 2 volts as a switch for the RED LED.
Any button press also tests the battery voltage. 
This is a medical switch unit and it does not send a medical signal for battery button test.

tolson

  • Global Moderator
  • *****
  • Posts: 870
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #8 on: December 08, 2017, 12:44:33 PM »
Hopefully somebody from the RF Digital team will respond with an explanation of what is going on,

martin7743

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: SimbleeCOM_onReceive callback not working under Simblee_ULPDelay?
« Reply #9 on: December 12, 2017, 03:47:50 AM »
Some additional information to my measurements above:
- I have removed the power hungry ADP160 regulator from the Sparkfun breakoutboard before. So the current measurements should be identical to the bare simblee chip. (eveything works fine with BLE)

- Arduino version 1.8.2
- Simblee version 1.1.2

I am still curious. Can anyone confirm that SimbleeCOM consumes power if a receiving callback is present, even if stopped with SimbleeCOM.end()? So no coin cell operation possible on the receiver side?
Is there a workaround or fix with low level functions?

Thanks in advance,
Martin

 

anything