Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,741,979 Members 45,366 Now Online
XDA Developers Android and Mobile Development Forum

[TUT] Tasker CPU Control V5|Frequency/Governor Customisable Profiles|SetCPU with OCD

Tip us?
 
brandall
Old
(Last edited by brandall; 31st May 2011 at 03:18 PM.) Reason: Commercial links removed.
#1  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
Lightbulb [TUT] Tasker CPU Control V5|Frequency/Governor Customisable Profiles|SetCPU with OCD

INSTALLATION INSTRUCTIONS ADDED TO POST #2

For those of you not familiar with Tasker, it’s a pretty damn amazing application that works toward fully automating your Android phone.

You can pick up a free trial version from here.

This thread is to show, assist and learn (from your input) how to fully utilise the newly introduced CPU controls, with the ultimate goal of preserving battery life without using additional applications such as SetCPU or other power saving scripts. This may look like a beast of a tutorial, but it really doesn't take that long to set up. Honest...

Tasker can be a little daunting at first, but a quick read through the manual, some tweaking of the profiles and step-throughs on the Tasker wiki and you’ll be up to speed in no time.

In order to control the CPU, you’ll need a rooted device and a compatible kernel. A quick acronym lesson can be found here. In brief, you require the following Governors (or as many of them as you can get!):

Performance (keeps the CPU frequency always at the maximum. Most power-hungry, most responsive)
Ondemand (when the CPU is needed, immediately sets it to maximum frequency. Slowly reduces the frequency back down to the minimum as time passes. Responsive, reasonable power usage).
Interactive (like Ondemand, but more responsive with slightly more battery usage)
Conservative (when the CPU load is needed, slowly increases the frequency to maximum. When the CPU is no longer needed, immediately drops back to the minimum. Less power-usage than Ondemand or Interactive, less responsive).

If there isn’t such a kernel for your device, then I can only suggest you beg and plead with a Dev in your device’s forum!

You can check the following in a file explorer to see your available frequencies and governors of your current/updated Kernel:
sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors


I have a Desire and am running an Oxygen AOSP ROM. I’m therefore using vorkKernel detailed here. There’s a detailed breakdown in the first post of that thread showing the kind of kernel you’re looking for.

WARNING! DO NOT ENABLE THE PROFILES UNTIL YOU HAVE DOUBLE CHECKED THEY DO NOT EXCEED YOUR PHONE’S CAPABILITIES!! I TAKE NO RESPONIBILITY IF IT SETS ON FIRE! BE CAUTIOUS TO BEGIN WITH. IF THE AVAILABLE FREQUENCIES I DETAIL ARE NOT IN YOUR KERNEL, USE YOUR COMMON SENSE AND APPLY SIMILAR ONES! Ok? Right, ready to blow your phone up…? Just kidding….! Maybe….

Before you import the profiles, make sure you disable/archive/uninstall SetCPU or any other similar applications or scripts that could take precedent over the CPU control.

You’ll also need a couple of tools to see/hear your progress at a glance/listen:

A widget that shows CPU frequency, with regular refresh intervals would be handy. (If you don’t have one, I suggest you use Process Monitor available for free on the market here . The widget refreshes every 5 seconds from the home-screen).

As they’ll be some ‘screen-off’ states, it's very useful to have a speech engine so you can be told what’s happening without having to turn the screen on and therefore changing the state! (I use Pico TTS)

The application CPU Spy can be helpful to show you how these profiles combined with the Data Sync profiles will increase the amount of time your device will be spending in 'deep-sleep' and at lower frequencies. Thanks leftAlone for pointing this app out.

In Tasker, the main triggers for the CPU controls are as follows:

Display Off
Display On
Battery Low
Battery Hot
Phone Charging
In call
(added in V2)
End Call (added in V2)
Initial Boot (added in V2)
Application Launched (added in V2)

In my set-up, these triggers become intertwined as there is often more than one active state to consider. Here we go....

READ THE REST OF THIS POST, BUT INSTALL WITH INSTRUCTIONS FROM POST TWO!

