Author Topic: sleep mode  (Read 20872 times)

fr

  • Newbie
  • *
  • Posts: 19
sleep mode
« on: March 07, 2013, 04:00:36 am »
Hi,

How to ask digispark to put in sleep mode until a state change on one pin ?


Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: sleep mode
« Reply #1 on: March 07, 2013, 04:04:29 am »
The digispark uses quite a bit of power through the USB circuitry (the pullup) and the power LED so if your goal is to use a very very small amount of power, you'd have to cripple the digispark. Better to program raw AVR chips.

fr

  • Newbie
  • *
  • Posts: 19
Re: sleep mode
« Reply #2 on: March 07, 2013, 05:09:56 am »
I understand.
I love the simplicity of digispark, communication by USB for debuging  but it is a project where it would be used alone

I have no experience on ATTINY85 use alone with language arduino.
If you have some links...


Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: sleep mode
« Reply #3 on: March 07, 2013, 06:15:23 pm »
Do you really need sleep mode for your project? You can't make the digispark be powered just when it is needed for instance? It's easier to remove the 5 second delay from the bootloader than to learn to program and work with raw ATtiny85 chips at the moment.


In the future (next release or maybe the one after that) the digispark software will be getting a lot better at working with raw ATtiny85 chips. For now it takes a bunch of messing with fuses with an ISP programmer to setup a chip to be compatible with the digispark software.


If it is really completely unacceptable I can try and write up some info on how to program a raw chip. Let me know which operating system you're using if so. Digispark uses about 20ma to run when not asleep. Sleep mode can probably make that number about half as much without doing hardware modifications to the circuit board like removing the power LED and possibly crippling the USB port.


On a raw ATtiny85 chip sleep mode will reduce power consumption to about 0.01ma

fr

  • Newbie
  • *
  • Posts: 19
Re: sleep mode
« Reply #4 on: March 08, 2013, 12:45:35 am »
Bonjour à tous,

Mon projet est un interrupteur magnétique pour rc.

En bateau l'eau est l'ennemi et avec ce genre de gadget on peut protéger, en même temps le circuit doit surveiller la batterie afin qu'elle ne soit pas détruite. Il existe un produit qui fait cette dernière fonction très bien mais pas pour les LiFePO4
mon code et le schéma

#include <DigiUSB.h>
 
 
const int pinPont = 1;                     // An1 (ou pin 7 sur ATtiny85) milieu du pont
                                           // extérieurs vers ground et +5V après vers lipo
const int pinMagn = 0 ;                    // P0 (ou pin 5 sur ATtiny85) capteur effet hall mégane
const int pinBuzz = 5  ;                   // P5 (ou pin 1 sur ATtiny85) buzzer
const int pinMosfet = 1 ;                  // P1 (ou pin 6 sur ATtiny) commande mosfet
int val = 0 ;                              // variable pour valeur lue
int nb = 0 ;                               // variable de test
unsigned long StartMs = 0 ;                // durée pour viser tampon com USB
const unsigned long dureeAffich = 2000 ;   // Durée d'affichage

void setup() {
  DigiUSB.begin();
  pinMode(pinBuzz, OUTPUT) ;               // set a pin for buzzer
  pinMode(pinMosfet, OUTPUT) ;             // set a pin for led intégrée et mosfet
                                           //P2 pas besoin de déclarer la pin
                                           // Attention liaison usb sur P3 et P4
                                         }
 
void loop()  {
  if ( (millis()-StartMs) >= dureeAffich )
  {
    val = analogRead(pinPont) ;            // lire tension accus
    DigiUSB.println(val);
    StartMs=millis() ;                     // Réarme le chrono
    if (digitalRead(pinMagn) !=0 || val > 800) {
     digitalWrite(pinMosfet,LOW) ; }       // le mosfet 25N05 est passant, la radio est allumée
    else {
      digitalWrite(pinMosfet,HIGH) ;       //le mosfet est bloqué,la radio est éteinte
                                           // prévoir mise en sommeil ATtiny
      }                                    // http://arduino.cc/forum/index.php?topic=83826.0
    if (val < 600) {                       // la tension est basse
      digitalWrite(pinBuzz,LOW);    }      // Pas d'alarme sonore
    else  {
      digitalWrite(pinBuzz,HIGH);   }
   }

  DigiUSB.refresh();                      //pour que la liaison USB fonctionne correctement
 
  }


