Monthly Archives: September 2015

Solution to why Windows 10 randomly wakes up from hibernation

Here is another issue I have been having since upgrading to Windows 10: I often find that the computer has woken up from hibernation, which is of course irritating since it unnecessarily consumes power. I did some googling and found a number of things that could be the cause, like the mouse, keyboard or network interface being able to wake the computer up. Turning all of these off did however not stop the computer from waking up.

Also, a recommendation was to issue the following command in a cmd window to figure out why the computer woke up:

C:\WINDOWS\system32>powercfg /lastwake
Wake History Count - 1
Wake History [0]
  Wake Source Count - 0

In my case the response unfortunately says nothing about why the computer woke up, which seems like a major shortcoming.

Then I tried the following:

C:\WINDOWS\system32>powercfg /waketimers
Timer set by [SERVICE] \Device\HarddiskVolume2\Windows\System32\svchost.exe (SystemEventsBroker) expires at 15:46:51 on 2015-09-27.
  Reason: Windows kör den schemalagda aktiviteten NT TASK\Microsoft\Windows\Media Center\mcupdate_scheduled som kräver att datorn aktiveras.

This did give a useful hint since it told me that mcupdate_scheduled was set to wake the computer up at 15:46:51 the next day, presumably to update Media Center. I do not want the computer to wake up to install updates, so I found out that scheduled tasks can be controlled by “Schedule tasks” (or “Schemalägg aktiviteter” as it is called in my Swedish W10 installation). In it I was able to dig down to Media Center and disable its daily checking for updates, see screenshot below (again, it is from my Swedish installation, but I guess it is it trivial to figure out how to do the same thing in an English W10).

Media Center update scheduling
Media Center update scheduling.

I clicked the circled Deactivate (“Inaktivera”) button to disable the scheduled updates and after this the powercfg /waketimers gave the following response:

C:\WINDOWS\system32>powercfg /waketimers
There are no active wake timers in the system.

Another way of checking for tasks that could wake up the computer is to run Power Shell and the following command:

PS C:\Users\Per> Get-ScheduledTask | where {$_.settings.waketorun}

TaskPath                                       TaskName                          State
--------                                       --------                          -----
\Microsoft\Windows\.NET Framework\             .NET Framework NGEN v4.0.30319... Disabled
\Microsoft\Windows\.NET Framework\             .NET Framework NGEN v4.0.30319... Disabled
\Microsoft\Windows\Media Center\               mcupdate_scheduled                Disabled

Apparently, no task is currently about to wake the computer up. Good.

I also found the following Power Shell command that can be used to disable scheduled wake ups:

Get-ScheduledTask | ? {$_.Settings.WakeToRun -eq $true -and $_.State -ne "Disabled"} | % {$_.Settings.WakeToRun = $false; Set-ScheduledTask $_}

I hope that this will be the end of the computer waking up all by itself. If it is not, I will continue to run the above commands again to see if any new wake timers have popped up.

Update 2016-01-04

Even though the frequency of unwanted wakeups seemed to be much reduced by the above measures, they sometimes occured anyway. Maybe I have just not found and disabled enough things that can cause a wakeup. I have given up on hunting these down, so instead I connected the computer and monitor to a power strip with a switch that I use to remove power from the computer once it has started to hibernate. As long as I remember to turn off the switch, this is guaranteed to prevent the computer from waking up while in hibernation.

Update 2016-10-01

A couple of times I have noticed that my mouse has reverted to being able to wake the computer up. Maybe this happens during some Windows updates. Some of the spurious wake-ups have probably been due to e.g. the scroll wheel on the mouse moving half a notch by itself which might happen if it accidentally was left between two notches. A straightforward way to verify if this can happen is to put the computer into hibernation and then start moving, clicking and scrolling on the mouse. Also try the keyboard while you are at it. To disable wakeup from mouse or keyboard, go to the device manager, right click on the device, select the Power Management tab and disable the wake-up option.

Another thing I have found that can wake the computer up is if I connect am mp3-player to a USB hub while the computer is hibernating, but I have found no setting to disable this.

Still, the trusted old power switch on the power strip without any software involved remains the most reliable method of preventing the computer from waking up when it should not.

Update 2018-03-24

It seems like Windows repeatedly starts allowing mice and keyboards to wake the computer up. One way to check which devices can currently wake the PC up is to issue the following command in a cmd window:

powercfg -devicequery wake_armed

Then one can go into device manager, right click on the offending devices, select Properties and in the Power management tab disable the wakeup capability.

It would be really nice if one could set a flag somewhere to never ever enable anything but the power button to wake the computer up to avoid the PC unnecessarily being on and consuming power for long periods when it is not used.

Macro Photography Using a Macro Coupler

