Changes between Version 1 and Version 2 of VoltageLabelsAndScaling

Show
Ignore:
Timestamp:
03/01/12 14:18:59 (15 months ago)
Author:
khali
Comment:

Go on with the voltage labels and scaling article

Legend:

Unmodified
Added
Removed
Modified
  • VoltageLabelsAndScaling

    v1 v2  
    1212First of all, we need reference values to know which result we are supposed to get to. In most cases, the reference will be the BIOS, which typically displays all monitored values. So, boot your machine and go to the BIOS, and write down on a sheet of paper the label and value for every voltage being monitored. If you can spot more than one value per item, this is very useful, so write down all values. The reference can also be a piece of software provided by the vendor. 
    1313 
    14 Once you know which voltages are being monitored and their values on your specific systems, go to Linux and run {{{sensors}}}. We will try to figure out the proper labels and scaling factors. For this exercise, we need to know the ADC range of the chip. Here is the answer for the most popular Super-I/O chips: 
     14Once you know which voltages are being monitored and their values on your specific systems, go to Linux and run {{{sensors}}} (or even {{{sensors -u}}} which is even more accurate.) We will try to figure out the proper labels and scaling factors. For this exercise, we need to know the ADC range of the chip. Here is the answer for the most popular Super-I/O chips: 
    1515 
    1616 * Old Winbond Super-I/O chips (W83627HF, W083627THF, W83637HF, W83687THF, W83697HF, driver = w83627hf): 0 to 4.08 V, 1 bit = 16 mV 
     
    2121 
    2222For other chips, try to find the answer in the datasheet, driver documentation or source code. 
     23 
     24Then we can start comparing the values reported by the BIOS with the values reported by {{{sensors}}}. I will use the Asus E35M1-I Deluxe motherboard as an example. This board uses an ITE IT8771 chip for hardware monitoring. According to the table above, its ADC ranges from 0 to 3.06V with 1 bit = 12 mV. 
     25 
     26The BIOS reports the following voltage values: 
     27 
     28{{{ 
     29CPU: 1.368 V 
     303.3V: 3.33 V 
     315V: 5.003 V 
     3212V: 12.072 V 
     33}}} 
     34 
     35The (unconfigured) {{{sensors}}} command reports the following voltage values: 
     36 
     37{{{ 
     38in0:          +1.36 V  (min =  +2.15 V, max =  +2.69 V)  ALARM 
     39in1:          +2.23 V  (min =  +1.24 V, max =  +2.56 V) 
     40in2:          +2.90 V  (min =  +1.14 V, max =  +0.95 V)  ALARM 
     41+3.3V:        +3.34 V  (min =  +4.75 V, max =  +2.28 V)  ALARM 
     42in4:          +2.23 V  (min =  +1.51 V, max =  +3.05 V) 
     43in5:          +2.93 V  (min =  +3.01 V, max =  +2.93 V)  ALARM 
     44in6:          +2.23 V  (min =  +1.60 V, max =  +1.63 V)  ALARM 
     453VSB:         +3.38 V  (min =  +2.83 V, max =  +2.18 V)  ALARM 
     46Vbat:         +3.29 V   
     47}}} 
     48 
     49Here we are lucky that some of the inputs have internal mapping and scaling so the driver already applied proper scaling and labels to them. In particular the +3.3V line is already OK. 3VSB and Vbat are also OK, so we get them for free even though the BIOS doesn't even list them. This leaves us with 3 voltage values to map and optionally scale: CPU, 5V and 12V. 
     50 
     51We'll start with CPU as it is the easiest one. Voltage of modern processors is relatively low, always inside the ADC range so scaling isn't needed. So we are looking for an input with value 1.368. {{{in0}}} is a very obvious candidate. Note that we are again lucky here because most modern processors can operate at different voltages depending on the frequency, so the value from {{{sensors}}} doesn't necessarily match what the BIOS shows. Frequency scaling is usually not in effect under the BIOS setup screen so you should either temporarily disable it under Linux as well or put heavy load on the CPU while trying to do the input match. On the plus side, note that the CPU voltage (Vcore) is almost always connected to {{{in0}}} so it's a safe bet if there's nothing contradicting this hypothesis. 
     52 
     53For 5V and 12V, things are a little harder. Both values are above the ADC's range (3.06 V) so we aren't looking only for mappings but also for scaling factors. Unfortunately it's not possible to find the mappings if you don't know the scaling factors (comparing the scaled values from the BIOS with the unscaled values from {{{sensors}}} doesn't work), and it would seem impossible to guess the scaling factors if you don't know the mapping. Looks like a dead end to you? Not really. All this means is that we have to be smart. 
     54 
     55Let's [http://www.google.com/search?q=Asus+E35M1-I+Deluxe+BIOS&hl=en&prmd=imvnsfd&source=lnms&tbm=isch&oi=mode_link&ct=mode&cd=2&biw=1682&bih=859 search the web for snapshots of BIOS pages from other users with the same board]. As motherboards tend to get a lot of online reviews, it's usually not too difficult. Then we write down all sample values we can for 5V and 12V, and add them to the ones we already got from our own board. After sorting, we get the following: 
     56 
     57{{{ 
     58 5V samples: 4.942 V, 5.003 V, 5.024 V, 5.147 V 
     5912V samples: 11.872 V, 11.922 V, 12.072 V, 12.122 V 
     60}}} 
     61 
     62Here again we are somewhat lucky, hunt was good and we have 4 sample values for each input. Each of the values above corresponds to an 8-bit register value, which is multiplied by 12 mV and then by the scaling factor for the respective input. As registers can only hold integer values, we know that the values listed above are separated by an integer number of 12 mV * scaling factor steps, and the integer numbers in question will always be small (typically 1, 2 or 3.) From this we should be able to guess the scaling factor. 
     63 
     64Let's start with 12V. The differences between the 4 values are as follows: 
     65 
     66{{{ 
     6711.922 - 11.872 = 0.050 V 
     6812.072 - 11.922 = 0.150 V  
     6912.122 - 12.072 = 0.050 V 
     70}}} 
     71 
     72From the above, it seems clear that 1 LSB of the ADC corresponds to 50 mV after scaling. And we know that it corresponds to 12 mV before scaling. So we can conclude that the scaling factor is 50/12. And we validate this conclusion as: 
     73 
     74{{{ 
     7512.072 V / (50/12) = 2.897 V 
     76}}} 
     77which is close enough to {{{in2}}} (2.90 V). If it had not worked, we would have tried again with the assumption that 2 LSB of the ADC corresponds to 50 mV after scaling. Then 3 LSB, etc until the candidate scaling factor is below 1, which never happens. 
     78 
     79And now we do the same for 5V: 
     80 
     81{{{ 
     825.147 - 5.024 = 0.123 V 
     835.024 - 5.003 = 0.021 V 
     845.003 - 4.942 = 0.061 V 
     85}}} 
     86 
     87It is slightly more difficult this time because there are some rounding errors, but still: it seems that 1 LSB of the ADC corresponds to about 21 mV after scaling. To limit the rounding errors, best is to divide the difference between the greatest and least values by our estimation of the number of ADC steps between them: 
     88 
     89{{{ 
     90(5.147 - 4.942) / (6 + 1 + 3) = 0.0205 V 
     91}}} 
     92so our guess is that 1 LSB of the ADC corresponds to 20.5 mV after scaling. And we know that it corresponds to 12 mV before scaling. So we can conclude that the scaling factor is 20.5/12 or 205/120. And we validate this conclusion as: 
     93 
     94{{{ 
     955.003 V / (205/120) = 2.929 V 
     96}}} 
     97which is close enough to {{{in5}}} (2.93 V).  
     98 
     99Finally we can write the partial configuration file which corresponds to our findings: 
     100 
     101{{{ 
     102chip "it8771-*" 
     103 
     104### Voltages 
     105 
     106   # in1, in4 and in6 all read +2.23V, no idea why. 
     107 
     108   label  in0   "Vcore" 
     109   ignore in1 
     110   label  in2   "+12V" 
     111   ignore in4 
     112   label  in5   "+5V" 
     113   ignore in6 
     114 
     115   compute  in2  @ * (50/12), @ / (50/12) 
     116   compute  in5  @ * (205/120), @ / (205/120) 
     117 
     118   set in0_min   0.7 
     119   set in0_max   1.5 
     120   set in2_min  12   * 0.95 
     121   set in2_max  12   * 1.05 
     122   set in3_min   3.3 * 0.95 
     123   set in3_max   3.3 * 1.05 
     124   set in5_min   5   * 0.95 
     125   set in5_max   5   * 1.95 
     126   set in7_min   3.3 * 0.95 
     127   set in7_max   3.3 * 1.05 
     128}}} 
     129 
     130And now, good luck with your own motherboard!