LowPowerLab Forum

Hardware support => Low Power Techniques => Topic started by: rocsta on February 10, 2016, 03:29:22 AM

Title: Strange Behaviour of lowpower commands
Post by: rocsta on February 10, 2016, 03:29:22 AM
Hi all,

I'm still in "race" with my trapcontrol project. I have had a lot of problems and it took a lot of time, but now I'm (more or less) on the final spurt for the field test.

But I have a last strange problem. I have perhaps to explain, that I use a lot of the digital pins and I need definitely more then 2 hardware interrupts. At most 5 for different PIR-Sensors and the RTC.

So I used the Code snippet proposals from this thread: https://lowpowerlab.com/forum/index.php/topic,1173.msg8036.html#msg8036, like this:

  PCMSK2 |= (1 << PCINT18) | (1 << PCINT19) | (1 << PCINT20) | (1 << PCINT21) | (1 << PCINT22); // ALARM + PIR Sensors
 
  PCICR |= (1 << PCIE2);

  sei();


and ...

ISR(PCINT2_vect) {
  uint8_t pinState;
  uint8_t changedbits = 0;

changedbits = PINC ^ portchistory;
portchistory = PINC;

if(changedbits & (1 << PC2)) {
// Port 18 - ALARM signal
if (tc_debug) {Serial.println("*****TIME ALARM");}
ALARMpinchanged= 1;
}

if(changedbits & (1 << PC3)) {
....


Everything works fine, but when I send the moteino in standby with

  Serial.flush();   // empty the serial buffer
  radio.sleep();
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);


... my PIR "fires". When I comment the powersaving-commands everything works fine.

Do you have some ideas ?

Kind regards,

rocsta
Title: Re: Strange Behaviour of lowpower commands
Post by: Felix on February 10, 2016, 09:02:20 AM
Hi rocsta,
So you're using MoteinoMEGA, with pinchange interrupts?
Do you have a single PIR? It goes HIGH and triggers the PCINT when you call the sleep commands?
Any chance you tried another PIR, or perhaps some pulldown resistors on the PIR signal pin? Not sure what else to suggest right now..
Title: Re: Strange Behaviour of lowpower commands
Post by: rocsta on February 10, 2016, 09:41:33 AM
Hi,

yes, moteinoMEGA with PINchangeInterrupts.

Actually I have only one PIR (for development purposes), in "worst case" I would like to use four.

But I will check the PIRs and their levels again, thank you for the hint.

rocsta
Title: Re: Strange Behaviour of lowpower commands
Post by: rocsta on February 10, 2016, 07:32:51 PM
So, I don't know, what I have done, but now it seems to work.

Probably it was the following: Depending on the scenarios, I need from 1 to 4 PIR sensors. Now I changed the Code, so that only the connected PIR PINs will be avtivated with "pinMode(PIN_PIRi , INPUT);"

Perhaps this was the point, but I'm really not sure.

Now I'm working on the power consumption, to high, 17 mA.  :(
Title: Re: Strange Behaviour of lowpower commands
Post by: Felix on February 10, 2016, 08:37:22 PM
That's good that you got it working.
Oh yes, as some say, you can fly to the moon on a few mA :)