The speech profile (CPU-SayState) is the first one to download – it’s set up to tell you every 5 minutes (in very clear English), your frequency and governor. Not only will this confirm that your screen-off state is working correctly by just listening, but when you are performing other routine tasks, it will alert you if for some reason you find yourself overclocking/underclocking when you don’t want to be and you'll know something is wrong (the alternative to this is good old fashioned log files).

Next, CPU-BatteryHot. It's stand alone. You’ll see that the ‘Event’ is simply ‘Battery Overheating’. If this event occurs, then the governor is set to conservative and the frequencies to 245 and 422,400. Let’s be honest, if you do have an overheating battery, you’re more likely to panic and put the phone in the fridge rather than rely on this profile to resolve it, but it’s a simple start and provides a useful notification should this ever occur.

Next, CPU-DisplayOff. This is a good chance to save some battery life. The event is ‘screen off’ and the task sets a tiny vibrate notification so you’ll know it’s applied whilst the screen is off. An icon will be present in the status bar when you turn the screen back on. Conservative governor and frequency of 245 and 384. You of course should tweak these to whatever you wish - that's the point of this! The other tasks within the profile are removing the notification of other CPU profiles that may have been active prior to the screen turning off.

Next, let’s set up CPU-BatteryLow. It’s relatively stand alone again, triggered by an event of the ‘battery level’ being less than 25%. Conservative governor, with frequencies of 245 and 499,200 with an added IF statement at the bottom confirming the battery level. A popup on the screen will tell you the battery is low, which will go away on its own or can be pressed to dismiss. All other notifications of previous states are cancelled and finally a ‘stop’ is applied IFthe battery goes above 35%. At this point a task is performed that matches the governor and frequency of what will be your ‘regular ***’ CPU settings (again, these should be whatever you wish). This will end once the screen is turned off so the profile returns to CPU-DisplayOff.

Next, CPU-ChargingAny. Triggered by the 'power' state, the first task checks the battery level being above 50%. If it isn’t, an interactive governor is applied (to concentrate on charging), if it is, a performance governor is applied pushing the frequency up to 1075200. A status bar notification/icon and a vibrate pattern alert you that you are overclocking. Other notifications are killed.

Now we have to look at cancelling the overclocking once the phone is no longer charging/on external power. This isn’t totally straight forward, as the preferable states (inverted) of ‘no usb connected’ or ‘battery not charging’ relate to most of the time you use your phone.

The answer is to use an ‘exit task’, which will activate once the current state no longer applies e.g. the charge is removed. At this point, we need to check the current state of the phone, by applying tasks in order of their priority. The first task checks if the screen is off (therefore assuming the phone is no longer being used). If it is, it applies the DisplayOff profile. Secondly, if the battery level is now greater than 25%, it applies the DisplayOn profile (shown below). Finally (assuming the other two tasks states were not true), it applies the BatteryLow profile. The current task is instructed to ‘stop’ once a true state is found.

Finally, CPU-DisplayOn. The event is of course ‘display on’ and it applies the governor and frequencies that you would consider your ‘regular profile***’ for your normal phone usage. For me this is interactive with frequencies of 245 and 998,400. It of course first checks that the battery is not less than 25%, otherwise the BatteryLow profile would have already been activated and should be left to do so. A status notification and the killing of existing notifications is included at the end.

You’ll need to create a manual ‘regular profile’ (mine is called CPU-InteractiveManual in the .zip folder) that you can leave unchecked. This is named to match the *** above. It’s also there in case circumstances require you deactivate all of the other profiles and just run your regular profile (because you want to).

Very finally (!), I have a manual MaxOverclock profile, which I activate when I’m going to be using certain applications – A ROM Emulator for example.

Added in Version 2

CPU-DeviceBoot. I noticed that the Kernel I'm using boots as standard using a conservative governor (this surprised me a little) and overclocking to max frequency (I assume to help boot speed). This profile waits 30 seconds on initial boot and then checks the phone state before applying the correct profile from above.

CPU-DuringCall. During a call, my proximity sensor turns the screen on and off. When inputting numbers on a call (Voicemail for example), this caused the CPU-DisplayOff and CPU-DisplayOn profiles to be constantly flicking on and off unnecessarily. This profile deactivates all CPU profiles until the call is finished.

CPU-EndCall. Once the call is finished, the profiles are activated once again.

An obvious way (so obvious I previously didn't include it) to preserve battery life is to set individual CPU profiles for individual applications. Tweaking of these if you suffer lag, will help you find the minimal settings for each application.
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm
The Following 43 Users Say Thank You to brandall For This Useful Post: [ Click to Expand ]
 
brandall
Old
(Last edited by brandall; 11th May 2011 at 09:25 PM.)
#2  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
STEP-THROUGH INSTRUCTIONS

With Tasker currently ristricting the import of CPU actions, I've had to strip them out of the profiles, meaning you have to add them in manually for the time being. Shouldn't take too long... Follow these instructions:

Download the latest 'Tasker CPU Profiles STEP-THROUGH.zip' and Unzip the profiles into sdcard/Tasker/profiles - Import them individually from the menu options. There should be 11:

CPU_BatteryHot
CPU_BattertLow
CPU_ChargingAny
CPU_DeviceBoot
CPU_DisplayOff
CPU_DisplayOn
CPU_DuringCall
CPU_EndCall
CPU_InteractiveManual
CPU_MaxManual
CPU-SayState


There is one additional stand-alone task:

MTVar

Ensure they remain unchecked until we've added all of the CPU activities below.

Before applying your custom CPU profiles, it would be highly recommended that you observe your current kernel's/ROM's/device's behaviour using home-screen widgets and the speech task included. My device (Desire), has custom kernels that use different governors to get the best performance out of the device. Please understand which governor(s) your kernel dev has focused on and if the voltage and/or governor(s) are changed in certain states. This will be well documented in your Kernel thread.

Overclocking

Please be more than aware that overclocking your device is not without its risks. Within the profiles Overclocking will occur only when the screen is on, the device is on charge and the battery is above 50% to ensure this is intentional. Should your screen go off, you will have to manually restart overclocking by unplugging and replugging the charger. Using a 'Performance' governor, will increase the CPU frequency to the maximum available and remain at that level. This is unecessary unless you are using a particularly high resource application such as a ROM emulator. Using an alternative governor that allows maximum frequency when required, but does not remain there when not, should be considered.

Instructions

The CPU settings have been replaced by actions entitled 'Type'. The text says 'Insert Frequency and Governor here'. In addition, they may be instructions to tick the 'IF' statement and add the values included in the text. Remove the 'Type' entries as you go, replacing them with the following suggested entries:

(CPU action entries are contained under 'Misc'
Select Edit
Press +
Select Misc
CPU)

Tap CPU-DisplayOn
Tap on CPUDispOn - Replace action #6 | Interactive | 128,000 | 998,400

Tap CPU-DisplayOff
Tap on CPUDispOff - Replace action #7 | Conservative | 128,000 | 245,000

Tap CPU-BatteryLow
Tap on CPUBatLow - Replace action #2 | Conservative | 128,000 | 998,400

Tap CPU-ChargingAny
Tap on CPUCharg - Replace action #2 | Interactive | 128,000 | 998,400
Replace action #3 | Performance | 128,000 | 1,075,200

Tap CPU-BatteryHot
Tap on CPUBatHot - Replace action #1 | Conservative | 128,000 | 422,400

Tap CPU-InteractiveManual
Tap on CPUManual - Replace action #1 | Interactive | 998,400 | 128,000

Tap CPU-MaxManual
Tap on CPUMaxMan - Replace #1 | Performance | 128,000 | 1,075,200

----------------------------------------------------------------------
Enable all APART FROM CPU-MaxManual and CPU-InteractiveManual, click 'On', then apply and turn the screen off and on and you should be up and running!

I assume you'll need to add your own icons in to each of the notifications.
-----------------------------------------------------------------------
Minimalistic Text Widget

Also included in the tasks and the V5 download is a profile for Minimalistic Text showing the Tasker variables all of my profiles use. Drag it into the Minimalistic Text folder on the SD card and it will be there in the preference manager. It you don't use all of my other profiles (why the hell not?!) you can delete the entries that are not applicable to you. My other profiles are in my signature btw. I've no idea where my signature is though... Not using Minimalistic Text?? It's a great low resource home-screen widget with Tasker integration. Check out the XDA thread here

I DON'T WISH TO USE THE MINIMALISTIC TEXT PLUGIN!

Then delete the following 'Perform Task MTVar' entries:

CPUDispOn - Action #9
CPUDispOff - Action #14
CPUCharge - Action #10
CPUBatLow - Action #8
CPUEndCall - Action #2
CPUBatHot - Action #6
CPUManual - Action #5
CPUMaxMan - Action #5
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm
The Following 23 Users Say Thank You to brandall For This Useful Post: [ Click to Expand ]
 
brandall
Old
(Last edited by brandall; 12th May 2011 at 12:39 AM.) Reason: All earlier versions removed to avoid accidental download
#3  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
Conclusion

I’ve never used so much battery working these out!! It may well be that the amount of tasks, or the way they are structured, actually uses more battery life than controlling the CPU could save. I’ll be running some tests over the coming days to monitor it. If that does prove to be the case, I'll still be glad I’ve done this and learnt more about this fantastic application and look forward to it making me even more lazy.

Let me know your feedback please folks, inconsistencies, errors, I’m all ears and feel free to use the 'thanks meter'

Quote:
Originally Posted by harmohn View Post
Battery life:
Without brandall's profiles: ~9hrs
With brandall's profiles: ~16hrs!
Quote:
Originally Posted by torsrex View Post
my batterylife has GREATLY improved!
Without tasker: 10h 21% left, with tasker: 15h 67% left..!
Quote:
Originally Posted by MadeUpPost View Post
Since using your profiles, I haven't had to charge my battery in 23 days and I'm having much better sex with my wife! Thanks!

FAQ

Q) I'm getting missing plug-in errors on V5? What do I do?
A) Read the bottom of post #2 and delete the Minimalistic Text actions if you do not wish to use it.

Q) Which profiles do I leave unticked and ticked again??
A) See this post

Q) I get a CPU Action Not Available error - why?!?
A) See the bottom of this page (thanks wanfauzan)

Q) Why doesn't Overclocking start again when the display is turned on and the phone is on charge?
A) Best solution see here. Credit Matrix72

Q) The icons you use are rubbish. How do I use my own?
A) See this post

Q) I have many other Tasker questions, can I post them here??
A) To avoid clutter, probably best to use this official Google group

Q) My phone is sluggish when the 'battery low' profile is active.
A) Be cautious, but adjust the frequencies and maybe governor until you find the perfect settings for your phone.

Change Log

Code:
Select Code
V2
Added CPU-DuringCall profile to V2 .zip
Added CPU-EndCall profilie to V2 .zip
Added CPU-DeviceBoot profile to V2.zip
Changed how CPU-DisplayOn behaves when battery level low
Changed how CPU-ChargeAny behaves when battery is less than 50%. Also added sound effect and matching vibrate pattern because I'm childish. 
Added wait task to CPU-BatteryLow until charge reaches 35%
Added CPU-Navigation example profile to V2 .zip
Changed how cancelled notifications are handled for aesthetic reasons. 

V2.1
Added missing IF statement to vibrate pattern of 'Overclocking' on CPU-ChargeAny

V2.2
Changed collision handling of CPU-BatteryLow to consider wait task

V3
Updated CPU-DuringCall to create an 'in call' variable (%INCALL), that can be used in other tasks.
Updated CPU-EndCall to create an 'in call' variable (%INCALL), that can be used in other tasks.
Changed notification handling to include specific titles, so not to cancel notifications of other Tasker profiles.
Removed Overclocking Sound and chilled the vibrate pattern.

V4

The below update *REMOVED AS IN V5* prevents the quick screen off/screen on changes between CPU-DisplayOff and CPU-DisplayOn which can cause lag and echo errors. This was a headache to resolve due to too many reasons to list, but I've resolved it by adding a 5 second wait before the display off CPU settings are applied - if within that 5 seconds you turn the screen back on, the display off settings will not apply, consequently neither will the display on settings reapply. Someone needs to donate me some paracetamol... 

It's achieved with an additional variable %CPUSS (CPU sleep state) which is set to a value of 1 within the 5 second wait and a value of 2 after (once the CPU screen off settings have applied). This way, the CPU display on settings know whether to activate, or they remain active and therefore don't reapply.... 

V5

* So many I've forgotten them all.... Oops!
Bugs

All totally fixed in V5 (I hope).

Feature Requests

Consider states for 'smartass' governor.

Thanks

torsrex - Risking device and limb testing
-----------------------------------------------------------------------------------------------------

Due to the amount of changes, there is no 'step-through' update for users of the lower versions. Delete the profiles you have and it's a lightening quick addition of the CPU entries from post #2!

------------------------------------------------------------------------------------------------------

The thanks meter lets me know I'm appreciated!
Attached Files
File Type: zip Tasker CPU Profiles V5 STEP-THROUGH.zip - [Click for QR Code] (9.5 KB, 5974 views)
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm
The Following 43 Users Say Thank You to brandall For This Useful Post: [ Click to Expand ]
 
harmohn
Old
#4  
harmohn's Avatar
Senior Member
Thanks Meter 39
Posts: 366
Join Date: Jan 2010
Location: London
I've used a lot of battery working out similar profiles myself

Will have to check yours out when I get home. Having voice overs for frequency and governor is a good addition!
 
enotar
Old
#5  
Senior Member
Thanks Meter 15
Posts: 346
Join Date: Jun 2010
I used CPU control with tasker and since then I uninstalled SetCPU that was a great soft but Tasker give me so much freq control for each application.
Example Book reader don't need the full juice and you can set automaticaly a low frequency.

Tasker is a great tool.
 
brandall
Old
#6  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
Quote:
Originally Posted by harmohn View Post
I've used a lot of battery working out similar profiles myself

Will have to check yours out when I get home. Having voice overs for frequency and governor is a good addition!
Since I've stopped playing around quite so much, my battery life does seem to have improved! Could be just wishful thinking though...

Quote:
Originally Posted by enotar View Post
I used CPU control with tasker and since then I uninstalled SetCPU that was a great soft but Tasker give me so much freq control for each application.
Example Book reader don't need the full juice and you can set automaticaly a low frequency.

Tasker is a great tool.
I've added an example of setting the CPU profiles for individual applications just in case.

Let me know your feedback! I assume no news is good news!? V2 updated in change log.
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm
The Following User Says Thank You to brandall For This Useful Post: [ Click to Expand ]
 
goz5000
Old
(Last edited by goz5000; 5th April 2011 at 08:41 PM.)
#7  
Senior Member
Thanks Meter 14
Posts: 118
Join Date: Sep 2010
I get error trying to import any of your profiles, I'm I doing something wrong??
 
brandall
Old
#8  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
Quote:
Originally Posted by goz5000 View Post
I get error trying to import any of you profiles, I'm I doing something wrong??
What is the error? I'll start with the obvious:

Have you checked you're running the latest version of Tasker? Mine is 1.0.20u3m

Have you unzipped the files into sdcard/Tasker/profiles ?
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm
 
goz5000
Old
#9  
Senior Member
Thanks Meter 14
Posts: 118
Join Date: Sep 2010
import failed, task contains actions unsuitable for import.

I got cpu end call, cpu device boot, and cpu during call to import but the others will not.

I'm using the vork kernel on CM7
 
brandall
Old
#10  
brandall's Avatar
Senior Member - OP
Thanks Meter 4522
Posts: 2,618
Join Date: May 2008
Location: Birmingham

 
DONATE TO ME
Quote:
Originally Posted by goz5000 View Post
import failed, task contains actions unsuitable for import.

I got cpu end call, cpu device boot, and cpu during call to import but the others will not.

I'm using the vork kernel on CM7
You're absolutely right - I just tried to import them myself and got the same result! Ok... I'll find out what's causing the problem...
Devices: Desire|Wildfire|Sensation|Flyer|SIII|Hudl|N4|7|10


Tasker: The Ultimate Noob/Beginners Guide

Memotion:
Latest BETA Build Here: V1.1.7B

utter! Latest Play Store Build Here: V3.1.1B


Quote:
Originally Posted by Tinasintunes View Post
Ohhhhh @brandall Ohhhh @brandall you're the best doo dum dee dee doooooo dummmmm

Tags
cpu, frequency, governor, profiles, tasker
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes