Hainey Associates LLC

Circuits and Software Development


IoT Embedded Systems

Contact: info@haineyassociates.com

View Herb Hainey's profile on LinkedIn

Dragon Tail - Enchantments

Computer Vision * Impedance Matching * Energy Conversion * Radios/RF * Renewables * Education * Online * Community

Computer Vision

 For years I have enjoyed watching hummingbirds come to the feeder just outside my window.  Their antics are amusing.  They can be feisty little birds when they try preventing other hummers from using "their" feeder.

My curiosity has had me wondering how much they eat, how much they weigh, how fast they fly, and recently, how often they come to the feeder.

I have been working with some Computer Vision software and decided to try and count hummingbirds using software and a USB webcam.  I chose to use Python 2.7 and OpenCV 2.4, originally planning to use my new Raspberry Pi 2 as the host. 

I've not yet gotten satisfactory performance from the Pi.  I suspect it is the USB webcam driver that is causing the problem.  In the meantime, I've switched over to Windows 7 with JetBrains PyCharm as my Python IDE.

At this point I am using a two step process to count the birds.  First I use a simple Python program to access the webcam and record an .avi video of the feeding birds.  I use the mouse to start and stop the recording as birds come and go.  A second program scans the .avi file using some simple OpenCV functions to determine when a bird approaches.  Each approach is counted and displayed on the screen along with a frame count.

Take a moment and watch the video listed below.  In it, a new hummer approaches the feeder for the first time trying to figure out just where the food is.

** Source code can be downloaded from here: ViewAVI.zip


Hummer Face/Pix 


Traffic Monitor

 For this project I used OpenCV to establish frame by frame reference points for hand shot video of multilane vehicle traffic.  Color video is read from a file and processed frame by frame to track the white lane markers as reference points. A color overlay shows frame number (yellow), reference point rectangle location (red) and orientation (green).

Each frame is first converted to gray scale and filtered. Next Canny edge detection finds edges within a given range of sharpness.

After the edges are detected, they are used to find contours. The contours are then analyzed to find the minimum area enclosing rectangles.

Finally the length, width, and orientation of the rectangles are used to identify the frame reference points.


** Source code can be downloaded from here: ViewAVI.zip

My pedometer got accidently reset to zero when I was about 800,000 steps toward my goal of 1 million steps.  I modified the reset button to prevent further resets and devised a mechanism that could "reload" my lost steps.

The guts of an old VCR mechanism and some string were assembled into a stride simulator.  Adjusting the lengths of the strings and the speed of rotation gave a cadence of about 120 steps per minute. 

I was able to track the motion of the pedometer using a simple pattern matching algorithm.  The red dot tracks the center of the pedometer.  The x and y coordinates of the dot and the frame number are displayed in yellow.  The blue dots leave a bread crumb trail showing the relative motion.  In the lower left corner is a stabilized view of the pedometer.

Varying the background color made the LCD digits more or less readable.  The gray background produced the best readability of the digits. 

Analysis of the motion revealed a driven frequency of 1.93 hz. and natural frequencies of 0.70 and 1.20 hz.

Impedance Matching

Impedance Matching is talked about in connection with radio frequency circuits.  How is matching accomplished and why is it helpful?  Start by determining the two impedances you are trying to match.  Then use the Smith Chart as a graphical tool to determine what form of matching circuit is needed and what the component part values are.

A simple R-L-C Load impedance is scanned using an HP 3577B VNA with HP 35677A S-Parameter Test Set.  The impedance is displayed in the lower half of the Smith Chart indicating the load appears Capacitive over the scanned frequency range of 1.0 to 5.0 Mhz

Z Load Scan

A matching circuit consisting of 3.9uH inductor in series with the R-L-C load shifts the resonant loop near an ideal 50 ohms

Read about the details: SimpleMatchingExample.pdf

Matched Load

Energy Conversion

Developed SEPIC and Buck topology NiCd and NiMH battery chargers

Buck Converter

