Editing Sensorino

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 557: Line 557:
 
* a 9m a traves de dos paredes fallaba en promedio en el momento de haber subido 30-40% del programa, que seria despues de haber transmitido ~150-200 paquetes sin fallo, o sea que la tasa de error todavia debe ser baja (~1%).
 
* a 9m a traves de dos paredes fallaba en promedio en el momento de haber subido 30-40% del programa, que seria despues de haber transmitido ~150-200 paquetes sin fallo, o sea que la tasa de error todavia debe ser baja (~1%).
  
===Pruebas 13/2/2014: sleep, pin interrupt y watchdog===
+
===Pruebas 13/2/2014===
  
 
Estoy intentando poner el PIC a dormir y despertarlo con el watchdog o los interrupts externos.
 
Estoy intentando poner el PIC a dormir y despertarlo con el watchdog o los interrupts externos.
Line 566: Line 566:
 
En principio podríamos llegar a tener un consumo de solo [https://www.sparkfun.com/tutorials/309 1uA] !
 
En principio podríamos llegar a tener un consumo de solo [https://www.sparkfun.com/tutorials/309 1uA] !
  
'''Wakeup con watchdog''': hay muchas guias que explican como funciona [http://citizen-sensing.org/2013/07/arduino-watchdog/ aqui], [http://www.fiz-ix.com/2012/11/low-power-arduino-using-the-watchdog-timer/ aqui] o [http://forum.arduino.cc/index.php/topic,48626.0.html aqui].
+
'''Wakeup con watchdog''': hay que programar una ISR
 
+
  ISR( WDT_vect ) {
Primero hay que habilitar el watchdog y su interrupción y que no resetee el PIC:
+
  //codigo aquí
 +
  }
 +
y habilitar el watchdog y su interrupción y que no resetee el PIC:
  
 
   MCUSR &= ~(1 << WDRF);
 
   MCUSR &= ~(1 << WDRF);
 
   WDTCSR |= (1 << WDCE) | (1 << WDE);
 
   WDTCSR |= (1 << WDCE) | (1 << WDE);
   WDTCSR = (1<< WDP1) | (1 << WDP2);
+
   WDTCSR = (1<< WDP0) | (1 << WDP3);
 
   WDTCSR |= _BV(WDIE);
 
   WDTCSR |= _BV(WDIE);
  
Explicación: el registro WDTCSR se encarga de configurar el watchdog. Hay 8 bits: WDIF WDIE WDP3 WDCE WDE WDP2 WDP1 WDP0, según los configuremos obtendremos [http://forum.arduino.cc/index.php/topic,48626.0.html distintos comportamientos]:
 
  WDE  WDIE      Mode              Action on Time-out
 
    0    0      Stopped                  None
 
    0    1      Interrupt              Interrupt
 
    1    0    System Reset              Reset
 
    1    1  Interrupt System Reset interrupt then go to system reset
 
Los tiempos se setean con el prescaler (WDP3 WDP2 WDP1 WDP0):
 
  WDP3 WDP2 WDP1 WDP0  Time-out at
 
    0    0    0    0    16 ms
 
    0    0    0    1    32 ms
 
    0    0    1    0    64 ms
 
    0    0    1    1    0.125 s
 
    0    1    0    0    0.25 s
 
    0    1    0    1    0.5 s
 
    0    1    1    0    1.0 s
 
    0    1    1    1    2.0 s
 
    1    0    0    0    4.0 s
 
    1    0    0    1    8.0 s
 
 
Y luego hay que programar una ISR:
 
  ISR( WDT_vect ) {
 
  //codigo aquí
 
  }
 
 
en la ISR conviene deshabilitar el watchdog para que no toque los huevos hasta que nos durmamos otra vez
 
en la ISR conviene deshabilitar el watchdog para que no toque los huevos hasta que nos durmamos otra vez
  

Please note that all contributions to Wiki Makespace Madrid may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wiki Makespace Madrid:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to type the two words you see in the box below:

Cancel | Editing help (opens in new window)