All posts by Bastiaan

Arduino Waits

I’ve written a little script to use an external routine for waiting purpose on the Arduino. It makes much more sense than using the “delay()”. Since that has it’s limitations. This subroutine can be called from anyway where you need (custom) wait time. Enjoy!


Arduino LED Light

You know those Philips very expensive LED lights? Yeah, we can do that too! But a lot cheaper. Order some Arduino’s, get some RGB leds from a famous Chinese source and get coding! I’ve made a little example here:

Twitter link

It fades in when it becomes too dark. This takes about 10 secondes and it fades out when the light returns to normal. This is ideal for a night light or just regular lights in the living room. The concept is sound. I orginally tried to make each R, G and B led to fade in/out depending on the resistance of the LDR, but gives a really annoying flickering in most cases, so I decided to just fade in and fade out.

The code, nothing fancy, but it works nice. I’m using three LDR’s to get a good average reading, but I guess you can go with one if you want.


Lego Tracksections

And we are back for the next level! It’s time to divide up the track in sections so we can have a couple trains driving around. I found the blog at really interesting because it makes use of photosensors. I used microswitches, but they tend not to work really well with a carpet and everything, so I started using LDR’s instead. The result looks a bit likes this:

IMG_3028 IMG_3027 IMG_3026

I used a couple little prints to put the LDR’s on with a 10k Ohm resistor as voltage divider. This works pretty much ok. In the last picture you can see the first attempt of the setup. In the meantime I changed it a little bit, but not too much. The “railplan” looks like this at this point:


In short, this is what happens so far:

1. Get the sensor reading

2. Determine the previous sensor (so you know which way your train is going)

3. Set the correct flags so we can call a function to get the trains up and running (e.g. what section will the train in be next?)

4. The function to get the trains running checks for some things. Of course we need to know if the next section to where the train is going will be busy or not. This can later be used to set switches and signposts!

As of this evening the sensors started acting up, but my detection mechanism worked flawlessly. It gives the current position, train number and next section via the Arduino Serial Monitor.

Ah well, more to fiddle around with! Catch you later!

Lego on Arduino

For the past couple days I’ve been working on getting my Lego trains to run via an Arduino (actually, it’s a fake one, but who cares!). On my YouTube channel (link) you can find my first attempt at stopping and starting with ease-in and ease-out. It’s, ofcourse, done with an infrared light, but the track is too big, so I ordered more LED’s from China. Takes a while to get here though …

The next task will be dividing the track into sections so two trains can drive the same track, but stay out of each others hairs and/or pass each other. After that there will be, hopefully, signalposts and automated switches.

The track division is made with old “micro” pushbottons from some alarmclocks. For now this works fine, but I’m planning on using LDR’s instead. The pushbutton methode dates back to about the stoneage, but it still works fine. I’ll be posting a movie about that soon.

B.t.w, you should also check out Got some inspiration from there. I also Roland Wiersma a lot of thanks for creating the LegoPowerFunctions library for Arduino, found on GitHub. This library works really well!


Monitoring CPU Wait Time in SCOM 2012 R2

Dear readers,

For the purpose of this article and readability I will write in English (or Engrish …). First of all, in the default Hyper-V MPE 2012 SCOM MP there are a lot of nice things and monitors. One of them, however, is missing from this bunch. This is the CPU Wait Time Per Dispatch. This counter is read from the Virtual CPU instance of the Hyper-V host. The counter itself means “how much time does it take before my vCPU can get some real CPU time”. In VMWare they call this the CPU Ready counter by the way. One of our consultants mentioned we need to monitor this thing. So, all good and well, let’s get to it!

Within SCOM I will show you two things, basically eveyone can do this. How to create a rule for measuring Performance. This will output some nice graphs and might be handy in troubleshooting or judging performance base lines. After that we’ll be making a Monitor to send out alerts if VM’s bite of more than they can chew.

First, the rule. Start by creating a new Performance Based Rule and select your destination management pack.


The target for this rule is not a default target, so don’t forget to select “View all targets” and search for the Hyper-V MPE 2012 Virtual Processor:


After that, set the counter to “CPU Wait Time Per Dispatch”. This name is exactly as it comes from the perfmon counters (really weird huh…?), so type that in. This way you can also create other counters if you’d like to do that 🙂

As a rule of thumb I set the interval to 5 minutes. You shouldn’t go to fast because you will take up too much time processing all the requests. The other Hyper-V MP rules also are set for five minute intervals in most case, hence my choice. For the target select “VP Instance” from the Arrow-ed menu. Also, type in the object manually. I’ve done this whole rule based on the “% Guest Run Time” rule (which is bullocks if you ask me) and it was in there like that. I figured I’d do that too.


Well, next and finish!

For the performance view I used the following settings. Note the “Show data related to” setting. Select your rule, et voilá! It can take some time before the stats start piling up. In my case I had to take a big lunch break of about 45 minutes…


After that, we create a Performance Based monitor. It’s a single treshold monitor, nothing too fancy. I like to use consectutive samples because that way you can tweak your monitor pretty good when all is setup. It allows for maximum flexibility when overriding.


I like my custom monitor disabled so I can tweak a bit before I turn them on, your choice!


Here I also set the interval at five minutes because I will override the monitor anyway when I enable it.


I basically set the monitor to 100.000. From what I’ve seen, a starting VM will rise up to about 80k and running VM’s between 30k ~ 50k. But you can see for yourself and see what counters work for your enviroment.


I like to see this as a warning. After all, your VM is just like a snail breaking before a corner, but it’s still working.


And finish up by making a really cool message of sorts.


So, after this, override the Monitor to whatever group you see fit. Here’s an example of a performance graph (these machines just restarted after a Host reboot):