Showing posts with label calculation. Show all posts
Showing posts with label calculation. Show all posts

14.2.10

WD MyBook Hacks - Temperature Readings

This is a topic that puzzled me for some time. Built-in temperature sensors are useful for monitoring the health status of the device and making proper action if for instance overheating occurs. For personal computing, lm-sensors is a frequently-used tool for this purpose which is able to read the sensors via SMBus on most of the motherboards. However, the MyBook has a different facility for this, so we will see how to take advantage of it. In fact, not only the on-board temperature sensor can be read, but the one on the hard drive can be used as well.

Reading sensor on the hard drive

This sensor can simply be reached through reading the S.M.A.R.T. data of the drive as I posted earlier. What we need to do is to grep the useful data and get rid of the garbage by selecting the line and the field we are interested in:

#~: smartctl -a -d ata /dev/sda | awk '/Temperature/ {print $10}'
44

will do the job, and we get the temperature of the hard drive in Celsius.

Reading the on-board temperature sensor

This one can be interrogated through:

#~: cat /sys/module/thermAndFan/parameters/current_temp
27

which is a reasonable value. If however we look further into the details:

#~: cat /sys/module/thermAndFan/parameters/hot_limit
16
#~: cat /sys/module/thermAndFan/parameters/cold_limit
104

this should give the clue that this is not a direct temperature reading. Indeed this sensor does not read in Celsius but rather in "Counts" which is proportional to the sensor resistance value. Luckily enough google finds the lookup table for this platform here (see TvsCnt[] array). As the sensor is a semiconductor thermistor, there is no simple linear equation to determine the temperature, rather the following exponential dependence should be used: Cnt=a×exp(b/T), with Cnt being the reading above and T being the absolute temperature in Kelvin. For this specific sensor the parameters are a=1/9331 and b=3865 as a result by a simple fitting procedure. So after some algebra we find that the temperature will be: t=3865/(ln(Cnt)+9.1411)-273.16 in Celsius (feel free to do it in Fahrenheit :) ).

In order to implement this equation, we will use the command-line calc tool:
#~: ipkg install calc

Finally using this tool a simple script can be used to determine the temperature:

#!/bin/sh
Y1=`cat /sys/module/thermAndFan/parameters/current_temp `
C1='display(0);config("tilde","off");3865/(ln('
C2=')+9.1411)-273.16'
/opt/bin/calc $C1$Y1$C2 | awk 'NR==3 {print $1}'  

which results in a single return value, e. g. 37.

Finally the question remains: Why would we do this? The reason is that these readings can be plotted using for instance MRTG, so that the health status of the storage can be checked easily.

28.1.10

Inside a LED lamp

Using LED lamps instead of incandescent bulbs and fluorescent lamps is argued to be power efficient thus economically favorable. Longer life span is also usually cited as an advantage. I wanted to look into the details for a long time and recently I ordered some LED lamps on ebay, so I took one of them apart to see what is inside...
The lamp is a 48 LED device, and is written to use 4.5W on a 230V power supply. My intention is to present the schematics of the lamp so that we can see the details of its operation.

LED basics:


Just to understand the main building block of the lamp: LEDs (light emitting diodes) are semiconductor heterostructure devices meaning that they have rectifying properties so that current only passes through one direction, while in the other way around it doesn't. While this is true for all diodes, the plus for LEDs is that light emission will happen only when they are conducting. Even if this is the case there is a certain threshold for the light emission to start which is around 3.5V for blue and white LEDs. Above this threshold the current through the device rises exponentially so it needs to be regulated which is usually achieved by either an external resistor in series or a current generating power supply circuit.

LED lamp:


Let's see what we have here: Regulation on the AC side is done by C1 as it acts as a finite impedance at 50Hz. The point is that the this is achieved without any unnecessary dissipation as there is no heat generated on C1. D1 is an integrated Graetz-bridge which rectifies the input voltage. The role of C2 is smoothing the output and R4 is an additional protection for the LED block. R1, R2 and R3 discharge the capacitors after switching the lamp off (most likely due to safety reasons). I also put some measurement data on the schematics: the 48 LEDs in series operate from a sum of 179V meaning that each LED has a voltage drop of 3.73V on average, in good agreement with our expectations. The 110mV voltage across the 10 Ohm resistor tells that 11mA flows through the LEDs meaning that the dissipation of the block is 11mA×179V=1.97W which is way lower than the expected 4.5W! Indeed it is not surprising that the light output of this lamp is not enough especially if compared to compact fluorescent lamps. The power factor can also be calculated: the voltage drop over C1 is 124V leading to a  power factor of 0.84. This value of course becomes important if LED lighting is to take a major role in households.
In conclusion it turns out that the electrical circuit is as simple as possible leading to a high average lifetime of the device (I expect it to be comparable to the couple of thousand hours of compact fluorescent lamps). No 50Hz wobbling of the light output is also a benefit of the device. However the efficiency of the principle described above is given by the fact that many low power LEDs was put in series leading to a voltage drop of 179V on the LED block with only 11mA current consumption. High power LEDs cannot be used this way since each single (!) chip has a light output better then this entire block while consuming several hundred mA-s at around 3.5V (a good example is Cree's XLamp series). This means that a more complicated power supply is necessary for such a LED lamp which together with the more expensive LED means more expensive device but way better light output as well (especially true for devices equipped with three or four high power LEDs), so I recommend buying such a lamp instead of these cheap ones.

16.1.10

Why not charging battery on wifi signal?

I just became aware of this nice piece of video made on CES 2010.



They argue that batteries of cellphones and similar devices can be recharged by solely relying on power emitted by wifi hotspots. In fact for me this is somewhat hard to believe so let's make some calculations:
First, let's assume that the efficiency of the device is 100%, meaning that all received signal is converted to battery power (this is quite optimistic, since charging up a battery usually worse than 70%). Anyhow, if we have a single cell LiIon battery of 1500mAh, that will need approximately 1.5Ah*3.7V=5.55Wh energy input to be charged up completely.
Now let's see the other side of the equation: According to this howto page, the maximum transmitted power of a wifi hotspot can be 1W. This itself would be sufficient if we can catch everything, our battery is charged up in 5.55 hours. In fact, usually this is not the case (luckily for others, because they still would like to use wifi as it is intended :) ). For me it seems, that the size of the device is around 5cm × 10cm, giving an area of 50cm^2. You can measure this for example at 2:24 in the video above, where you have the hand of the guy for comparison. In this case, if we are 1m away from the access point, then this 1W goes through an area of 12.5m^2 (simply assuming that it the pattern isotrop), meaning that we catch 0.005/12.5=0.0004 part of the transmitted power. This is 0.04%! Anyhow, we get a power input of 0.4mW, so the time we need to charge up the battery above will be:
5.55Wh/0.0004W = 13875h = 578 days = 1.6 years.
I think I have been quite generous with the approximations above, so this might be some sort of best case scenario :) In fact, if go further away from the access point, the power input will cut off with the second power of the distance, and also the power conversion can add a factor of at least two.
I anyhow wish good luck for every end users so that they can make a single charge once every elections :)