Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Sleep mode on: April 12, 2013, 10:05:37 am
OK,
thanks a lot!
2  Using Arduino / Programming Questions / Re: Sleep mode on: April 12, 2013, 09:40:45 am
Thanks a lot for all this suggestions, I'll put in practice the whole. Just tell me one more info: where is written that the interrupt mode set to falling is'n allowed in sleep mode? In your previous post you tell about page 72 of atmega328 datasheets, but I can't find such indication there.
3  Using Arduino / Programming Questions / Re: Sleep mode on: April 12, 2013, 07:35:26 am
I really don't understand well this issue, how can the clock sample the interrupt pin if while the mcu is sleeping  in power down mode all the clocks are off ? I suppose the wake-up is asyncronous.
Anyway my problem is not to wake-up the mcu, it wakes up regularly, the problem is that if I keep low the interrupt pin, mcu continues to drain current, even if it's in sleep mode. The wake-up signal comes out from the 1/32 Hz square wave output of a real time clock, and the square wave wake-up the mcu but stays low for 16 seconds. A solution could be to put a monostable ( 1/2 74HC123) between real time clock and mcu, but I would like to know why mcu drains this current, just to find a better solution.
Thanks for any suggesting.
4  Using Arduino / Programming Questions / Re: Sleep mode on: April 12, 2013, 05:48:19 am
Sorry dc42 I didn't see your second post, I've read it just now.
I use interrupt on pin 0 of Arduino Leonardo, this mean INT2 on atmega32U4 and for what I know it's possible to have an interrupt on falling edge of signal ( External Interrupt Control Register A – EICRA). Isn't true?
5  Using Arduino / Programming Questions / Re: Sleep mode on: April 11, 2013, 04:20:52 am
sleepNow() listing:

Code:
void sleepNow()         // here we put the arduino to sleep
{
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();       
    sleep_mode();       
    sleep_disable();
}

in power down sleep mode all the cloks should be disabled.
and I've disabled brown-out by fuses.

The problem is not how much current it drains, my question is: why it doesn't really go in sleep mode until the digital input 0 stay low?

Thanks anyway,
A.
6  Using Arduino / Programming Questions / Re: Sleep mode on: April 11, 2013, 02:27:39 am
I've found something more.
The current comsumption is high until the interrupt signal from real time clock stays at low level.
The interrupt change level any 32 seconds and  so the current draw last for 16 seconds.
What I can't understand is why this happens. The attachInterrupt() function is set as FALLING, the interrupt code runs once any 32 seconds but the sleep mode drains current until pin 0 remain low.
Any idea?
7  Using Arduino / Programming Questions / Re: Sleep mode on: April 09, 2013, 04:35:57 am
Tsens is 2,  at the moment I'm using only 2 sensors. The whole setup runs in about 740 mS, 2.5seconds if I consider the software delay()s. 1-wire bus is quite slow.
The current comsumption in sleep mode really looks too high considering I've removed the 5V regulator and power green led on board. And is not a matter of bus or SD card because 1.69 mA drops down to  1.49 if I remove SD card and 1 wire bus sensors, only  a 200uA difference.
Anyway  nothing on this card can draw current except real time clock chip who needs only few uAmps.
8  Using Arduino / Programming Questions / Re: Sleep mode on: April 09, 2013, 03:46:14 am
I forgot :  the loop is complete I removed only part of the setup, it run only once and initilizes sd card and sensors on 1-wire bus.

A.
9  Using Arduino / Programming Questions / Re: Sleep mode on: April 09, 2013, 02:19:04 am
You are right!
This is all the code regarding sleep & wake up :

Code:

void setup(void)
{
pinMode(MOSI, OUTPUT);
  pinMode(SCK, OUTPUT);
  pinMode(MISO, INPUT);
  pinMode(0, INPUT_PULLUP);  // RTC IRQ
  pinMode(1, INPUT_PULLUP);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, INPUT);  // 1-WIRE
  pinMode(5, OUTPUT); // LED 1
  pinMode(6, OUTPUT); // LED 2 
  .........
  .........
  attachInterrupt(0,wakeUpNow,FALLING);
}

void wakeUpNow()        // here the interrupt is handled after wakeup
{
  ++sample;
}

void sleepNow()         // here we put the arduino to sleep
{
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();       
    sleep_mode();       
    sleep_disable();
}


