Go Down

Topic: Lowest consumption issue (Read 2422 times) previous topic - next topic

philgeek

Hello

When using my MKRFOX1200 supplied through 3.3V / Vin , I Can't get a lower consumption than 1.2 mA during LowPower.deepsleep(120000); instruction time (using <ArduinoLowPower.h>).

My test bench uses the simpliest hardware and software (nothing enabled, no LED ... ).

I've double checked this measure using my multimeter (very low quality) in serie (current measure) and in parallel (voltage measure) accross a 100 Ohm resistor in serie with the power supply : 120 mV drop ...

Unfortunately it is not enough efficient to be powered during monthes through a pair of AA alcaline batteries, even if my module sleeps always ... I was expecting less than 100 uA reading the Atmel SAMD data sheet ...

I could see two possible issues :

- The mkrfox1200 hardware design doesn't allow to get better results (ex. due to the clock input ... I don't know ...)
- The Arduino LowPower library doesn't do enough and could be optimized ...

As I've not got enough time to check by myself those two issues, I just hope that someone or a support can tell me what objective can be set  and how to proceed in order to get it. I wouldn't like to spend efforts targetting a non feasible objective, and some other messages on the forum are not enough conclusive on this topic ...

Sleep mode conumption parameter should be written in the MKRFOX1200 documentation, when it's said that the board can be supplied through AA batteries ...

Sorry for the English and the message form, I'm constrained by a Parkinson disease ... however compatible Arduino practice  :)

philgeek

I did a mistake in my description, sorry : the board is supplied through the battery connector and not through Vin !

philgeek

I've got a piece of information from technical support / Carla :

"After run some tests on this board, we have reached 300uA with a MKR Fox 1200, so we recommend you to update the low power library to get the improvements."


I had not yet time enough to experiment. I've seen on github a 1.2.0 version (instead of 1.0.0 in my Arduino IDE) but I can't see any major change which could improve my configuration. Anyway, I will do the comparison, for sure.

And now, I know the target/feasibility thanks to Carla.

Again, I would appreciate to get results from others. Thanks. Philippe.

philgeek

Reading the code of the low power library, I can see that the option BOARD_HAS_COMPANION_CHIP is not setup. Unfortunately this doesn't give us the capability to use the instruction LowPower.companionSleep(); and to ensure that the sigfox module by itself is set in deep sleep mode as well as the SAMD CPU.

In my test bench I did'nt initialised the sigfox module. I was expecting  the sigfox module to be its lowest consumption mode after reset. Furthermore I didn't call a SigFox.end() instruction. Maybe the mistake is there, I don't know ...

I definitively would appreciate to get support on this topic.

Please tell me anyway how you've got  happy with the lifetime of your "AA" battery back !

Philippe.

philgeek

I've updated the Arduino Low Power library to 1.2.0, I've called sigfox.end();   : I get 500 uA (+/- 100 uA) during the sleep mode. Progress, yes, but not as much as expected reading the components data sheet + MKRFOX1200 schematics.

End of my posts on that subject.














philgeek

Sorry, but I'm coming again a last time in order to provide a fruitful issue .

I've tried "to remove  the pin initialization in wiring.c", as suggested in other forums :

https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/wiring.c#L85

And now my consumtion in standby is about 50uA, difficult to be more precise with my multimeter ...

I've not seen negative side effects, anyway.

I can close the topic as SOLVED, and maybe my trials will help others ...

nimasa

@philgeek, Wiring.C file in Arduino installation folder on my computer is completely different than this one and there is no pin initialization in it. Do I have to substitute it with the one on Github?

philgeek

#7
Mar 18, 2018, 10:02 pm Last Edit: Mar 18, 2018, 10:07 pm by philgeek
Here is the updated file with comments & installation path added in the header. I hope this will help to get the low consumption figure on mkrfox1200.

Please take also into account the great benefits of a setup boost 3.3V circuit, which makes batttery life about 10 times longer. My reference is the NCP1402, and its implementation by Sparkfun.

/*
  Copyright (c) 2015 Arduino LLC.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Philgeek on www.philoc.fr
// Edited on 2018/03/17 thanks to question / my post on Arduino forum mkrfox1200/lowest consumption issue
// I just hope it can help but I cannot commit ;-)

// This file has been updated as I looked for the lowest consumption on mkrfox1200
// The modification below is tagged with "phg" embedded in the comment
// Only one line had to be placed as comment ...
// Notes :
// The path on my configuration is .arduino15/packages/arduino/hardware/samd/1..6.16/cores/arduino/wiring.c
// Notes / Prerequisites
// All unused components, and especially sigfox and usb must have been reset by your application before entering deep sleep
// And Arduino Low Power library must be in its 1.2.0 version, at least in my configuration
// Lastly check any pin configuration, be careful with pullups and leds ... but you did that already
// And at he end of the day, you should get around 50 mA, as I've got by myself ... because the data sheet figures & the mkrfox1200 schematics are done that way.
*/--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
#include "Arduino.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * System Core Clock is at 1MHz (8MHz/8) at Reset.
 * It is switched to 48MHz in the Reset Handler (startup.c)
 */