Actuellement je mesure 40 mA en consommation, je vide donc la batterie en 5 heures et surtout elle meure car elle va continuer à se vider au delà des valeurs limites



My project is a magnetic switch for rc.

Boat water is the enemy and with this kind of gadget can be protected at the same time the system must monitor the battery so that it is not destroyed. There is a product that makes it function well but not for LiFePO4
my code and schema

I currently use is 40 mA, so I empty the battery in 5 hours and especially because she dies she will continue to drain beyond the limits

fr

  • Newbie
  • *
  • Posts: 19
Re: sleep mode
« Reply #5 on: March 08, 2013, 12:54:15 am »
J'oubliais, pour que le code fonctionne il faut modifier des fichiers du digispark

Merci à RC Marine pour cette modif.



I forgot the code to work you must modify files digispark

To thank you for this mod RC Marine.

Neon22

  • Newbie
  • *
  • Posts: 6
Re: sleep mode
« Reply #6 on: March 08, 2013, 01:26:55 am »
The digispark has a 1.5V boost converter as a shield.
So I would assume we had some way to sleep the chip and re-awake at some later point.
I want to program the digisparks using the USB but my units will be used standalone in some cases.

Is there really no way to sleep the digispark...

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: sleep mode
« Reply #7 on: March 08, 2013, 02:49:15 am »
You could have the power switched by a relay, which the digispark could control to shut itself fully off.
The external event would have to switch that relay back on then.
Kind of an hardware sleep.

It probably would be better if you use a latching relay, so it doesn't need constant power applied to stay on.


In french :

Tu pourrais utiliser un relais pour controller l'alimentation, le digispark pouvant ainsi s'éteindre lui même complétement.
Il faudrait que ton évènement extérieur puisse activer ce relais.
Un peu comme un sleep matériel.

Ce serait mieux si le relais est verrouillable, afin de ne pas avoir besoin de lui donner du courant pendant toute la période d'allumage.
« Last Edit: March 08, 2013, 04:10:27 am by DeuxVis »

fr

  • Newbie
  • *
  • Posts: 19
Re: sleep mode
« Reply #8 on: March 08, 2013, 06:15:34 am »
Si c'est à moi que tu t'adresses, sache que c'est pour arrêter la radio entre deux régates, donc il faut pouvoir réallumer avec l'aimant.


If it's me you're talking to, know that this is to stop the radio between two races, so it must be able to reignite with the magnet.

RC Navy

  • Jr. Member
  • **
  • Posts: 54
  • When you like, even too much, it is not enough!
Re: sleep mode
« Reply #9 on: March 08, 2013, 11:20:56 am »
Salut fr,

le patch que tu proposes en réponse #5 va être inclus dans la prochaine release de l'intégration Digispark dans l'EDI arduino. En fait, j'ai travaillé sur ce sujet pour toi et j'ai découvert que Bluebie avait fait la même modification (plus d'autres améliorations) et qu'elles seront incluses dans la prochaine release.
Je conseille donc aux utilisateurs du Digispark de mettre à jour leur IDE arduino dès qu'il sera disponible sur le site Digistump.

Hi fr,

the patch you propose in reply#5 will be included in the next release of the integration of Digispark in arduino IDE. In fact, I worked on the subject for you, and I discovered Bluebie did the same modification and this one (plus some other improvements) will be included in the next release.
Thus, I recommend to Disgispark users to update their arduino IDE as soon it will be available in the Digistump site.

RC Navy

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: sleep mode
« Reply #10 on: March 08, 2013, 12:29:17 pm »
The new release of the IDE will be available in the next few days.


La nouvelle version de l'IDE sera disponible dans les prochains jours.

fr

  • Newbie
  • *
  • Posts: 19
Re: sleep mode
« Reply #11 on: March 08, 2013, 12:56:06 pm »
Super, cool !

In english :

Super, cool !

And for my  sleep mode ?