void loop(void)
{
  digitalWrite(gLed,HIGH);
  sensors.requestTemperatures();
 
  delay(3);
  File dataFile = SD.open(filename, FILE_WRITE);
  if (dataFile)
  {
  for (byte n=0; n<tsens; n++)
     {
      float tempC = sensors.getTempC(temp[n]); 
      dataFile.print(tempC);
      dataFile.print("; ");     
     }
     dataFile.println();
     dataFile.close();
  } 
  digitalWrite(gLed,LOW); 
  while (sample<samplemax)
  {       
   delay(10);
   sleepNow(); 
   if (digitalRead(A0)==LOW) 
  {     
    digitalWrite(yLed,HIGH); 
    while (digitalRead(A0)==LOW) {}
    digitalWrite(yLed,LOW);
  } 
  }
  sample=0;
}
10  Using Arduino / Programming Questions / Sleep mode on: April 08, 2013, 11:07:16 am

Hi all,
I'm setting up a new low power project based on Arduino Leonardo and I find some problem putting Arduino in sleep mode. I'm using the lowest consumption sleep mode, SLEEP_MODE_PWR_DOWN, from sleep.h library  and I measure the current draw from supply drops down to about 1.6mA only after about 15 seconds I execute the sleepNow() function. Before sleepNow(), the currunt is about 35 mA, that I suppose is a normal value. The board wakes up regularly, the problem is only this strange delay for the sleep mode  become effective.
Thanks for any suggestion.

Alebit.
11  Using Arduino / Programming Questions / Re: Timer programming on: October 08, 2012, 10:23:43 am
...
For something like frequency synthesis, where timing accuracy matters, this method is superior to updating the DAC output from inside an ISR.  There's no problem with interrupt latency, and no chance that the timer will fire late because some other interrupt was being serviced at the time.  ..."

Thanks, very nice idea!
12  Using Arduino / Programming Questions / Re: Timer programming on: October 05, 2012, 10:23:11 am

Thanks, really useful link!
13  Using Arduino / Programming Questions / Re: Timer programming on: October 05, 2012, 10:18:11 am
I repeat that to get jitter-free timer output you have to use the hardware timer output. Not an ISR.
to use the hardware timer output is surely a good idea by many point of view, unfortunately in my case, as I wrote in my post, I have to update a DAC and this require in sequence to put two bytes on a buffer, to set a write bit and to set a load bit, impossible to do with just a timer output and easy to do with ISR. If you have MIPS enough.
Next time I'll define the subject of my post "DAC update"  in place of "timer programming".
Thanks to all of you and expecially to dhenry for all the tests and naked isr.
14  Using Arduino / Programming Questions / Re: Timer programming on: October 04, 2012, 02:18:25 am


Thanks Nick your link is useful for timers programming even if this is not my problem at the moment.
As I say in previous post I've tested the code compiled with WInAVR and put on the same Arduino Uno with ISP .
This is the adapted code
Code:
unsigned int n;
char m;

void setup()
{
  DDRB=255; 
  PORTB&=~32;
  m=1;
  cli(); 
  TCCR1B= 0x00;
  TCCR0B= 0x00; //stop   
  TCCR2B= 0x00;
 
  TCNT0= 0x00; 
 
  OCR2A= 20;   // 
  OCR2B= 40;
   
  TCCR2A= 0x00;
 
  n=0;

  TIMSK0= 0;
  TIMSK1= 0;
  TIMSK2= 6;    // timer2 output compare A & B match enabled
  TCCR2B= 1;    // start timer2 - prescaler=1 - 16 MHz clock
 
  EIMSK=0;

  sei();
}


ISR(TIMER2_COMPA_vect)
{
    PORTB|=32;   
}

ISR(TIMER2_COMPB_vect)
{
    PORTB&=~32;     
}

void main()
{
  setup();
  while (n==0) {}
  n=0;
}
In this case it works fine  and if( OCR2A-OCR2B) > 30  we obtain a pulse width equal to ((OCR2A-OCR2B) * 62.5nS) as it should happens in previous  case. The limit of 30 for OCR2A-OCR2B is probably due to the time for ISR call, the storing and retrieving of registers, ect.
What I would like to know is how Arduino waste all that time and, if is possible, where can I find the assembly code of my C source compiled in Arduino environment ?  What Arduino is doing in "loop() "?
15  Using Arduino / Programming Questions / Re: Timer programming on: October 03, 2012, 02:55:16 am
I'm really grateful to everybody for all the comments and the debate, meanwhile, unfortunately, the point of my question is fading away. My trouble is "why this code doesn't works?" I know you could write the code in a different way but this should works and generate a pulse on pin 13 at a frequency of 62.5KHz  (16MHz clock/256 - and it do it exactly) but with a variable pulse width related to the value OCR2B-OCR2A, while the output pulse is about 1.8uS wide for any value of OCR2B and OCR2A I've tested.
 I can't understand why . I'm going to put the same code on Arduino board using GNU Ccompiler, AVRstudio  and ISP to check if I've the same problem. I'll keep you updated.
Pages: [1] 2