Sometimes I want to take closeup photos of printed circuit boards to e.g. document broken or incorrectly assembled components. Given the small size of many components (like 0402 or even 0201), a high degree of magnification is often required. I have a 150 mm Sigma macro lens that can do 1:1 magnification from subject to detector, but this is not always good enough, so I was looking for another solution, preferably going up to a magnification of about 6:1 so that a 4 mm subject would fill up the view of my Nikon D300. Also, I did not want to spend too much on new equipment as this is something I do not do very often.

It turns out that there are a number of ways to make existing lenses more suited for macro photography, namely:

  • extension tubes (reduces minimum focus distance)
  • macro bellows (essentially long and adjustable extension tubes)
  • close-up lenses to put on the front of existing non-macro lenses
  • reversing rings to mount lenses backwards
  • macro couplers to mount one lens backwards in front of another

I did some quick calculations (using information from this page) and figured out that extension tubes or bellows would not give me much of additional magnification. They need to be very long to have much of an effect on long lenses and with shorter lenses the focus distance for large magnification becomes very small.

According to a formula on https://en.wikipedia.org/wiki/Close-up_filter, a close-up lens (or close-up filter as it is also called) needs to have a power of 20 diopters to give a 6:1 magnification on my 70-300 mm lens and 33 diopters on my 150 mm macro lens. The problem is that such strong close-up lenses seem to be rare and if they exist they are probably not very sharp.

To get magnification from mounting a single lens in reverse, the focal length needs to be short. From a 50 mm lens, the expected magnification is probably only about 1:1, so this did also not seem like a very good option.

The solution I opted for was instead to use a macro coupler to mount my 50 mm f/1.4 lens backwards in front of my 70-300 mm zoom. A 50 mm lens has a power measured in diopters of 1/(0.050 m) = 20 diopters, so it will act as a close-up lens that powerful, giving a magnification at the 300 mm setting of about (300/50):1 or 6:1.

Since the 50 mm lens has a 58 mm thread and the zoom has a 67 mm thread, I needed a step-up ring from 58 to 67 mm and a 67-67 mm macro coupler ring. I found inexpensive ones at a local Internet shop, http://kaffebrus.com/step-up-ringar-121.html and http://kaffebrus.com/adapterring-koppling-122.html. Total cost was 147 kr or about $18.

This is what it looked like when I used the rings to mount the short lens in backwards in front of the zoom lens on the camera:

50 mm lens in front of 70-300 mm lens.
50 mm lens in front of 70-300 mm lens.
50 mm lens in front of 70-300 mm lens.
50 mm lens in front of 70-300 mm lens.

DSC_6707_sm

One thing that immediately becomes apparent when looking into the viewfinder is how dark it is. This is due to the fact that the 50 mm lens goes to minimum aperture when it is not connected to a camera, so it lets in very little light. There is no aperture ring on this lens, but there is a small lever in the mount that one can manually pull to increase the aperture and I found that it is possible to put a piece of tape on the lever to fix it in a desired position. Small aperture is good to get maximum depth of field, but it can be hard to see the subject unless the lighting is very bright, so taping the lever to maximum aperture while composing the scene and then removing the tape before taking the shot might be a good idea.

Aperture lever
Aperture lever

The aperture of the zoom lens seems to not be very critical, but it should be open enough to not cause vignetting. Also, zooming out far away from 300 mm causes vignetting, so the setup is mostly useful at or close to 300 mm.

It is of course necessary to use a tripod and in order to get as sharp photos as possible, one needs to take every reasonable step to reduce vibrations, like using a remote shutter release cord and the mirror-up mode so that the mirror does not cause camera shake.

A future improvement would be to build a focusing rail and apply focus stacking to get a greater depth of field. Building a stepper motor controlled focusing rail could be a fun project.

Below are some test photos I have taken with the setup.

Millimeter lines on the scale of a caliper. The field of view is about 4 mm wide.
Millimeter lines on the scale of a caliper. The field of view is about 4 mm wide.
Detail from a 100 kr bill.
Detail from a 100 kr bill.
An 0603 inductor and an 0402 capacitor.
An 0603 inductor and an 0402 capacitor.
An integrated circuit I made around 1995 as a project at the university. The technology is 0.8 µm CMOS.
An integrated circuit I made around 1995 as a project at the university. The technology is 0.8 µm CMOS.
Pins of a TQFP package, of which one is broken and another is damaged.
Pins of a TQFP package (0.5 mm pitch), of which one is broken and another is damaged.
Detail from a flower.
Detail from a flower.
Two 0603 resistors.
Two 0603 resistors.
A SOT23 component.
An SOT23 component.

 

Prolific USB to serial port adapter in Windows 10

Here is the solution to another issue I experienced after upgrading to Windows 10.

Two different serial port adapters with Prolific PL2303 chips (with VID 067B and PID 2303)  did no longer work. Some googling brought up the below page which claims that the problem is counterfeit chips and new drivers trying to fight that, but I am not at all sure this is the real issue. Anyway, the solution (allegedly an old driver) offered on the page solved the problem:

http://www.ifamilysoftware.com/news37.html