Developed this tiny circuit that uses a 9V battery to create the +/-17V rails needed for a +/-15V instrumentation output

Flyback Switch

Developed Flooded Cell/AGM Battery Monitor 12/24/36/48V

This simple low power device automatically determines system battery voltage at "Power Up", auto-ranging up as the battery charges.
See: MidniteSolar (scroll down)

Battery Monitor

My AC inverter died.  To get some IGBT experience, I traced out the bipolar circuit then modified the system to use IGBT devices.

Flyback Switch

Developed a 250V/3000W PWM controlled Active Dump Load for Wind Turbines.  Testing a 3000 watt load can quickly generate a lot of heat.  Getting FETs to work reliably while switching 250Vdc made for some challenges.  Failures while testing prototypes were often spectacular!

Flyback Switch

Sometimes there isn't much physical space available for product enhancements.  This coulomb counter / gas gauge had to be divided into two boards for it to fit into the available space

Gas Gauge


Wireless technology is becoming ubiquitous. I have helped several companies develop radio based products for mining, logging, utility monitoring, and vehicle tracking.

Radios have been an interest of mine since a high school buddy enrolled in a correspondence course to obtain his 1st Class FCC license. I passed the 2nd Class FCC license in high school, followed by a 1st Class license while in college. I was able to defray some of my college expenses by working as a broadcast engineer and DJ for the college FM station. The FCC has replaced my 1st Class license with a General Radio Telephone license. When developing RFID tag systems, I obtained an FCC Experimental radio license.

Learning Morse Code was fun and I worked my way up from Novice (KB7GLH) to Extra Class (AA7AL) and have been affiliated with the W5YI Volunteer Examiner Coordinator program. While living in Arlington, I have served as a radio operator with both the Red Cross and the Snohomish County DEM.

I have designed hardware and software that have been incorporated into a variety of radio systems. I have run numerous tests on radio systems and antennas. Following is a sampling of my radio projects.

Recent Product Development incorporating ZigBee radio modules:

This instrument measures the splice resistance of high voltage power lines.  It is used while the lines are powered.  The lineman may be riding in a helicopter or standing in an insulated bucket truck to make the measurement.

See: SensorLink Radio Ohmstick

SensorLink Radio Ohmstik
See: Rothenbuhler Engineering / Talkie Tooter

Renewable Energy Systems


Data Logging:


Wind speed anemometer

Wind turbine output as blades spin up from zero RPM

in a 20 mph breeze

Anemometer Spin Up Grapgh


Block model of simulated wind turbine

Simulation closely reflects the actual logged data

WindSim1 WindSim1Out

Wind Tunnel Blower - Max center stream output of almost 44mph


Wind Tunnel:

Testing KidWind "Red Prop" in homemade wind tunnel section

Windtunnel Turbinetamer

Mechanical Wind Turbine Simulator

Wind Turbine Simulator

Education and Professional Development

BSE Degree from ABET accredited Walla Walla University
Washington State Licensed PE - Electrical
Member of IEEE Power Electronics, Computer, Controls, and Robotics Societies
IEEE Senior Member
Lifetime Learner
General Radio Telephone License
Extra Class Ham License (AA7AL)

Continuing Education

12/21/2011 Sebastian Thrun and Peter Norvig Introduction to Artificial Intelligence 77.7%
4/06/2012 Udacity CS101 Building a Search Engine High Distinction
6/07/2012 Udacity CS253 Web Applications Engineering Highest Distinction
4/06/2012 Udacity CS373 Programming a Robotic Car High Distinction
Stanley AI Offer

My Online Sensor Project


Service Activities

LEGO Robotics Coach (3 yrs.)

Lego Coach Lego Robotics

Snohomish County/CDC Toxic Algae Study
(3 yrs.)

Snohomish County Volunteer Lake Monitoring Program (5 yrs.)

Lake Monitoring

Whatcom County North Rotary Career Fair Speaker/Presenter (5yrs.)

Career Fair