Lwmesh Power saving - Page 1
Forum section: electronics / beginners

author: Peili
author_rank: Regular Contributor
timestamp: September 03, 2019, 10:04:50 am
content: Hi,I am using the Lwmesh stack for avr-atmega256rfr2 MCU. I downloaded the Lwmesh and modify the code to send data as broadcast. My application is theEnd Device broadcast the data..I'm using Watch dog Timer interrupt other than Hal_Sleep() function.. So my application is ,End Device send data and go for sleep and when an interrupt come then wake up and send data using Watch Dog Timer of 2 sec.But the problem we are facing is we are not able to save battery(Since the devices are battery powered).I have measured the current consumption.It takes 20milli ampere while sleeping and 15 milli ampere when it wakes up.I am using avr-atmega256rfr2 MCU . Here i'm attaching my code for End device(WSNDemo) and Hal_sleep. Please advice us to save battery life.. How to reduce the power consumption of the End Device?

author: ataradov
author_rank: Super Contributor
timestamp: September 03, 2019, 06:07:11 pm
content: This is not really related to LwMesh. You need to debug sleep modes separately first. This may be related to something else on your board, for example.

author: Peili
author_rank: Regular Contributor
timestamp: September 04, 2019, 04:26:53 am
content: Quote from: ataradov on September 03, 2019, 06:07:11 pmWhat are the examples ? Is my code correct? Sometimes it works perfectly. How to debug the sleep modes? Please advise..

author: ataradov
author_rank: Super Contributor
timestamp: September 04, 2019, 04:30:33 am
content: Create a static application that just sleeps. Does it achieve the expected consumption? That's the start. After you are sure that your sleep stuff works on its own, add it to the network code.If "sometimes" it works, figure out what is different about times when it doesn't.I don't know if code is correct. I have not worked with AVRs in many years, and I don't care to remember how it all works.

author: Peili
author_rank: Regular Contributor
timestamp: September 17, 2019, 11:03:22 am
content: Is broadcast frames consume more power? Now my current consumption is 4ms at ON time and 16UA at sleep.. i want to down the consumption in micro seconds.. How to reduce it?

author: ataradov
author_rank: Super Contributor
timestamp: September 17, 2019, 01:54:31 pm
content: What is "consumption in micro seconds"?No, broadcast frames do not consume more power compared to unicast frames. But the most power is consumed by the active receiver.

author: Peili
author_rank: Regular Contributor
timestamp: September 18, 2019, 04:27:06 am
content: Quote from: ataradov on September 17, 2019, 01:54:31 pmI want to reduce the power consumption in micro seconds now it's in Milli seconds.. Few months ago i got theON time of my End Device as 135UA.. That is the expected power consumption.. But nowit's 4ms... But there is no change in the code and don't know why it consume more power..

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2019, 04:33:17 am
content: I have no idea what you are talking about. How can you compare 135 microamps to 4 milliseconds? They have different units.

author: Peili
author_rank: Regular Contributor
timestamp: September 18, 2019, 04:37:54 am
content: Sorry, current consumption is now close to 135UA.. i want to reduce the 4millisecond ON time to microseconds..

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2019, 04:38:42 am
content: Ok, so measure what takes that time in your application. How would I know that?

author: Peili
author_rank: Regular Contributor
timestamp: September 18, 2019, 04:50:10 am
content: My application usesWatch Dog Timer interrupt other than Halsleep function.. My scenario is End Device wakeup and send it's App_Addr to nearest Router and go for sleep.WDT is 2seconds.. only that much i need. no need for routing.. JustWakeup ,Send and Sleep.... But for that scenario the device take 4milliseconds ON time.. My End Device is a Battery powered device(atmega256rfr2). I can't afford this type of power consumption...What are the factors affecting the power Consumption and how can i reduce it by code wise?I'm really stuck into itHere i'm attaching my Wsndemo for EndDevice the configuration file and sleep function

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2019, 05:01:38 am
content: How did you measure that 4 ms time? It takes some time to send a frame and receive an ACK. I don't know if 4 ms is justified or not in this case. You need to measure different part of the process and see what takes the longest time and eliminate that.

author: Peili
author_rank: Regular Contributor
timestamp: September 18, 2019, 05:14:14 am
content: Quote from: ataradov on September 18, 2019, 05:01:38 amMeasured it by switching one Pin in my board in sleepCode:case APP_STATE_SLEEP:{PORTD&=~(1<<PD6);//sleepHAL_Sleep(APP_SENDING_INTERVAL);appState = APP_STATE_WAKEUP;} break;case APP_STATE_WAKEUP:{NWK_WakeupReq();PORTD|=(1<<PD6);//sleepappState = APP_STATE_SEND;} break;herePD6 is the pin I'm switching and measuring...

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2019, 05:20:50 am
content: Ok, now do the same for all steps of the sending process and see what takes all this time. I don't know what could be taking that long.

author: Peili
author_rank: Regular Contributor
timestamp: September 18, 2019, 05:41:04 am
content: Ok i will check and update you sir

author: Peili
author_rank: Regular Contributor
timestamp: September 19, 2019, 11:06:55 am
content: Quote from: ataradov on September 18, 2019, 05:20:50 amSir, i done the same step for all the process and the results are:appSendData() takes 200microsecondsappInit() takes small amountBut in my sleep condition,Code:case APP_STATE_PREPARE_TO_SLEEP:{PORTD&=~(1<<PD6);if(!NWK_Busy()){NWK_SleepReq();appState = APP_STATE_SLEEP;}} break;case APP_STATE_SLEEP:{PORTD|=(1<<PD6);HAL_Sleep(APP_SENDING_INTERVAL);appState = APP_STATE_WAKEUP;} break;takes 4 milliseconds..The condition if(!NWK_Busy()) function is taking that much power consumption.. So the ON time of the device is about 4 milliseconds..I checked the code and realize that a lock bit(nwkIb.lock) is checked during the condition and find that the lock bit is decrement when nwkDataReqConfirm() is called..Is ma thoughts are correct? And how can i reduce that time?

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2019, 03:34:52 pm
content: Well, yes, this was to be expected. You need to do the same for the internals of the stack. Basically trace the path of the frame through the stack and see what steps of the sending process take this time.I would specifically start with PHY_DataReq() and PHY_DataConf() pair and extend outwards.