Show Posts
Pages: [1] 2 3 ... 9
1  Using Arduino / Programming Questions / Re: Programming problem in sleep mode. on: August 11, 2014, 01:28:04 am
Hi Guys

okay I found the problem and fixed it, it turns out that you do infact need to disable the ADC before sleep otherwise it draws more current in sleep mode. My problem came in that once the unit wakes up the ADC has to be manually re enabled before and analog readings can be done.
here is my finished code below. ( Sorry about all the comments )
Code:
//Libraries//
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <VirtualWire.h>
//-----------------------------------End of Libraries---------------------------------------------//

// Global variables //
const byte LED             = 13;
       int ATimer;
       int BattValue       = 0;
       int BattCheckPin    = A3;
       int DataRadioSwitch = 9;
       int RadioTXPin      = 11;
/////////////////////////////////////  8 = 1 min
///////////////////////////////////// 45 = 6 min
///////////////////////////////////// 75 = 8 min
int SleepTime = 450;///////////////// 450 = 1 Hour
///////////////////////////////////// 5400 = 12 Hours 
///////////////////////////////////// 10800 = 24 Hours                                     
                                     
//-----------------------------------End of Global Variables--------------------------------------//

// Data Structures//
typedef struct roverRemoteData
{
  int    TX_ID;      // Just to make sure that the transmission is ID'd
  int    Sensor1Data;// The variable were the data from each sensor
};
//-----------------------------------End of Data Structures---------------------------------------//

// watchdog interrupt//
ISR (WDT_vect)
{
  wdt_disable();                   // disable watchdog//


//------------------------------------End of Watchdog---------------------------------------------//
//Setup//
void setup ()
{
  vw_setup(2000);                  // Radio Baud Rate//
  vw_set_tx_pin(RadioTXPin );      // Set DATA radio TX Pin// NOTE: MUST BE PWM PIN
  pinMode(DataRadioSwitch,OUTPUT);
}
//------------------------------------End of Setup-------------------------------------------------//
 //Main Loop//
 void loop ()
 {   
  flash ();                        //HeartBeat Flash//
  AwakeTimer();                    //Awake Timer//
    if ( ATimer == SleepTime)
    {
      BattRead();
      DataTX();
    } // End of Main loop if timer was reached

//----------------------------------- End of Actual executing code---------------------------//
  //Preparing to go to sleep//
 
  digitalWrite(DataRadioSwitch,LOW);               //Switch Data Radio off

  byte old_ADCSRA = ADCSRA;                        // disable ADC //
  ADCSRA = 0;                                      // disable ADC //

  byte old_PRR = PRR;                              // disable Internal modules//
  PRR = 0xFF;                                      // disable Internal modules//

  MCUSR = 0;                                       // clear various "reset" flags//

  // Watchdog Timer Parameters//
  WDTCSR = bit (WDCE) | bit (WDE);                 // allow changes, disable reset
  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);   // set WDIE, and 8 seconds delay
  wdt_reset();                                     // pat the dog once program has executed.

  // Sleep Activation //
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);            //Sleep mode Selection//
  sleep_enable();                                  //Sleep Now//

  // turn off brown-out enable in software//
  MCUCR = bit (BODS) | bit (BODSE);                //Brown out settings
  MCUCR = bit (BODS);                              //Brown out set.
  sleep_cpu ();                                    //CPU is now sleeping

  //--------------------------------------End of sleep Preperation-------------------------------//
  // Once awake code executes from this point//
  // Once CPU wakes up do the follwoing to restore full operations//
  sleep_disable();
  PRR = old_PRR;
  ADCSRA = old_ADCSRA;
}

//----------------------------------------END OF MAIN PROGRAM---------------------------------------//

// VOIDS FUNCTIONS//

//Wake up timer//
void AwakeTimer()                 
{
  ATimer++;
}

// Heartbeat flash//
void flash ()
{
  pinMode (LED, OUTPUT);
  digitalWrite (LED, HIGH);
  delay (16);
  digitalWrite (LED, LOW);
  delay (16);
  ATimer = 0;                      // Reset Wake up timer//
}

// Read Own battery State//
void BattRead()
{
  BattValue = 0;
  BattValue= analogRead(BattCheckPin);
}

// Transmit data//
void DataTX()
{
  digitalWrite(DataRadioSwitch,HIGH);
  struct roverRemoteData payload;

  payload.TX_ID = 3;
  payload.Sensor1Data = BattValue;

  vw_send((uint8_t *)&payload, sizeof(payload));
  vw_wait_tx();
  digitalWrite(DataRadioSwitch,LOW);
}

2  Using Arduino / Programming Questions / Re: Programming problem in sleep mode. on: August 10, 2014, 10:29:39 am
I thought the ADC was enabled as part of the wake up procedure after a watchdog interrupt. ?
3  Using Arduino / Programming Questions / Re: Programming problem in sleep mode. on: August 10, 2014, 10:17:35 am
placing the actual analogRead(A3); statement in the main loop or in a void with local or global variables also does not make a difference.
4  Using Arduino / Programming Questions / Re: Programming problem in sleep mode. on: August 10, 2014, 10:11:51 am
Because i have given up just trying anything to try and get it to work.

there or not there it still does not work
5  Using Arduino / Programming Questions / Programming problem in sleep mode. on: August 10, 2014, 09:56:25 am
Hi  guys i have the following code running on a modified pro mini.
Code:
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <VirtualWire.h>

const byte LED = 13;

int ATimer;


typedef struct roverRemoteData
{
  int    TX_ID;
  int    Sensor1Data;// The variable were the data from each sensor
};

void AwakeTimer()
{
  ATimer++;
}
//void DataTX()
//{
//
//}

void flash ()
{
  pinMode (LED, OUTPUT);
  digitalWrite (LED, HIGH);
  delay (1000);
  digitalWrite (LED, LOW);
  delay (50);
  ATimer = 0;
}

// watchdog interrupt
ISR (WDT_vect)
{
  wdt_disable();  // disable watchdog
}  // end of WDT_vect

void setup ()
{
  // VirtualWire setup
  vw_setup(2000); // Bits per sec
  vw_set_tx_pin(11);
  pinMode(9,OUTPUT);

}

void loop ()
{
  int BattValue = 0;
  //delay(5000);
    int BattCheckPin = A3;
    pinMode(BattCheckPin,INPUT);
    delay(100);
    BattValue= analogRead(BattCheckPin);
    delay(100);
   
  AwakeTimer();
  if ( ATimer == 2) // 45 = 6 min// 75 = 8 min // 450 = 1 Hour
  {
    flash ();
   // DataTX();
     digitalWrite(9,HIGH);
  struct roverRemoteData payload;

  payload.TX_ID = 3;
  payload.Sensor1Data = BattValue;

  vw_send((uint8_t *)&payload, sizeof(payload));
  vw_wait_tx();
  digitalWrite(9,LOW);
  }

  digitalWrite(9,LOW);

  // disable ADC
  ADCSRA = 0; 

  // clear various "reset" flags
  MCUSR = 0;     
  // allow changes, disable reset
  WDTCSR = bit (WDCE) | bit (WDE);
  // set interrupt mode and an interval
  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 8 seconds delay
  wdt_reset();  // pat the dog

  set_sleep_mode (SLEEP_MODE_PWR_DOWN); 
  sleep_enable();

  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);
  MCUCR = bit (BODS);
  sleep_cpu (); 

  // cancel sleep as a precaution
  sleep_disable();
} // end of loop

it works great for power saving and to test it i have it wake up once a minute and read the voltage input on pin A3 . my problem is for some strange reason the pin reading does not update once a reading was taken.

Example
When starting the proram the analog read of pin A3 reads 1023 IE 3.3v as it is a 3.3v mini. but even if I remove the pin and apply a 1.5v voltage on the A3 pin it still reports 3.3v.

I have tried to place the line code
Code:
BattValue= 0;

after the transmission is complete and it still does not work.

does the sleep library have an impact ont eh analog read function or what is going on. the pin just not update its reading after the first bootup.


any help is great
6  Using Arduino / Project Guidance / Re: Low Power Device and Solar Chip , need Input. on: August 09, 2014, 03:22:13 am
Hey Tom

Thank you  that worked a treat.
Lol shows you simple is better. i thought voltage drop over diode would effect the current as-well and since the current only micro amps i didn't give it much further thought.

Im very chuffed about the cells being able to run the unit in sleep mode. it actually puts 2uA back into the battery in direct sunlight while  running the Pro mini. i know it wont charge it but at least Im sure its not draining the batt.
7  Using Arduino / Project Guidance / Low Power Device and Solar Chip , need Input. on: August 09, 2014, 01:53:46 am
Hi Guys

This topic is of the back of another recent thread that can be found here.
http://forum.arduino.cc/index.php?topic=259048.msg1829943#msg1829943

I did not want to hijack that thread with my question so I'm starting a new thread.

Iv been doing test on the sleep library and example code of Nick Gammon(Arduino Master in my eyes)
But I need help with alternative ways to power the device while is sleep mode.

a couple of years ago.
I bough a few of these https://www.sparkfun.com/products/9962 solar chips with the original idea that that would be able to charge a small coin battery but they did not make the cut. now after playing and getting my Arduino pro mini 3v3 to run at 4.8 uA in sleep mode these devices has a new meaning.

these solar chips has a max current delivery of 50 uA in direct sunlight at 4V, i have 4 of these chips connected in parallel and in ambient light setting  i get around 11-16 uA out. :-) this is enough (tested) to run the modified pro mini in sleep mode with no battery connected.

Interested yet ?     I AM !!!.

My problem is as follows and this is where i need input and advice.
When the solar chip(s) is connected and there is no light on them they actually draw 1 uA more from the battery then just a pro mini alone in sleep mode. So how can i detect that there is enough voltage on the solar chips to disconnect the battery (save power) without using more CPU power to monitor this. ?

Can I use a mosfet or transistor as a stand alone hardware solution or what can you guys suggest ?

PS here is the code with a few modes
I managed to create a crude timer form the internal watchdog to wake the chip up at any desired time.
 
Code:
#include <avr/sleep.h>
#include <avr/wdt.h>

const byte LED = 13;
int ATimer;
void AwakeTimer()
{
  ATimer++;
}
  

void flash ()
  {
  pinMode (LED, OUTPUT);
  for (byte i = 0; i < 2; i++)
    {
    digitalWrite (LED, HIGH);
    delay (1000);
    digitalWrite (LED, LOW);
    delay (50);
    ATimer = 0;
    }
    
  pinMode (LED, INPUT);
    
  }  // end of flash
  
// watchdog interrupt
ISR (WDT_vect)
{
   wdt_disable();  // disable watchdog
}  // end of WDT_vect
 
void setup () { }

void loop ()
{
 
  AwakeTimer();
  if ( ATimer == 7) // 45 = 6 min// 75 = 8 min // 450 = 1 Hour
  { flash (); }
  
  // disable ADC
  ADCSRA = 0;  

  // clear various "reset" flags
  MCUSR = 0;    
  // allow changes, disable reset
  WDTCSR = bit (WDCE) | bit (WDE);
  // set interrupt mode and an interval
  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 8 seconds delay
  wdt_reset();  // pat the dog
  
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_enable();
 
  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);
  MCUCR = bit (BODS);
  sleep_cpu ();  
  
  // cancel sleep as a precaution
  sleep_disable();
  
  } // end of loop
8  Using Arduino / Project Guidance / Re: Low power project and batteries on: August 04, 2014, 10:27:08 am
Hi Timmy,

no your question is not dumb but also not so difficult to work out, of course theory and practice does not always meet in  the middle. have a look at these websites they might help you with your project , I have been trying to do something similar but no one really seems interested. http://heliosoph.mit-links.info/arduino-powered-by-capacitor-first-tests/  is a guy that has done alot of testing on this , and my site http://powerduino.blogspot.com/

hope you come right.
9  Using Arduino / Networking, Protocols, and Devices / Re: AXSEM AX5043 RF Transceiver on: February 27, 2014, 08:28:08 am
Hi Chris

i hope you get this message.
I have just received free samples form Asxem AX5043 chips and after reading through the complete data sheet this chip is incredible! Which would prompt me to ask what did you mean with front end that is required ? the chip interfaces via MISO and MOSI so would it not just work with arduino ?  I would really like to create a small Data radio out of these units.   
10  Using Arduino / Networking, Protocols, and Devices / Re: AXSEM AX5043 RF Transceiver on: February 26, 2014, 05:59:20 am
HI Chris

Thank you for the reply, i thought i was alone .....

I have now ordered a few NRF905 chips from nordic.
They have been proven to work with Arduino and they offer similar functions but will see how they perform.

Rustie0125
11  Using Arduino / Networking, Protocols, and Devices / Re: RF Design question. on: February 26, 2014, 01:12:24 am
Hi Mike

I know about the licensing issue, but our regulations state that up to 10mW devices are allowed in the free band with out licensing  and once a device has been designed I can us it for personal use until I want or plan on selling it then I would just to get is certified to at 10mw  output power. I know the UK is more strict on these rules but you would be amazed with what you get away with in this country.
12  Using Arduino / Networking, Protocols, and Devices / RF Design question. on: February 26, 2014, 12:05:45 am

I am looking for a small data radio to use in one of my projects that is supported by Arduino libraries but that i can find the individual components to make my own boards. I am currently looking into the NRF905 chip from NORDIC and although it is an old chip I am impressed with what it offers. my question is the following.

to save space I will be using a PCB antenna on the board but i need to know if I can place all my components inside the rim of the antenna ? I know if everything is switched on chances of interference is great but for my application everything will be in sleep/switched off before I transmit and when the other components are working the Radio will be sleeping.


Example of a board , I want to move the actual radio to the inside of the board and the MCU on the back of the board with other components.

would this work and what do I need to look at for ?
13  Using Arduino / Networking, Protocols, and Devices / Re: nRF24L01+ only working when I place my finger on it on: February 25, 2014, 08:17:32 am
Hi
I have been playing with the NRF24L01 for while now and what I have picked up is that their is slight variations in performance from board to board, have you tried just another unit ? I have ordered these things before and 3 out of 5 units was defective so be careful where you order from.
14  Using Arduino / Networking, Protocols, and Devices / Re: Where to buy RFM22B RF Chip not the board on: February 21, 2014, 10:59:03 am
How would the NRF24L01 with a LNA and PA do with a wire or PCB antenna ?
15  Using Arduino / Networking, Protocols, and Devices / Re: Where to buy RFM22B RF Chip not the board on: February 21, 2014, 08:29:57 am
 Riva

Its no secret what Im working on I have been trying to make it as public as possible but cant seem to get much attraction from the community. you can see the project herehttp://powerduino.blogspot.com/2014/02/open-source-community-built-ultra-low.html here but in a nutshell im trying to create a TINY GPS arduino tracker. so to answer your questions in short.

Range :800-1000meters
Freq 315-900mhz will do (better penetration)
Data rates as high as possible but the application is not time critical so multiple packets can be sent.
MUST be a transceiver due to the nature of the project.
Size well lets put it this way, Im trying t put a GPS , MCU ,Radio , Accelormeter, RTC and battery on a board no bigger then a Pro mini . that is why i need to be able to move the components around.
Pages: [1] 2 3 ... 9