uint32_t SystemCoreClock=1000000ul ;

/*
void calibrateADC()
{
  volatile uint32_t valeur = 0;

  for(int i = 0; i < 5; ++i)
  {
    ADC->SWTRIG.bit.START = 1;
    while( ADC->INTFLAG.bit.RESRDY == 0 || ADC->STATUS.bit.SYNCBUSY == 1 )
    {
      // Waiting for a complete conversion and complete synchronization
    }

    valeur += ADC->RESULT.bit.RESULT;
  }

  valeur = valeur/5;
}*/

/*
 * Arduino Zero board initialization
 *
 * Good to know:
 *   - At reset, ResetHandler did the system clock configuration. Core is running at 48MHz.
 *   - Watchdog is disabled by default, unless someone plays with NVM User page
 *   - During reset, all PORT lines are configured as inputs with input buffers, output buffers and pull disabled.
 */
void init( void )
{
  // Set Systick to 1ms interval, common to all Cortex-M variants
  if ( SysTick_Config( SystemCoreClock / 1000 ) )
  {
    // Capture error
    while ( 1 ) ;
  }
  NVIC_SetPriority (SysTick_IRQn,  (1 << __NVIC_PRIO_BITS) - 2);  /* set Priority for Systick Interrupt (2nd lowest) */

  // Clock PORT for Digital I/O
//  PM->APBBMASK.reg |= PM_APBBMASK_PORT ;
//
//  // Clock EIC for I/O interrupts
//  PM->APBAMASK.reg |= PM_APBAMASK_EIC ;

  // Clock SERCOM for Serial
  PM->APBCMASK.reg |= PM_APBCMASK_SERCOM0 | PM_APBCMASK_SERCOM1 | PM_APBCMASK_SERCOM2 | PM_APBCMASK_SERCOM3 | PM_APBCMASK_SERCOM4 | PM_APBCMASK_SERCOM5 ;

  // Clock TC/TCC for Pulse and Analog
  PM->APBCMASK.reg |= PM_APBCMASK_TCC0 | PM_APBCMASK_TCC1 | PM_APBCMASK_TCC2 | PM_APBCMASK_TC3 | PM_APBCMASK_TC4 | PM_APBCMASK_TC5 ;

  // Clock ADC/DAC for Analog
  PM->APBCMASK.reg |= PM_APBCMASK_ADC | PM_APBCMASK_DAC ;


  // Setup all pins (digital and analog) in INPUT mode (default is nothing)
  for (uint32_t ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ )
  {
 // modification - PHG - 2017-09-13 : line below suppressed in order to get lower consumption in standby /deep sleep mode '<50uA)
//    pinMode( ul, INPUT ) ;
  }

  // Initialize Analog Controller
  // Setting clock
  while(GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);

  GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID( GCM_ADC ) | // Generic Clock ADC
                      GCLK_CLKCTRL_GEN_GCLK0     | // Generic Clock Generator 0 is source
                      GCLK_CLKCTRL_CLKEN ;

  while( ADC->STATUS.bit.SYNCBUSY == 1 );          // Wait for synchronization of registers between the clock domains

  ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV512 |    // Divide Clock by 512.
                   ADC_CTRLB_RESSEL_10BIT;         // 10 bits resolution as default

  ADC->SAMPCTRL.reg = 0x3f;                        // Set max Sampling Time Length

  while( ADC->STATUS.bit.SYNCBUSY == 1 );          // Wait for synchronization of registers between the clock domains

  ADC->INPUTCTRL.reg = ADC_INPUTCTRL_MUXNEG_GND;   // No Negative input (Internal Ground)

  // Averaging (see datasheet table in AVGCTRL register description)
  ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 |    // 1 sample only (no oversampling nor averaging)
                     ADC_AVGCTRL_ADJRES(0x0ul);   // Adjusting result by 0

  analogReference( AR_DEFAULT ) ; // Analog Reference is AREF pin (3.3v)

  // Initialize DAC
  // Setting clock
  while ( GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY );
  GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID( GCM_DAC ) | // Generic Clock ADC
                      GCLK_CLKCTRL_GEN_GCLK0     | // Generic Clock Generator 0 is source
                      GCLK_CLKCTRL_CLKEN ;

  while ( DAC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization of registers between the clock domains
  DAC->CTRLB.reg = DAC_CTRLB_REFSEL_AVCC | // Using the 3.3V reference
                   DAC_CTRLB_EOEN ;        // External Output Enable (Vout)
}

#ifdef __cplusplus
}
#endif

Go Up