Home

About

My name is Wayne Lindimore. I’m a Lead System Administrator for a financial services company near Denver, Colorado. I work with Windows, VMware, Citrix and use scripting for automation, reporting and monitoring tasks. I like to learn new things and experiment with scripting on my own time and that will probably be most of what I blog about. Things that interest me include fractals, patterns, image processing, sounds, web services – generally trying to do things which aren’t normally done with PowerShell. I still have a lot to learn about PowerShell and experimenting helps me (hopefully) achieve that.

Advertisements

3 Comments (+add yours?)

  1. Andrew Stephens
    Jan 14, 2016 @ 16:43:13

    Hi Wayne.

    I just briefly reviewed your “PowerShell Stopwatch Demo” – very interesting!!
    I’m looking for a tool to roughly measure the shutter synchronisation for a high count of compact digital cameras.
    At an lcd refresh rate of 60 hz = 16 ms/frame do you think I should always be guaranteed a display difference of 16ms between screen frames using your code?

    PS: do you have any limitation for use of your code or linking to that article?

    Thanks,

    Andrew Stephens.

    Reply

    • wlindimore
      Jan 14, 2016 @ 18:13:03

      Hi Andrew,

      Interesting question. The Stopwatch Class has the granularity to judge 16ms intervals for sure. I’m not sure how you’re going to use that info specifically to validate the sync but here are a couple general thoughts.

      With the PowerShell overhead to process commands I’m not sure you can do much within the interval of the refresh, 16ms. I ran a couple tests and you can see there is not much time to do anything within 16ms before you are well past it.

      # Just Start and Stop
      $stopWatch = New-Object System.Diagnostics.Stopwatch
      $stopWatch.Restart()
      $stopWatch.Stop()
      write-host $stopWatch.ElapsedMilliseconds
      1
      ————————————————————
      # Start, Write-Host, Stop
      $stopWatch = New-Object System.Diagnostics.Stopwatch
      $stopWatch.Restart()
      write-host
      $stopWatch.Stop()
      write-host $stopWatch.ElapsedMilliseconds

      8
      ——————————————————–
      # Start, Test against a variable, Stop
      $a = 0
      $stopWatch = New-Object System.Diagnostics.Stopwatch
      $stopWatch.Restart()
      if ($a -le 1) {}
      $stopWatch.Stop()
      write-host $stopWatch.ElapsedMilliseconds
      8
      ———————————————————
      # Start, Test against the Method, Stop
      $stopWatch = New-Object System.Diagnostics.Stopwatch
      $stopWatch.Restart()
      if ($stopWatch.ElapsedMilliseconds -le 16) {}
      $stopWatch.Stop()
      write-host $stopWatch.ElapsedMilliseconds
      4
      ———————————————————

      You could probably do a single test and a single action.

      Anyway, sounds like a very interesting project. Good Luck.

      You can use that code and link as you wish.

      Best Regards,
      Wayne

      Reply

  2. Andrew Stephens
    Jan 15, 2016 @ 02:49:50

    Appreciate that Wayne. My previous “reviewed your code” really meant I had glimpsed at it 😉

    “… I’m not sure how you’re going to use that info specifically to validate the sync but here are a couple general thoughts.”
    By simply having all the cameras take a photo of the lcd monitor – e.g. with an exposure period of 1ms (and enough light).

    So, to be sure I understand, if, for theoretical example, time since epoch is 0ms up to “just less” than 16ms your stopwatch should display Elapsed Millisec as “0” then when time since epoch is 16ms to “just less than” 32ms as “16” etc.

    I’ve only briefly looked at powershell before but I will dig into it and your code more soon – just currently looking for a “cosy” feeling so hope I don’t seem lazy 🙂

    Thanks again,

    Andrew.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: