Jump to content

CPU Voltage Monitor


rhg
 Share

Recommended Posts

CPU Voltage Monitor v0.3

This was requested by a friend overseas that has to deal with very bad voltage fluctuations.

Updated 2006-02-11 05:06

Ok, v0.2 was ok, but not enough for me. Also lacked some

functionality I wanted so I added it. :o

Goals/Features

1) Auto Detect's current voltage and

--- Automaticaly applies +-0.1 tolerance range

--- Displays MsgBox with Current Voltage and Applied Ranges

2) HotKey parameters now displayed in MsgBox on Startup

--- SHIFT+ALT+S = Emergency Shutdown Dialog

--- SHIFT+ALT+V = Current Voltage Dialog

--- SHIFT+ESC = Exit Dialog

3) Alert Dialog when out of tolerance with Sound

--- Alert Dialog offers Emergency Shutdown ( Shutdown(13) )

4) Detects if it is already running and

--- notifys user then terminates

Test Platform(s):

Compiled Using AutoIt v3.1.1.107 Beta

OS: Windows XP Profesisonal

PC1: AMD+GigaByte Desktop Clone (32-bit)

PC2: Intel Centrino 1.8/533 Laptop (HP)

ToDo:

1) Add support for more CPU's -- Auto Detect's Voltage Now

1a) CPU Detection -- Not needed, but plan to add as feature

1b) Load tolerance specs from INI -- 86'ed

Known Limitations:

Voltage readings using WMI only return readings in

1/10 increments versus manfacturer specs which are typically

1/1000 increments. So technicaly this is not accurate at all.

Maybe in a future version I will try to access BIOS readings

with WMI instead of using Win32_Processor readings.

Update: I think this *is* the only way to detect

CPU voltage with WMI. ;)

Any feedback/criticism welcome. :geek:

Global $Title = "CPU Voltage Monitor v0.3"
If WinExists("CPU Voltage Monitor v0.3") Then
    $sdnow=10
    Bye()
EndIf
AutoItWinSetTitle($Title)

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayIconHide",1)

HotKeySet("+{ESC}", "Bye")
HotKeySet("+!s", "EShutDown")
HotKeySet("+!v", "Voltage")

Global $Output, $sdnow=0
Global $current_voltage = GetVoltage()
Global $min = $current_voltage - 0.1
Global $max = $current_voltage + 0.1

Alert(0)

$Title = "Auto Settings"
$Output=""
$Output = $Output & "Based on the detected voltage the settings"&b()
$Output = $Output & "below will be used for Tolerance Range:"&b()&b()
$Output = $Output & "              Detected: "&$current_voltage&" V"&b()&b()
$Output = $Output & "        Mininmum Tolerance: "&$min&"00 V"&b()
$Output = $Output & "        Maximum Tolerance : "&$max&"00 V"&b()
MsgBox(64,$Title,$Output,10)

$Title = "Controls"
$Output=""
$Output = $Output & "Here is a list of controls for use with CVM:"&b()&b()
$Output = $Output & "Exit Program"&t()&"SHIFT+ESC"&b()&b()
$Output = $Output & "Emergency"&t()&"SHIFT+ALT+S"&b()
$Output = $Output & "Shutdown"&b()&b()
$Output = $Output & "Current Voltage"&t()&"SHIFT+ALT+V"&b()&b()
MsgBox(64,$Title,$Output,10)

While 1
    $current_voltage = GetVoltage()
    Select
    Case $current_voltage<$min 
        Alert(1)
    Case $current_voltage>$max
        Alert(2)
    Case Else
        Sleep(1000)
    EndSelect
Wend

Func Bye()
    Exit
EndFunc

Func OnAutoItExit()
    Select
        Case $sdnow=1
            Shutdown(13)
        Case $sdnow=0
            $Title = "CPU Voltage Monitor v0.3 - Exit"
            $Output = ""
            $Output = $Output & "     Hope you enjoyed this version."&b()&b()
            $Output = $Output & "Please POST/PM/IM/EMAIL Any and All"&b()
            $Output = $Output & "        Feedback and Criticism :)"&b()
            MsgBox(64,$Title,$Output,10)
        Case $sdnow=10
            $Title = "CPU Voltage Monitor v0.3"
            $Output = ""
            $Output = $Output & " An instance of CPU Voltage Monitor"&b()
            $Output = $Output & "       is already running."
            MsgBox(64,$Title,$Output,10)
    EndSelect
EndFunc

Func Voltage()
        $Title = "CPU Voltage Monitor v0.3"
        $Output = ""
        $Output = $Output & "Current Voltage Detected : "&GetVoltage()&" V"
        MsgBox(64,$Title,$Output,30)
EndFunc

Func EShutDown()
    $Title = "Emergency Shutdown"
    $Output=""
    $Output = $Output & "     Do you want to ShutDown your computer"&b()&b()
    $Output = $Output & "                        IMMEDIATELY?"&b()&b()
    $Output = $Output & "If you click Yes All Programs will be forced to Close"&b()
    $Output = $Output & "   and this computer will ShutDown Immediately."&b()
    $Output = $Output & "       Continue with Emergency ShutDown?"&b()
    If ShowMe($Title,$Output,120)=6 Then
        $Title = "Emergency Shutdown"
        $Output=""
        $Output = $Output & "Are you Sure?"&b()&b()
        If ShowMe($Title,$Output,30)=6 Then
            $sdnow=1
            Bye()
        Else
            Return
        EndIf
    EndIf
EndFunc

Func b()
    Return @CRLF
EndFunc

Func t()
    Return @TAB
EndFunc

Func ShowMe($T,$O,$to=10)
    SoundPlay(@WindowsDir & "\media\chord.wav",0)
    Return Msgbox(4096+4,$T,$O,$to)
EndFunc

Func Alert($lvl)
    Select
    Case $lvl = 0;welcome message
            $Title = "CPU Voltage Monitor v0.3"
            $Output = $Output & "CPU Voltage Monitor will alert you if your" & b()
            $Output = $Output & "CPU Voltage rises above or drops below" & b()
            $Output = $Output & "1/10th of your Current Voltage Detected." & b()&b()
            $Output = $Output & "                Want to Continue?"& b()& b()
            $Output = $Output & "Click Yes to Continue or Click No to Abort." & b()
            If ShowMe($Title,$Output,100)=7 Then
                Bye()
            Else
                Return
            EndIf
        Case $lvl = 1;below tolerance
            $Title = "CPU Voltage Alert"
            $Output=""
            $Output = $Output & "Your CPU Voltage is below tolerance."&b()&b()
            $Output = $Output & "        Minimum Voltage  : "&$min&" V"&b()
            $Output = $Output & "        Detected Voltage : "&$current_voltage&" V"&b()&b()
            $Output = $Output & "   Do Emergency Shutdown?"&b()
            If ShowMe($Title,$Output)=6 Then
                $sdnow=1
                Bye()
            Else
                Return
            EndIf
        Case $lvl = 2;above tolerance
            $Title = "CPU Voltage Alert"
            $Output=""
            $Output = $Output & "Your CPU Voltage is above tolerance."&b()&b()
            $Output = $Output & "        Maximum Voltage : "&$max&" V"&b()
            $Output = $Output & "        Detected Voltage : "&$current_voltage&" V"&b()&b()
            $Output = $Output & "   Do Emergency Shutdown?"&b()
            If ShowMe($Title,$Output)=6 Then
                $sdnow=1
                Bye()
            Else
                Return
            EndIf
        Case Else
            Return
    EndSelect
EndFunc

Func GetVoltage()
    Local $objWMIService, $strComputer = ".", $objItem, $colItems
    Local $voltage
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    $colItems = $objWMIService.ExecQuery("Select * from Win32_Processor")
    If IsObj($colItems) then
        For $objItem In $colItems
            $voltage=$objItem.CurrentVoltage
        Next
    EndIf
    $voltage = StringLeft($voltage,1)&"."&StringRight($voltage,Stringlen($voltage)-1)&"00"
    Return $voltage
EndFunc

cpu_voltage_monitor.au3

Edited by rhg
Link to comment
Share on other sites

Link to comment
Share on other sites

It's been updated...*alot*. Try the new one although not sure it will make a diff if the v0.2 returned 0. :geek:

I have no idea what platforms this will work on HW/SW wise as not many have tried it yet. :o

Hm..and speedfan works but this doesn't...did you run this with sppedfan disabled? Also, does speedfan return 1/10 or 1/100 or 1/1000 readings? Like does it give you 1.023V--like that? or like 1.1V ...?

Thanks for the feedback..wasn't my idea actually. Just trying to help out a freind. ;)

Edited by rhg
Link to comment
Share on other sites

Speedfan gives me 1.65v for my core. I closed it and i still get 0.0 in this program. like i said i have a cheap board, speedfan is actually the only program that gave me any readout at all, so I'm not surprised it didn't work.

Link to comment
Share on other sites

@PerryRaptor

Awesome....are you running 64-bit XP on that 64-bit computer? Just curious. Thanks for trying it out and leaving some feedback. :geek:

@mikeytown2

No problem...there were some additional requests after v0.2 so I just added them along with some things I wanted to try, and learn some new things. Thanks for trying it both times and letting me know your config and stuff. :o Is inspiring me to find more about accessing device I/O directly...I might have to try some ASM maybe or some existing COM. All the same thanks.

Link to comment
Share on other sites

Works ok with WIN XP Pro 2 and an old:

Processor x86 Family 6 Model 4 Stepping 4 AuthenticAMD ~1332 Mhz

BIOS Version/Date Award Software International, Inc. 6.00 PG, 2/20/2002

SMBIOS Version 2.3

VIA motherboard

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Ok, so now we have hit some limitations...this is good. Cheap Syntax boards (just quoting) and Dual Opteron Tyan boards are out of the question but from the few handful of people that have tried says it works.

Also tested an IA-64 w/XP 64-bit and another PIII Mobile and both worked as well.

@PerryRaptor - I tested on a dual MP 1800+ on Tyan w/2003 and also this failed...came back 0. Maybe coincedence...then again maybe not?

I wonder though if I can access device I/O directly with au3? Specificaly motherboard sensors similar in the way that SpeedFan does. I guess the big thing there is that they actually catalog the different motherboard's and the respective BIOS/Specs. To be honest I am not interested in such an undertaking but I am always curious. :o

Thanks guys for the feedback and checking this thing out for me. Guess now we wait and see if it actually works; like a real scenario where it detects something out of tolerance and returns an alert....something to hope for at least. :geek:

-rhg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...