Go Down

Topic: Arduino Due Power Management (Read 1 time) previous topic - next topic

sj_arduino

Jan 14, 2015, 09:14 pm Last Edit: Jan 14, 2015, 09:14 pm by sj_arduino
Can someone provide Arduino Due code to disable unused IOs, clocks, ADCs etc to save power?
I am using a single sensor with Arduino Due, and trying to shut off everything else.

I looked under "C:\Program Files (x86)\Arduino\hardware\arduino\sam\system\libsam\include" for pmc.c/pmc.h but can't find something useful quikly to save power or do power management.

thanks

Steamboat

Hello sj_arduino

I am looking for exact the same thing. Is there any "DUE micro" type PCB on the market with not much more than the SAM3X and a DC/DC converter on it. For a battery powered Arduino project I would like to save as much power as possible but still have the power of this chip when it is needed ...

Rainer
from Germany
Rainer from Germany
wood-walker.org

MarkT

#2
Feb 05, 2015, 07:24 pm Last Edit: Feb 05, 2015, 07:24 pm by MarkT
I doubt it, the chip requires a lot of support components from what I can see.  There
are other ARM based microcontrollers with smaller pin-counts which would be much
more appropriate than the SAM3X.  The Teensy 3.x boards perhaps?

Alas the learning curve is a lot steeper for the SAM3X than the AVRs - the datasheet is
comprehensive but huge.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Steamboat

#3
Feb 06, 2015, 12:42 am Last Edit: Feb 06, 2015, 12:48 am by Steamboat
I did some power consumption trials. Opened the connection between 3.3 Volt main line direct behind the 3.3 Volt regulator IC4. Into this cut I soldered a 2 pin header to use a jumper for normal use or a wire for mA measurements.




In normal operation the bare 3.3 Volt part is using 136 mA. Because I am measuring in the 3.3 Volt line behind the regulator we do not see the 5 Volt consumption of the 16U2 and the loss of the regulator. It'S the bare SAM3X8 usage including all the DUE cirquite losses in the 3.3 Volt line.



In the documentation I found two nice codes by try and error:
pmc_mck_set_prescaler(254);
sets the clock prescaler to 254 = the max value to slow the clock down.
This brings my reading down to 66 mA

When adding this nice code:
pmc_disable_all_periph_clk();
You will disable all peripherial clocks - including the USB clock ;-)

I used this bare code:

Code: [Select]
int i = 0;
void setup() {
  pmc_mck_set_prescaler(254);
  pmc_disable_all_periph_clk();
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(10);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(10);
  i++;
  if (i > 30) {
    pmc_enable_all_periph_clk();
    i= 31;
  }


The LED did 30 blinks but stopped after that and I could not get the USB port up again. Had to erase the memory again.
Could anybody please explain how to get it up again. I would love to switch down everything like this because I got a 19 mA reading while the blinking was still working:



Rainer from Hannover, Germany
www.steamboating.de

PS:
you don'T need much peripherials to operate a bare SAM3X8. Most of the stuff on the DUE is nice to have or for making programming easier...




Rainer from Germany
wood-walker.org

Steamboat

Hello Forum

Can't get up a serial communication after disabling and enabling the peripherial clocks.
Code: [Select]

void setup() {
 pmc_disable_all_periph_clk();
 delay(10000);     
 pmc_enable_all_periph_clk();
 delay(10);
 Serial.begin(9600);
}
void loop() {
   Serial.println("alive");
   delay(500);
}

What is wrong with this code.
Why is the USB conection influenced by the peripherial clock? According to the Block Diagramm Figure 29-6 in the datasheet this are two different clocks?

This code on other hand works for me and saves some juice...
Code: [Select]

void setup() {
  pmc_disable_udpck(); //switch off USB clock
  delay(5000);             //saves about 0.5 - 1.5 mA in the 3.3 Volt line of the DUE
  pmc_enable_udpck(); //switch on USB clock
 Serial.begin(9600);
}
void loop() {
   Serial.println("alive");
   delay(500);
}


Rainer from Germany
wood-walker.org

Go Up