Author Topic: device unable to enter ULP  (Read 1220 times)

ralf12

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
device unable to enter ULP
« on: February 05, 2016, 10:35:23 AM »
Dear community

my device seems unable to enter ULP

I use 2 rfduino RFD 22301, 1 for LED output, 1 with mechanical button.
Programmed with Arduino 1.6.6 (http://rfduino.com/package_rfduino166_index.json)
RfDuino version 2.3.2 installed
started with Example: /*This sketch demonstrates how to send data from a Device
to a Host in a Gazell network.
When Button A on the Device is pressed and released,the green led on the host will toggle.*/

Based on this example I tried to add the ULP() function to reduce Power.

Here is the code:
Code: [Select]
************************************************************
#include <RFduinoGZLL.h>

device_t role = DEVICE0;

// pin 3 led connected to ground with 470 Ohm in serial
// (can be turned on/off from the 2. rfduino)
int led2 = 0;
int led = 3;
// pin 5 is button input
int button = 5;

int data[1];
 
void setup() {
  pinMode(led2, OUTPUT);
  pinMode(1, INPUT_PULLDOWN);   //no floating input
  pinMode(2, INPUT_PULLDOWN);
  pinMode(led, OUTPUT);
  pinMode(4, INPUT_PULLDOWN);
 // pinMode(5, INPUT_PULLDOWN);
  pinMode(6, INPUT_PULLDOWN);
 
  // button low will be shown on the rfduino use intern pullup
  pinMode(button, INPUT_PULLUP);   //switch to ground
 
  RFduinoGZLL.txPowerLevel = -20; //Sets the transmit power to max dBm
 
  RFduinoGZLL.begin(role);
}

void loop() {
  RFduino_ULPDelay(500);
  delay(200);
  // send state to Host
  data[0] = 1;
  digitalWrite(led, HIGH);
  RFduinoGZLL.sendToHost((const char *)data,sizeof(data));
 
  RFduino_ULPDelay(500);
  delay(200);
  data[0] = 0;
  // send state to Host
  digitalWrite(led, LOW);
  RFduinoGZLL.sendToHost((const char *)data,sizeof(data));
}
*************************************************************
The power consumption (~10mA) increases while RFduino_ULPDelay(500) slightly against
the delay(200) (measured with oscilloscope).
To be sure there is no HW defect, I tried a 2. module, the same result.

Has anyone recognised such behaviour?
Has anyone an idea what caused this?
Thanks in advance

VLorz

  • RFduino Full Member
  • ***
  • Posts: 68
  • Karma: +2/-0
    • View Profile
Re: device unable to enter ULP
« Reply #1 on: February 07, 2016, 11:51:28 AM »
It is a little bit difficult to measure the current consumption with a standard oscilloscope in the case of an RFduino, assuming you are using a series 1ohm resistor your measured voltage while in ULP with the LED off will be in the micro-volts range.

Take into account the LED current consumption could be obfuscating your current consumption interpretation.

The order of your delays in the code should be inverted, try it like this:

unsigned char out_val = 0;

void loop() {
  // update value to put in the LED
  out_val ^= 1;

  // send state to Host
  digitalWrite( led, out_val );
  RFduinoGZLL.sendToHost( (const char *)out_val, sizeof(out_val) );

  // wait long enough to give it some time to send the frame (most times it will take only 5ms when at host device reach,
  // but it will take "forever" in case the host is out of reach or turned off).
  delay( 25 );

  // Go to ULP for half a second
  // uncomment this next line to reduce power consumption
  // RFduinoGZLL.end();
  RFduino_ULPDelay( 500 );

  // and uncomment this one too
  // RFduinoGZLL.begin(role);
}

See the picture attached here. Time is in ms and consumption in mA. The sequence of events is as follows:
1- System in ULP with RF Off, current is below 10uA, but my scope resolution is too poor at that level and the amplifier has an offset of +2.048V :(.
2- System in normal mode, reads data from flash, reconfigures part of the hardware.
3- Transmission begins, the pulses train is due to frequency hopping done by GZLL.
4- 3 individual frames are exchanged, all succeded, host was at reach with no other device taking data bandwidth.
5- System goes ULP again.

ralf12

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: device unable to enter ULP
« Reply #2 on: February 12, 2016, 11:14:51 PM »
Thank you very much for your response.
It was very helpful.
Specially that about connection handling.
Now I see the importance of device connection for power consumption.
If the is no connection (far distance for example) there is a ripple with ~ 600yS
on power supply (10 Ohm in serial to battery) and consumption increases to ~10 mA.
It would be interesting where to find such important background knowledge; even I have the
HW and SW description of the module and to avoid such "dead lock" which empties the battery.
Is there some kind of knowledge base available? I wonder no other seems to recognise that problem
like me.

Beside, I measured without connected LED and with DVM the current, only for documentation I appended the osci picture.

Thank you and further success

Ralf

VLorz

  • RFduino Full Member
  • ***
  • Posts: 68
  • Karma: +2/-0
    • View Profile
Re: device unable to enter ULP
« Reply #3 on: February 13, 2016, 02:11:11 AM »
Ralf,

I created an Arduino shield with 4 channels for current monitoring a few months ago, I was writing firmware based on the Kinetis KW01 SoC for subGHz communications and current consumption was a big concern for me. Current sensing is done using a lowR shunt resistor followed by a 20x voltage amplifier. Unfortunately, as in my design the current sensor senses current in both directions (+ and -) and the Arduino ADC is wired for unipolar conversions, its output is offset by 1.024V, something that makes a little difficult to take good captures with a standard oscilloscope (can't go down to mV range).

Information about the GZLL implementation behaviour is scarse. There is a compile-time parameter in the GZLL source code that controls this "try it forever if it fails", but source code is not available under (almost) any means, so we can not tune this feature.

I made measurements on average connection-send-receive.ack time and under good conditions (host at reach and not overloaded) packets are exchanged in less than 5ms in average for default configurations without changing the data-rate. So you could assume the host is out of reach after 10ms from invoking the xx_send function if the data received callback function is not invoked. Time to shut down and sleep then.

I perhaps could try to isolate the code I use for implementing this functionality and post it to github.

ralf12

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: device unable to enter ULP
« Reply #4 on: February 16, 2016, 01:19:21 AM »
VLorz

thank you for your attention, I'm surprised of the fast response  :).
It would be very helpful to have such code fragment, to start with.
As you know, I'm a RFDuino newbee, every support is welcome.

Your explanation "try it forever if it fails" makes me understand the randomly
flashing receiving LED. Because I decreased the Tx power to -20dB, the
transmission in a room with reflection is unstable.

I want create a simple sound/vibration detector, a few times/s sampling
and depend from amplitude, sending. A LiIon batt has to run for a while.

Have a nice time and success in your project

Ralf