This Blog will document projects I have
in progress or completed. You can search for my
handle on Flickr, Facebook, YouTube, or Picasa
for photos. I will link some of those here.

Worlds Smallest Iambic Keyer Paddles

I’ve done a couple of homemade dual lever paddles but recently I wanted to demonstrate my Tiny85 Arduino based keyer project at a local Maker Faire, so wanted something I could put in my pocket. In a few minutes, I made this. It’s a standard 3.5mm (1/8 inch) stereo plug. You can’t get any more portable than that.



Unscrewing the plastic shell reveals the secret sauce.



This is the dash paddle side. Just a tiny bit of thin copper soldered to the plug terminal. For those readers needing details, the copper came from the band around a Basil Hayden’s whiskey bottle.  We recycle!



Here is the dot side.



A  bottom view, you can see the two copper strips and how the sleeve (ground) contact was bent to form the common contact. A little careful tweaking left a thick sheet of paper’s worth of space between each copper strip and the common contact.



And the top side.



I was surprised to find it actually works. Could be useful on a QRP mountain top expedition. Have a look at this YouTube video.

Arduino Display for Liquid Flow Sensors


This project was done for a Friend Of a Friend. He needs to monitor water flow rate and quantity for his solar heating projects. He is mainly interested in this two inch sensor but also sent along a small plastic hose bib type similar to the Adafruit 828. Both of these sensors are turbine types, water flow spins a plastic wheel which magnetically triggers a pulse output proportional to the speed at which the wheel is turning. There’s lots of these sensors made for irrigation and industrial processes. The display is sometimes called a “Totalizer”.

This photo shows the 228PV sensor connected to the prototype display. I am spinning the turbine with air from a heat gun.

Flow Sensor Prototype with Large Flow Sensor

Flow Sensor Prototype with Large Flow Sensor


The electrical interface on the small flow meter has 3 wires, power, ground, and pulse output – relatively simple to connect to the microcontroller. But the large device has only 2 wires. It signals a pulse by shunting power to ground through a low resistance. The display must sense a pulse by looking for an increase in supply current. I designed an interface circuit that works with either unit by changing an option jumper. I constructed the interface circuit on a small piece of project board from Radio Shack (RIP). The positive supply feeds through a resistor which produces enough voltage drop when the large sensor is pulsing to trigger a digital low at the Arduino. The series resistor value is low enough that the power feed is still adequate for the small plastic sensor, so the option jumper just selects where to pick off the pulse signal. A series resistor and zener diode make sure the voltage ratings of the Arduino input pin are not exceeded. It’s a bad thing to overvolt an Arduino pin, please Don’t Ask Me How I Know This.



In this photo you can see the interface board soldered down near the front of the Altoids tin. I use “L” shaped bits cut from a paper clip, soldered to the board ground, and to the ground plane.  The same technique anchors the Arduino board.



Physical Construction

At first I worked up the circuit on a solderless bread board using code from the Adafruit web site. When satisfied with the results, I went ahead with building the Altoids tin prototype. The Arduino variant I used is a Sparkfun Pro Mini 5 Volt. It takes up little space and has a 5 volt regulator with enough capacity to run the 16×2 LCD.  An LED and two push buttons protrude through the lid, these are regular 6mm square PCB buttons. I solder one side directly to the lid, the other side of the switch is supported by a bit of PCB material and a piece of paper clip wire.

This photo shows the LED and the Reset button. Note the bit of PC board on the high side of the switch has a groove filed across so the grounded paper clip is isolated from the signal connection.



This photo shows the Function switch. It’s hard to see, but there is a 0.05 ufd surface mount capacitor soldered between the signal side and ground. That capacitor is part of my debounce strategy.



The Liquid Crystal Display itself mounts on four 2-56 screws. The screw heads are soldered directly to the lid. I attached a 10k Pot for contrast adjustment to the back of the LCD and it’s legs are used as tie points for 5v and ground wiring to the rest of the display.


If I have to build another one of these, I might glue the Arduino board to the back of the LCD which will greatly reduce the wiring between lid and box.


There is a power jack for 9 or 12 volt DC input, and a 3 conductor phone jack to connect the turbine sensor. These are epoxyed to the box.  Connection to the sensor plug is as follows:
Ground to the plug sleeve
Positive lead to the plug tip
If the sensor is a 3 wire type, the pulse lead connects to the plug ring



The opposite side of the box has a simple on/off slide switch mounted.



Software Considerations

Almost all of the turbine type flow sensors I looked at have two calibration factors specified: a “K” factor and an “offset”.  During calibration the manufacturer measures the pulse rate outputs for a number of precise flow rates. These are plotted but since the turbine has some friction, the graph will not be linear especially at the low end and a linear regression is done to get a best fit straight line.  The “K” factor represents the slope of the fitted line and has a dimension of pulses per unit volume moved. Offset represents the small amount of liquid flow required to start the turbine moving. You can assume that if any pulses are arriving at all, at least the offset volume of liquid is moving.  The 228PV manual specifies:
Frequency = (Gallons per Minute / K ) – Offset
We are measuring pulse frequency so turning the equation around:
Gallons per minute = (Frequency + Offset) * K

In general, this formula applies to any measurement unit. It would be possible to convert a gallons display to liters by just scaling the K and offset factors by the constant liters/gallon.  The Adafruit example sketch uses this method but measures pulse period in 1 millisecond increments which creates large gaps in the data if the pulse rate is over 100 Hz. At 200 Hz the pulse period will be 5 milliseconds, so a 1 millisecond period change is a 20 percent jump!

The following photo shows the display running Adafruit code:



Adafruit states their sketch is just an example to verify their sensors functionality but I felt higher accuracy at large flow rates was essential. An internet search turned up several sketches using a direct interrupt to count pulses. The sensor pulse train is applied to pin 2 or 3, fires on the rising edge of a pulse and calls an Interrupt Service Routine like:

void pulseCounter()
// Increment the pulse counter

Can’t get much simpler than that.  Run this for exactly one second and you have counted pulses per second. Apply to the above formula and get volume units transfered in that second. Accumulate that many units each second to find total volume transferred. So the code to actually calculate rate and volume is easy. I exorcised most of the Adafruit code and added my own formulas. I also added a line in the ISR to blink the LED along with the incoming pulses.


Display and Operation

But this display needs to operate with multiple types of flow sensors. So I had to code an arrangement to set and permanently store K and Offset for whatever sensor was plugged in. That turned out to be the most complicated part of the sketch. I use the Function button to do this, taking advantage of the Arduino setup section which is only executed on a reboot. Holding Function down while resetting the processor starts set mode.



Releasing the Function button displays the stored K factor with a cursor flashing over the first character, the sign.



The Function button has three uses in set mode, depending on how long it is held.
A quick click increments the digit under the cursor
A press between 2 and 4 seconds advances the cursor to the next digit
A press greater than 4 seconds completes the setting and moves either to the offset setting or writes the data

To make this a little easier, I added code to blink the LED if the button is held between 2 and 4 seconds, and turn on the LED solid if held more than 4 seconds. I hope this is no more annoying than setting a cheap digital watch.

Note that K factors are always positive but occasionally a negative offset is specified.



This photo is the normal running display entered after exiting set mode, or on a processor reset.  The first line records units moved per second, where units is in whatever the given K factor uses. Both the Adafruit sensors have factors specified in Liters/Second. The 228PV I’m working with uses units of Gallons per minute.  The water meter on my house here measures in cubic feet. You have to consult the sensor data sheet.

Resetting the processor zeros the cumulative quantity moved.



Finally, holding the Function button down during normal operating mode will cycle the following four displays:

The stored K factor



The stored Offset



Accumulated time since last reset. Note this is subject to the accuracy of the 16 Mhz clock in the Arduino.



A software version number.


Update October 25, 2015

I’ve constructed a second unit. This one is built in a nice looking Extruded Aluminum box from Adafruit.  I thought the better enclosure would make construction easier. I was wrong. Because it can’t be opened you can’t reach in and solder anything, and you lose the convenience of soldering anything needing a ground directly to the tin box. That means wires have to be attached to every terminal, brought to a common point and spliced. I did try soldering the Pro Mini to the back of the LCD and that works but the contrast pot had to be wired out so the assembly didn’t save much wiring. This photo shows the completed display with K factor set to 1.0 and a 2000 Hz crystal controlled signal applied to the sense input:



The left side has a power switch and also an SPDT switch for 2-wire/3-wire operation that replaces the option block in the prototype.



Sense in and power jacks are mounted on the right panel



Have to open the left side to connect an FTDI Friend



Calibration and the K Factor

Most of these flow sensors will have specified somewhere in the data sheet, a K factor and offset. What the manufacturer does is plot flow in output pulses per second (frequency) against flow volume through the sensor at a number of flow rates. Then they do a linear regression on the data to get a best fit straight line. An example is Fig 1 in http://www.hofferflow.com/datasheets/miniflow2.pdf.

K factor is the slope of the line, usually given in pulses per unit volume, for example pulses per gallon. Offset accounts for the plot not being non-linear at the low end. Because of friction, it takes some small amount of fluid velocity to get the turbine to start spinning. You can assume that if the turbine is pulsing at all, at least the offset quantity is moving. Less than the offset volume is undefined. In the sketch, interrupt code blinks the LED when pulses are coming in.

There does not seem to be a standard for how K factor is presented. Sensors output a pulse stream at a frequency proportional to the flow volume as calibrated, this can be measured. With some sensors, you multiply the pulse frequency by the K factor to obtain a volume rate. Others however, require you to divide the pulse frequency by K.

In the sketch, I added a way to switch between these two methods by using the first character of the K factor. If this character is a “*”, the incoming pulse rate will be multiplied by the K factor, If the first character is “/” pulse rate will be divided by K. You may see a formula in the sensor data sheet like Freq = (Flowrate * K) – offset. Since we measure Frequency and need to display Flowrate, the formula is rearranged to Flowrate = (Freq + offset) / K and the K factor needs to be set to type “/”. Other sensors present Freq = (Flowrate / K) – offset. Rearranging that formula gives Flowrate = (Freq – offset) * K and you would set the K type to multiply, “*”. If the sensor documentation is not clear, just try it out. If the multiply/divide indicator is wrong, you will probably get totally unreasonable flows displayed. If so try changing the type indicator.


Here is a table from the FMC MNIT001 meter manual:


Note how K factors are presented in Pulses per Unit Volume. So for these meters, set the K factor type to “/”.
Another table, this one from Badger documentation:


Badger presents the flow frequency formula as:


So with these Badger sensors the rearranged equation to find flow rate is GPM = (Freq + Offset) * K and you would chose the multiply type option.

More information on the sketch’s K factor changes is in the file HERE_ARE_THE_DIRECTIONS.pdf included in the V1.10 dropbox download below.

Sketch and Revision History

The code can be downloaded from my DropBox account. I am carrying forward the original Adafruit license.
Version 1.oo Oct 08 2015 Initial release

Version 1.01 Oct 17 2015 Correct schematic error

Version 1.10 Oct 25 2015 Change method of applying K factor

The Shed Project

This post is not really woodworking more like carpentry. Sheds are legal in this town as long as they are not on a permanent foundation and are at least 3 feet from a utility easement.

I bought this house in February 1999. There was a 10×12 foot shed in the back yard which was even at that time clearly deteriorating. Fast forwarding to 2015 and it had become a house for homeless rodents. The door had disintegrated and part of the floor had rotted away. I do need the storage space so I am rebuilding the underlying structure and will be replacing some of the rotted T1-11 siding on the front.

This is the patient. Note there is no transom or sill under the doorway. The front of the shed faces West and is just set on the dirt following the grade of the lot. It definitely tilts towards the back where there is a drainage swale. My measurements estimate the front is four inches higher than the rear. I believe this was a major factor in the floor deteriorating as rain falling on the door will run into the shed. I will think about raising the rear to make the structure level.



Most of the trim is untreated pine, and the bottom front has been in contact with soil.



Part of the floor has been removed here and the camera is inside looking at the area underneath the door. Some timber and Great Stuff there in an attempt to keep the rabbits out. The floor is 5/8 plywood and was nailed down with ten penny spikes about every 15 inches. Not fun to get up but I want to put it back down if possible after the framing is repaired.



Transom area from the outside. This would be looking east.



On the south side the floor has been taken up to see what structure is underneath. The shed proper is made of a set of prefabricated barn shaped 2×4 trusses. They are supported by four 4×4 timbers running east to west on a two foot spacing. I discovered that these 4x4s are in turn supported by three 4x4s running north-south set into the dirt.



Four two foot spaced 4×4 across a ten foot shed leaves a foot extra on each side



The plywood flooring has rotted in the area around the door. It has been replaced in pieces at least once.



The first phase was to shore up and replace the sill under the front. Here the front of the shed has been jacked up about four inches. I obtained several two foot long 12×3″ treated cutoffs from a forest preserve project a few miles from here. Getting them home on a bicycle was interesting. My original plan was to use the cutoffs as pads underneath the 4×4 sub structure. In this photo there is a pad under each of the four members at the front.  I have a number of treated 2×6 timbers removed from a deck and I decided to put one 2×6 on top of each of the lateral 4x4s. This will raise the entire structure an inch and a half, getting it above the dirt. I hope.



This bumper jack is raising the southwest corner. Big jack, must have been from a Buick. It will pull a fence post no problem.

I’m cutting the 2 foot pads in half which gives a piece about 11×12″ and you can see the pad in the corner.



I have one hydraulic floor jack, and a half dozen scissors jacks accumulated in anticipation of this project.  The procedure is to dig a hole, slide the jack under a support beam and turn the cranks evenly. The floor jack worked the easiest, and the bumper jack not too difficult with the load but the scissor jacks were hard to turn their screw while the jack is in a hole. A big crescent wrench helped.

I’m also putting a pair of support pads under each side because I noticed the shed has sagged a bit in the middle.



This photo shows the north side of the shed. Another scissors jack is helping raise the center of the structure and the front is now elevated. Pads have been placed at the front corner (left of photo) and at two spaces under the side 4×4″.  You can see a 2×6 has been slid over the front lateral and also over the lateral in the center. The barn shaped trusses are on 24 inch centers.



The horizontal part of the bottom front truss 2×4 that formerly formed the bottom of the door frame was gone. Rather than replace it with another 2×4, I laminated a pair of 2x6s with a bit of half inch plywood to make a beam the same thickness. The vertical studs that formed the door frame are rotted at the bottom, they will be replaced when I find a suitable door.



This is the southwest front corner after raising and placing the treated lumber pad, and installing a new beam across the front. I have screwed a short piece of 2×4 to the rotted door frame to hold it together temporarily.



This is the north side of the door frame with a good 2×4 added.



At this point the front had been repaired enough that I could begin at the back of the shed. The remainder of the floor was removed, the jacks moved to the back. I decided to add another three inches under the rearmost beam to make the structure more level. This is the final arrangement at the north east corner. Three 2×6 under the side beams and two of the 3 inch pads to help take the load.  I put a long lag bolt all the way through the 2×6 to tie the structure together.



This is the opposite rear corner.



The two middle 4x4s had to be double padded as well.



Since I had added 3×12 pads at two points along each side, raising the rear an additional three inches required adding some additional wood to take up the space at those points.  One inch ripped from a 4×4 above the pad at the left in this photo and one inch plus a 2×6 at the right.  The center lateral beam just needed one more 2×6 to make it come out even. The center was bolted down as well.



Now the structural repair was complete and I could start putting the plywood floor back down. It’s splintered a bit from digging out the nails but in a shed, I don’t care, I spackled the splinters.  I’m screwing everything together so it can be taken up easily at some future time.   I put down a layer of rosin paper. Don’t know if that’s necessary but I had some so I used it.

This photo is the north side corner at the rear.



This photo is the south corner at the rear. I also squirted Great Stuff in all the spaces around where the trusses were cut out.




To Do as of 8/7: Finish re-laying the floor and plan to patch the damaged part. Find an exterior door! Get a sheet of T1-11. Get a sheet of 5/8 ply to patch the floor. Get 1×4 cedar to frame the door. Figure out how to get those home. Add soffit vent screens and a screened vent at the rear near peak.

Update: Week of August 10-14

The flooring is all back in place except a 2′ x 6′ piece behind the door which was too badly rotted to reuse.



Added four soffit vents and a 14 inch square gable vent at the top rear. Made a nice cedar frame for the gable vent.
I rented a pickup truck from Menards ($19 for 75 minutes, made it with 15 minutes to spare) and hauled the following things home:

Sheet of 5/8 exterior plywood
Sheet of T1-11 siding
Three 8 foot 1x6s
Three 7 foot 2x4s

And while I had the truck, a used exterior door from the Habitat Resale store.
So now I have no excuse for not finishing the project.
I am not very confident with the door, have to make a frame to fit it. After some drawing and math involving ugly fractions I had a plan for the frame.

The old frame is 4 1/2 inches thick. Probably made to account for a 2×4 stud wall and a half inch of wall board on either side.  I only have the stud wall to account for so have downsized the proposed frame to 3 1/2 inches wide. I bought three 2x6s to form the frame so I moved my table saw to the summer workshop (driveway) and ripped them down. Two of the waste strips were then ripped to 3/8″ thickness, one to half inch. These will form the stop moldings .  Here is the ripping work station. I use my plug in router table as an outfeed support. It plugs into channels on either side of the saw table.



I blocked up the door on a couple of saw horses and clamped the stop molding and frame members to the sides to get an idea of what to do next. It looked good but how to align the hinges?



The door formerly had hinges with four screw holes. Could not find hinges that matched the hole pattern though so I moved the hinges up a half inch so there was solid wood for new screws.  I decided to cut the hinges into the frame member first. I aligned them to the board edge and knifed in the hinge outline. Used a one inch chisel to further deepen the hinge outline and a small gouge to round the corners. Then wasted most of the pocket with a trim router, followed by a pass with my good old Stanley 71 router plane to clean up the edges. Hinges fit well. Now to fasten the other hinge leaves to the door.

I set the frame with hinges attached on the door. With a 3/4″ board under each one it looked like the alignment on the door was as good as it could be. Piloted the screws with a Vix bit.



This shows one of the hinges hanging over the door edge ready to be piloted and screwed down. After running four screws in each hinge on the door side, I removed the clamps and, Moment of Truth, found the frame pivoted all the way with no binding whatsoever. Success!



The final bit of engineering was to bridge the top of the frame. After studying the existing frame, I decided to capture this horizontal board in shallow Dados. I laid them out in pencil, cut the sides down a quarter inch with a back saw then hogged out most of the waste with a chisel. Cleaned the bottom of the dado with the Stanley 71 router plane. This is the Christopher Schwarz/ Roy Underhill method and was probably faster than setting up a jig for the little Dewalt router.

This photo shows the dado with header board inserted, glued and screwed.



Finally I screwed a temporary header across the bottom of the frame, punched out the hinge pins and removed the door. Two temporary diagonal braces were screwed on so the frame can be safely moved.  Both the door and the frame are on the back yard deck now with a coat of paint drying. I think it will work, will find out Monday when the install is done.

 Update August 18

Howard Peterson, from the Dupage Woodworkers Club came over to help with the door. Howard is active with Habitat for Humanity and has much experience building houses. In four hours we had the door installed and the missing piece of flooring replaced.

After tearing out the old frame and the 2x4s that supported it, a framing square showed the opening was far from square, and the floor was not level. Howard ripped tapered shims from 2x4s to correct the out of square condition. Look closely at the vertical edges in the next photo, you can see the tapered bits. I would never have though of doing this, thanks Howard!



After considerable fussing, the door fit well, and we cut a new piece to replace the open floor behind the door. The inside of the shed is now secure and usable.



Update August 23

Next step was to replace the rotted and ant infested sections of T1-11 siding on the front. I figured I could do this with a single sheet of siding if only the bad parts were re done so ran a horizontal chalk line two feet up from the bottom and sliced off the old material with a circular saw. New sections were cut and fitted. I decided to run the new lower piece down almost to the footing to fill the open gap there and in doing so, almost ran out of the new sheet. The lower right piece was short but it turned out the pattern didn’t line up anyway so I made a five inch filler piece and it’s hardly visible.

All the new sections are fastened with screws and I put aluminum drip edge strips in the horizontal seams to keep rain out of the joint.



And here is the repaired front side with one coat of oil stain.  Later another coat of stain was done on the entire shed. Had to caulk a number of carpenter bee holes in the left hand soffit.



The final step was to replace the edge and door trim on the front. I had to rent the Menards truck again to bring home the half dozen cedar boards I figured would be needed.  I’m using six inch cedar trim around the door rather than brick molding plus four inch that was on the old door.

Cedar was cut and fitted for door stop moldings at this time.  This was complicated by the fact that there was a 3/4 inch warp in the front wall which cause the top left corner of the door frame to stick out farther than the right side. I couldn’t use the stop moldings I had previously made, had to make tapered stop strips out of cedar to account for the bulge.  It was a chance to use my latest secret weapon, a crude scrub plane I made out of a decrepit wooden jack plane. The blade has been ground to a radius of 8 inches so the plane takes a deep narrow cut. It hogged off the extra wood down to the line in about five minutes and I shot the edge with a long jointer plane.



My scrub plane takes out these thick rough shavings. Doesn’t take many passes to remove a half inch of cedar.



All the trim and stop is in place in this picture.  I installed an aluminum threshold piece which will help shed water out the front instead of running back into the shed floor.



A major benefit of using deck screws instead of nails is you can take the project apart for painting. I painted the trim a lighter color to match the house, would have gone crazy cutting in two coats of paint around all that cedar. Here is all that carefully fitted wood painted and drying on saw horses.



Update August 25

And this is the completed, painted restoration. Just need to add some weather stripping around the door and caulk a few gaps under the eves.



I’ve been fussing inside the shed all day. It’s an interesting problem, how to best make use of a 10×12 foot space. Formerly, stuff was just piled on the floor, so usually had to crawl over some things to get to what I needed. I’m now hanging as much as I can from the back and front walls and stashing spare wood scraps in the rafters so the floor space is clear.



Final Update September 4

Thinking more about efficient utilization of the interior space, I realized that adding shelving would help. The cheapest 18 inch commercial product I found was at Meijers, $25 for a four shelf unit 4 feet high. The home centers had similar units starting at $45. I decided I could build something better.  There were 2x4s nailed across the inside of the shed on both sides with a single nail in each stud, I believe these originally  supported the frames while the T1-11 siding and roof was nailed on. So I tore those 2x4s down, ripped them lengthwise to make 2 by 2s and converted them into shelves on each side of the shed. Also I had 3/8 plywood available that my neighbor surplused after a sump pump failure which I cut in around the studs. Would not have been able to do that with commercial metal shelving.


The final touch was to build a ramp leading up to the now higher threshold. I had 2×6 treated boards left over from rebuilding a planter years ago. It took a bit of fussing to get the ramp stable but I can easily wheel the lawn mower in there now which will clear space in the garage.


The structure is considered finished now, though there will always be changes to my storage strategy. I hope it lasts another 20 years.

Rebuilding Uncle Ray’s House Number


Sixteen years and change ago, we moved to our current location in Naperville, Illinois. As a house warming gift, Uncle Ray Lauderbach gave us an illuminated house number sign. He had made many of these for his neighbors in New Jersey. The design consisted of a wooden box about 5″ x 12″, and 3″ deep. It’s assembled using box (finger) joints.  There is a groove around the front where the number template, cut from thin black foam and glued to a sheet of textured plastic sits, along with a sheet of thin plastic as a front face plate. The back of the box is a sheet cut from a plastic mirror tile. Ray installed three 12 volt incandescent bulbs connected in series, these were powered by a 20 VAC wall wart, the undervoltage provided a dim but long lived illumination.

I screwed the box to the front of our garage.

I’ve painted the box four times and caulked the face plate but could not keep moisture out of the interior. In 2015 I could see the corners crumbling and it was clear that reconstruction was necessary. I removed it from the garage and disassembled. It’s a credit to Uncle Rays box jointing skills that I had to jack the ends apart with a reversed clamp to extract the number stencil sandwich from it’s groove. I cleaned everything and prepared to make a new wooden box.

Raw Material

Home Depot has these half inch thick Cedar fence pickets 6 inches wide and four feet long. I made a bird house out of them a few years ago and its held up well. There were three pickets lounging in my lumber stash, so this was a logical starting point. Also in this photo you can see the number sandwich and the mirrored backing plate with the electrics.

Bare Home Depot Cedar Fence Picket

Bare Home Depot Cedar Fence Picket


I decided to use the “Eleven Grooved Box” technique with mitered corners reinforced with splines. So I ripped the picket to 3 inches, and cross cut to about 38 inches. This was clamped in my planing board, planed smooth on one side, and readied to cut a quarter inch groove the whole length.

3 x 36 Inch Strip Ready to Plane

3 x 36 Inch Strip Ready to Plane


I have a beautiful, genuinely old plow plane and used it to cut the groove. I’m sure the plow plane was quicker than setting up the router table, digging out the router, finding a bit, and creating a ton of sawdust. Note to self: Cedar shavings smell good and make good mulch.

Plowing Quarter Inch Groove

Plowing Quarter Inch Groove


This is a close up of the finished groove in what will be the front edge of the new box. The whole 38 inches has been grooved at this point.

Finished Groove 1/4 Wide 1/4 Deep

Finished Groove 1/4 Wide 1/4 Deep


A test showed that the number sandwich fit well in the quarter inch groove. Also in this picture you can see one corner of the old light box.

Test Fit

Test Fit


Box Componants

The next step in making an Eleven Grooved Box (actually this one only needs nine grooves) is to slice the stock into 45 degree mitered side pieces. This is done using a big Stanley miter box. I used the plastic front face plate to gauge the dimensions of the pieces, leaving about an eighth of an inch extra for caulking.

Slicing the 36 Inch Strip

Slicing the 38 Inch Strip


With all four sides cut and checked for equal length top to bottom and side to side, I could do a dry fit using a strap clamp with the number sandwich inserted. It worked perfectly.

First Dry Fit

First Dry Fit


Next to cut grooves in each of the eight miter faces to receive the eighth inch splines I had cut from the remaining piece of the Cedar picket. I have a jig for this, developed to hold a Stanley 45 plow plane in just the right orientation.

Plowing 1/8 Inch Grooves for Splines

Plowing 1/8 Inch Grooves for Splines


All four box sides have been grooved in this photo. The jig mentioned above allows a clean cut which means a tight fit for the splines that will be glued in.

Four Completed Box Sides Grooved for Splines

Four Completed Box Sides Grooved for Splines


Box Assembly

The number sandwich has to be inserted in the front groove as the box is glued together. I made this a two step operation by gluing up the top, bottom, and one end only first, then inserting the plastic number sandwich, then finally gluing the last end in place. This photo was taken while the first stage was setting. The second end is in place to keep the box in shape, it has no glue applied yet.

First Stage Glue Up

First Stage Glue Up


I applied silicone sealant to the front edge only of the groove, inserted the plastic face plate, pressed it in place against the sealant, then slid in the number stencil with it’s textured plastic backing. This seals the front tightly but will allow the number itself to breathe a little bit.

Then glue was applied to the final box side piece along with it’s two splines, sealant applied as before, the final end inserted and clamped.  The photo below was taken the rear surface planed flush and the box primed. You can see how the splines fit tightly and reinforce each corner. There is only a single joint line exposed to the weather.

Rear Surface Planed Flush

Rear Surface Planed Flush


At this point I fitted the rear mirror with it’s electrics to the box and tested under power. It did not light. I checked and every one of the three light bulbs were open. Apparently they did not survive the box disassembly. These were bayonet base 12 volt bulbs from Radio Shack. Radio Shack no longer exists in this area, so I decided rather than try to find replacements, to construct something with white LEDs.

On the table saw I ripped a strip from an old prototype printed circuit board. It has a single long row of tenth inch spacing holes. Note to self: wear safety glasses and use a carbide tipped blade you don’t care about. Fiberglass is very abrasive.

I have a handful of white LEDs harvested from a string I got during a post Christmas sale, and dug up a 12 volt wall wart (actually measured closer to 18 volts). I soldered eight LEDs to the PC strip, wiring them in pairs with a 1500 ohm resistor between each pair which allows about 10 milliamps. Each pair is wired to common power points in the center. I splayed alternate LEDs out a bit to spread the light more evenly.

New Light Strip

New Light Strip


I removed the old bulb sockets from the mirror but left the three supporting copper brackets.  With a bit of bending I was able to solder the new LED strip to the copper strips for good support. The LEDs point towards the mirror, not towards the front. I felt this would spread the light more evenly.

New Strip Soldered to Old Brackets

New Strip Soldered to Old Brackets


A dry fit in the box showed good even illumination. There is a slight shadow across the center due to the PC board strip but hardly noticeable.

First Test Light

First Test Light



Back in the garage, I reattached the strip of flashing across the top rear that mounted the old box. Then I attached a strip of extruded aluminum behind the flashing. This will tilt the box forward slightly and help rain to run off. I cut a small piece of flashing and attached to the bottom of the box to make sure that edge is held tightly against the wall.

Finished Box With New Mounting

Finished Box With New Mounting


Here is the front view of the rebuilt box after a couple coats of paint.  Note to self: paint doesn’t stick to silicone sealant fingerprints.

Front Of Finished Box

Front Of Finished Box


So now it’s show time. Screw the creation back on the garage face. Since I used the original rear plate and mounting bracket, I only had to drill one new pilot hole. The power wire was routed inside across the header plate to the nearest outlet and stapled down. Power is on continuously, you can’t see the illumination in the daylight but because of Uncle Ray’s black background the numbers are very readable.

Mounted on Garage

Mounted on Garage


Finally the real test, how does it work at night? It’s a little bit brighter than the original setup but still not so bright it is distracting.

Night View

Night View


Thanks Uncle Ray!

Toastmasters Timing Light

There was a post on the Workshop88 mailing list asking for someone to construct a small manual light box for use by the timer at Toastmasters meetings. The specification was, a switched Green LED, switched Yellow LED, switched Red LED, and a fourth switch to blink all the LEDs at a 1 hz rate. The actual timing is done by a human with a stopwatch, the box just signals the speaker. The Toastmasters’ existing setup uses 110 volt incandescent lamps and is not very portable.

Much discussion ensued on the mailing list about what could be done with a Raspberry PI or Arduino, LCD screen, etc. etc. but in the end, I agreed to design and build something simple according to the original manual spec. Ultra bright LEDs could be used with a 555 timer to do the blinking. A standard MN1604 9 volt battery would easily power the LEDs for 8 – 12 hours. And I could use the standard Arduino style enclosure: and Altoids tin.

I’ve built two of these boxes. The photos on this page are from the second – but first came a prototype on a solderless breadboard.

Breadboarded Timer

Breadboarded Timer


On the breadboard the timer circuit was checked for reasonableness and LED illumination tested. I found with a nine volt battery I could put two LEDs in series, and with a 200 ohm limiting resistor the Red LEDs drew 15 milliamps, the Yellow 20 Ma, and a pair of Greens 12 Ma. The Red and Green were very bright, Yellow not so much. Later I checked the spec sheet on the Yellow LEDs and found they would take 50 milliamps.  I lowered the Yellow limiting resistor to 130 ohms which brought the Yellow current up to 35 Ma and then all three pairs were similarly bright.

These Ultra Bright LEDs have a clear plastic envelope with a lens formed in the end which directs most of the light straight up.  I sawed the tip of each LED off at a 45 degree angle to remove the lens. This directs more light to the front and reflects much more to the rear.

Original and Faceted LED

Original and Faceted LED


Here is the final schematic. This is slightly revised from the first model, the timing person wanted a separate power switch, and also wanted the blink cycle to start with LEDs on rather than LEDs off.

Toastmaster Timer Schematic

Toastmasters Timer Schematic


The original breadboard had all three of the grounds at the bottom of the 555 chip connected together, a switch from there to power negative activated the 555. In that configuration, the 10 microfarad capacitor started out in a discharged state which resulted in LEDs off.  Splitting that capacitor off and hard grounding it causes it to start in a charged state which turns the LEDs on. Switching the 555 pin 1 to ground starts the blinker.

I constructed the 555 module on a bit of perf board with copper pads on one side. A six hole by seven hole piece holds all the parts. This is the layout sketch I used.

Toastmaster Timer Blinker Module

Toastmasters Timer Blinker Module


Here is an assembled module. It measures 3/4″ by 5/8″.

Blinker Module

Blinker Module


With the blinker built and tested, I turned to physical construction of the box. Everything should fit in the lid.  I made an aluminum template for drilling the ten holes. In this photo, the four switches have been mounted and there are small holes drilled above the nut for the anti-rotation washer.

Altoids Lid Drilled and Template

Altoids Lid Drilled and Template


The LEDs don’t have any formal mounting hardware. To get maximum exposure, they are just inserted in the holes until they bottom out on the shoulder. Then a narrow strip of FR4 perf board is threaded over the leads. This photo is three strips cut from a wire wrap prototype PC board. I use a crosscut sled on a table saw for this, with a narrow carbide blade centered on the fourth row of holes.  Width of these strips is important because they help restrain the battery.

LED Retaining Strips

LED Retaining Strips


The fiberglass PC board strip is tacked down with bits of bent paper clip soldered to the tin lid. That paper clip in the center had to be moved later because it interfered with the battery. Soldering the LED leads in the perf board creates a very rigid assembly. I added the current limiting resistors between the LED pairs.

Switches Mounted and LED Dropping Resistors

Switches Mounted and LED Dropping Resistors


Spacing between the switches and the LED retaining strip is critical because the nine volt battery has to fit there, but not rattle around. A large paper clip was straightened out, then bent to capture the battery. A paper clip has just enough spring to hold the weight of the battery. This photo shows the battery clip soldered onto the lid. White arrows point to the four Z shaped wires holding the LED retaining strip in place. Ground leads are soldered to each switch and each has been cabled to it’s assigned LED pair.

Pins Holding LED Board

Pins Holding LED Board


Here is a photo with a battery installed in the clip. You have to be careful not to short the terminals on the lid lip.

Fitting the Battery

Fitting the Battery


At this point the lid is ready to receive the 555 timer blink module. It is mounted with two more bits of soldered paper clip, this time bent into an L shape. One clip is soldered into the ground hole of the perf board, the second in a vacant hole. White arrows in this photo point out the two module mounting clips also three of the LED restraining strip clips. Note the two retaining strip clips nearest the rim are bent parallel to the lid edge. This is to give clearance for the box bottom.

Blinker Module Installed

Blinker Module Installed


The last piece of hardware installed was the power switch. I used a small slide switch as that type will be less likely to accidentally turn on in somebody’s pocket.  Two eighth inch holes were drilled, then squared up with a small file. I soldered the ears of the switch to the inside of the box.

Power Switch Soldered In

Power Switch Soldered In


Finally the wires for power were added, everything tested, and all loose wires laced up with waxed dental floss. A bit of foam tape was added to the bottom to help make sure the battery clip doesn’t come loose. There’s a small paper clip loop soldered next to the power switch to take up strain on the wires there.

Internal View

Internal View


Here is the finished box with all three LED strings lit.  Note this is not a normal condition, only one color at a time should be on, mostly the Green which only draws 12 Ma (but is so bright it hurts your eyes). Blinking will draw about 60 Ma half the time. Duracell’s data sheet shows a useful life greater than 8 hours with a 50 milliamp draw so I expect this application to last considerably more than that.

Completed Toastmaster Timer

Completed Toastmasters Timer


This has been an interesting project that was well received by the users.  There is a short video on my Dropbox account.

Added: May 27, 2015

I needed a way to get consistent bevel cuts on the modified LED lenses using my bench grinder which is far quicker than the Dremel tool with cutoff wheel method.  The solution as any woodworker would know, is to make a jig. In this case though I was able to re-purpose a fixture I made years ago to hold hand plane irons while touching up the bevel. It’s just two pieces of 3/8″ x 3/4″ steel bar stock with half a dozen holes drilled. One piece is tapped, screws through the other then clamp the plane iron in the jig and it can be held tightly to the edge of the grinder’s tool rest.

Adapting this fixture to hold LEDs only required adding a washer slightly thicker than the LED wire leads to one end. I had to grind the underside of the threaded bar to get clearance for the grinding wheel. Two LEDs can be slid into the beveled end and clamped there by the screws. A single long screw through one of the threaded holes at the washer end provides a stop that can be held against the grinder tool rest.

LED Grinding Fixture

LED Grinding Fixture


I can tweak the grind angle by adjusting the tool rest, and a few passes across the grinding stone produces the consistent bevel I wnt. Just have to be careful not to grind away too much. I put a dab of nail polish on the ground surface to clean up the scratches.



Home Made Iambic Paddles

I have two homemade paddles to use with the Iambic Keyer Project.

This first example was made in the late 70s or early 80s, can’t remember exactly. I mentioned to a friend who worked in maintenance at a steel mill that I was looking for a heavy piece of metal to make paddles that wouldn’t scoot around on the desk.  We discussed some ideas and a few days later he produced the frame (all the blue parts) you see in the photo. It weighs over five pounds, it only moves if you want it to.

The arms are plexiglass fastened to short pieces of tubing. The tubing is flared at each end and each flare receives a bearing ball. Cup tipped Allen screws in the top frame and in the base capture the balls. With careful adjustment leaving a small amount of play, these bearings work well.

The rest of the paddle hardware is made of scraps from my junk box. Simple contacts made from machine screws work, but are noisy. Noise however does not bother the keyer much, as once an element is started, the paddle input is effectively debounced by dot/dash timing in the software.

Paddles Home Made About 1978

Paddles Home Made About 1978


My second example was made recently. I decided the blue paddles were not portable enough so I made something smaller. This set has a base of two inch steel Aux Bar scrounged from a telco installation project. The next photo shows the first iteration.

For pivot bearings I used brass thread inserts from Woodcraft. They have a 1/4-20 inside thread and a very coarse outside thread, intended to screw into a woodworking project. I filed the coarse threads off two sides of the inserts and soldered them to a strip of PC board material to form the paddle arms. The bearing for the arms is then the threads of the screws which go into threaded holes in the base plate.  Contacts are bent paper clips screwed to half inch nylon standoffs.  This works but has a terrible feel due to slop in the 1/4-20 threads.

I put a square of sticky silicone mat under the base and it stays put pretty well. The square was cut from a large mat intended to hold a wood work piece in place while you use a router on it’s edges.

Paddles Home Made February 2015

Paddles Home Made February 2015


The second iteration of the Aux Bar paddle is an attempt to remove some of the annoying backlash in the screw thread pivot bearings. I thought longer threads would help and got two threaded sleeves from the hardware store. These are made for joining two lengths of threaded rod. They have a #10 thread and are about an inch long. Two new paddle arms were constructed, this time with the bearings on the outside of the PC board as the sleeves are larger than the brass inserts used in the first model.

I inserted three sets of small screws into the arms to capture the tension spring which allows some adjustment. The spring shown in the photo is from an old IBM keyboard. If you part out one of those old Model M’s you have enough springs to last a lifetime. A second spring directly between the pivot points takes up some of the backlash remaining in the threads. Also the two #10 pivot screws are epoxyed into the base to eliminate that small bit of wobble. At the back of each arm where the paper clip touches, I added a drop of silver containing solder to make a better electrical contact.

This iteration has a very light touch but still too much slop in the bearings. I think with some tuning of the springs it will be very usable.

Paddles Home Made March 2015

Paddles Home Made March 2015


 Update 5/11/2015

Added a spring directly centered between the two pivot points. This spring is stronger than the small one separating the paddle arms, and it’s function is to take up backlash in the sloppy threads on the cheap pivot screws. I soldered cut down copper carpet tacks to the inside of the paddle arms to keep the new spring in place. The spring force is directly between the pivot points, so it does not contribute to the effort required to close the paddles unless you press hard enough to overcome it’s higher tension. It improved the feel of the Aux Bar paddles a lot.

Pivot Spring Added

Pivot Spring Added

Fun With Direct Digital Synthesis

You know that good feeling you get when a project comes together? Thats what I felt when I saw this sine wave on my oscilloscope.  It’s a Pulse Width Modulation (PWM) signal generated by an Arduino using a Direct Digital Synthesis (DDS) technique and a lookup table of amplitude values. It was the result of searching for a way to improve the tone quality of a morse code keyer project and I had gotten half wave, then quarter sine wave symmetry working in a demonstration sketch.

Quarter Wave Symmetry

Quarter Wave Symmetry
1000 Hz 256 Step Table


Digital to Analog Conversion is best done with optimized precision circuits. The relatively simple processor in an Arduino does not have a DAC device but it can do Pulse Width Modulation which can, in most cases, do the job adequately.

Pulse Width Modulation is widely documented. Basically it is a technique for generating an analog voltage from a digital signal. The device generates a high speed pulse train with varying pulse widths.  This is fed through a filter circuit which averages the energy in the pulses.  Fat pulses average to a higher voltage, skinny pulses average to a low voltage. By changing the pulse width over time, digital software can create a good analog representation of an arbitrary periodic signal. Other interesting applications are possible.

An Arduino generates PWM by setting up a timer. This is a counter with a circuit to trigger an interrupt at a specified count. The counter is incremented by the processor clock or, through a prescaler, a submultiple of the processor clock.  PWM is achieved by the Interrupt Processing Routine (ISR) manipulating the specified count at which the timer fires. DDS applications synthesize an arbitrary waveform by using a lookup table of values that the ISR accesses sequentially to change the terminal count.

Common non-DDS applications might be dimming an LED , feeding an RC servo, or controlling the speed of a motor, and the Arduino environment has a convenient analogWrite() function that handles all the details for you. Hybrid cars use PWM to control the traction motors.

I found many articles on generating DDS sound using the Arduino platform. I picked one from KO7M as a base to learn more about the method. Read Jeff’s weblog entry with source code here. His sketch sets up timer 2 for PWM with a 32 KHz base frequency.  Timer 2 is normally used by the Arduino for the tone() function and since my aim is to supersede the tone() function with something better, his example was a perfect starting point. In this article, I will only describe the changes I made in Jeff’s Interrupt Service Routine (ISR) and in the tables. Details of setting up the timers are covered in the source code and in many Internet sources. Here is a drawing of the Arduino connections:

Schematic for DDS Demo

Schematic for DDS Demo

Only five external parts needed including a button switch that stops and starts the sweep.

My test bed started out simple but it grew some (gruesome?).

Test Bed

Test Bed

Part 0: Analyzing and Parting Out the KO7M Sketch

After confirming that the sketch actually worked, I added code to sweep the frequency range from 50 to 2000 HZ so I could hear what it would sound like, and observe fidelity on my oscilloscope. Later I also added lines to generate a pulse at the start of the sine wave on a different pin. Using this pulse as an external sync source allowed the scope to display a steady waveform. I removed the sync code in the examples in this post for clarity.

This is the ISR from the original sketch (with small changes by me). TuningWord is the only parameter passed from the main part of the program. It is adjusted to set the particular PWM output frequency desired:

ISR(TIMER2_OVF_vect) {
  byte sine_table_index;
  static uint32_t phase_accumulator;
  // Update phase accumulator and extract the sine table index from it
  phase_accumulator += tuning_word;
  sine_table_index = phase_accumulator >> 24;  // Use upper 8 bits as index

  // Set current amplitude value for the sine wave being constructed.
  OCR2A = pgm_read_byte_near(sine256 + sine_table_index); 

Note Jeff is storing his sine table in flash memory. If you’re not familiar with that technique, read this tutorial. It is a good method for reducing the RAM footprint of an Arduino sketch. You can find my version of Jeff’s sketch here.  This is the 1000 Hz output from the original sketch with floating point math:

Original Floating Point

Original Floating Point
1000 Hz 256 Table

Part 1: Integer Conversion and Multiple Sine Tables

At this time, all floating point math in the example was converted to integer. To my surprise, it still works. There is more jitter on the waveforms due to integer truncation, but for keyer sidetone it is acceptable and the sketch sized dropped by about half.

I wanted to experiment with multiple lookup tables to get an idea of the minimum memory footprint possible while still producing acceptable sound. Libre Office Calc easily produced data with a 0-255 range for tables of length 256, 128, 64, 32 and 16 samples. See my spreadsheet here. Calc could also graph the tables to show how rough the waveform might be.  It was a simple matter to paste a table column into VI and join the values into C style  statements. These lines of data were inserted into the sketch and wrapped with #ifdef and #endif statements. At the top of the sketch is this code:

// Table sizes. Uncomment one and only one
//#define Table256
//#define Table128
#define Table64
//#define Table32
//#define Table16

Which allows me to choose a table size to evaluate at compile time. The wrapped tables look like:

#ifdef Table16
// 16 samples per period
#define Bits 12               // # of bits to shift 
PROGMEM prog_uchar sineTable[16] = {
#endif // Table16

Bits is a constant definition that controls how far the ISR has to right shift the phase accumulator variable so the number that remains does not exceed the sine table size.

The interrupt handler changed little and looks like this:

ISR(TIMER2_OVF_vect) {
byte sineTableindex;
static unsigned int phaseAccumulator;

  // Update phase accumulator and extract the sine table index from it
  phaseAccumulator += tuningWord;
  // Right shift because we're only using the most significant bits of the INT
  sineTableindex = phaseAccumulator >> Bits;

  // Look up current amplitude value for the sine wave being constructed.
  OCR2A = pgm_read_byte_near(sineTable + sineTableindex);

Code for this full table sketch is here. These are waveforms from the Integer version:

Integer Version

Integer Version
Three Table Sizes

Part 2: Using Half Wave Symmetry of Sine Waves to Reduce Table Size

During my Google research I found articles pointing out that the size of the sine table could be reduced by a factor of two or four if you exploited the symmetry of a sine wave. Several pages described how to do this in FPGA hardware but I could not find a good example of symmetry use in C code and nothing at all for an Arduino. I tackled symmetry in two stages.

For half wave symmetry it is only necessary to duplicate the first half of the wave for the second half, inverting the second half as it is generated. First you need to know which half is being processed during the interrupt. The Most Signifigant Bit (MSB) of the phase accumulator variable has that information. It will be zero in the first half of the sine wave, one in the second half. I added a variable to record this bit and use a mask of 0x8000 to extract the bit. Then a new constant MSBMask was created inside the table definitions to turn off the high order MSB during table lookup. The tables now look like this example:

#ifdef Table16
// 16 samples per period
#define Bits 12
#define MSBMask 0x07
PROGMEM prog_uchar sineTable[8] = {
#endif // Table16

Note the table sizes are half the original. This 16 stepe per period table is now only 8 bytes long.  The modified ISR with half wave symmetry now looks like:

ISR(TIMER2_OVF_vect) {
byte sineTableindex;                     // calculated index into sine table     
static unsigned int phaseAccumulator;    // running total of phase offset
unsigned int whichHalf;                  // for sine symmetry switching

  // Update phase accumulator and extract the sine table index from it
  phaseAccumulator += tuningWord;
  whichHalf = phaseAccumulator & 0x8000; // record which half of wave

  // Right shift because we're only using the most significant bits
  // of the INT. Leave only enough bits for one half table range
  sineTableindex = (phaseAccumulator >> Bits) & MSBMask;

  // Set current amplitude value for the sine wave being constructed.
  OCR2A = pgm_read_byte_near(sineTable + sineTableindex);

  // invert the second half of sine wave
  if(whichHalf) OCR2A = 255 - OCR2A;

The only additions to the ISR were the whichHalf variable, MSBMask which is defined with the sine table to remove the MSB, and the if statement at the end which does the actual inversion.

Code for the half wave symmetry version is here. These photos are from the half wave version:

Half Wave Symmetry Version

Half Wave Symmetry Version
Three Table Sizes


Part 3: Using Quarter Wave Sine Symmetry to Reduce Table Size

Exploiting quarter wave symmetry is more complicated. It is a left/right symmetry while half wave symmetry is up/down. First you have to know which quarter of the wave is being generated. The second most significant bit in the phase accumulator variable has this information. It will be 0 if in the first or third quarter, 1 if second or fourth. A new state variable and a mask of 0x4000 records this bit.  Since we are using less of the lookup tables, the MSBMask is smaller, it now needs to discard two MSB bits. The tables now look like:

#ifdef Table16
// 16 samples per period
#define Bits 12
#define MSBMask 0x03
PROGMEM prog_uchar sineTable[5] = {
  128, 177, 218, 245, 255
#endif // Table16

Note that the sixteen sample table has been reduced to five (not four) bytes. The 256 level table is only 65 bytes long! The odd byte at the end was necessary to work around a glitch – the table read from flash would look up the same value twice at the beginning and end of the even quadrant. Adding one to the index and one extra table byte solves that issue. The ISR now looks like this:

ISR(TIMER2_OVF_vect) {
byte sineTableindex;                     // calculated index into sine table     
static unsigned int phaseAccumulator;    // running total of phase offset
unsigned int whichHalf;                  // for sine symmetry
unsigned int whichQtr;                   // for sine symmetry
static boolean pulsed;                   // for unique scope sync

  // Update phase accumulator and extract the sine table index from it
  phaseAccumulator += tuningWord;
  whichHalf = phaseAccumulator & 0x8000; // record which half of wave
  whichQtr =  phaseAccumulator & 0x4000; // record which quarter of wave

  // Right shift because we're only using the most significant bits
  // of the INT. Leave only enough bits for one quarter table range
  sineTableindex = (phaseAccumulator >> Bits) & MSBMask;

  // Look up current amplitude value for the sine wave being constructed.
  if(whichQtr) {                         // in second or fourth quarter
  // +1 works around a glitch where same data at the quarter 
  // transitions was looked up twice in a row
    OCR2A = pgm_read_byte_near(sineTable + (MSBMask - sineTableindex + 1));
  else {                                 // in first or third quarter
    OCR2A = pgm_read_byte_near(sineTable + sineTableindex);
  // invert the second half of sine wave
  if(whichHalf) OCR2A = 255 - OCR2A;

This code does quarter wave symmetry first, then wraps half wave symmetry around that for the final output.  The changes to add quarter wave are the whichQtr variable and it’s masking line, and the if(whichQtr) statement which inverts the table lookup left to right. MSBMask in in the byte read statement because it is the number of steps that exactly form a quarter of the wave form.

Code for the quarter wave symmetry sketch is here. Here are scope traces of the quarter wave symmetry version:

Quarter Wave Symmetry Version

Quarter Wave Symmetry Version
Three Table Sizes



These changes to the original Interrupt Service Routine allowed the table sizes to be reduced by a factor of four with hopefully, not too much additional overhead. Any ISR overhead added is executed 32000 every second so you have to be conservative.  CPU time in the ISR is traded for a smaller program.

All three of these sketches can be useful for arbitrary waveform synthesis by constructing an appropriate table.  The base sketch would work for any periodic waveform, including those that have no symmetry either up/down or left/right. A sawtooth wave for example.  Half wave symmetry would be good for representing an underdamped or overdamped square wave.  Quarter wave symmetry works for sine waves, as shown here, or a triangle wave.

The oscilloscope traces are interesting by themselves. These sketches and a scope could be used to demonstrate microcontroller techniques at your local science fair. My scope is an 80’s vintage Tektronix clone. On the screen you can see the generated sine waves and by zooming in, see the artifacts of PWM happening at a 32 KHz rate. Use the coarse 16 step table and the staircase model of DDS is clear. You can view the raw PWM by simply disconnecting the 0.1 Ufd integrating capacitor from the scope input. Interesting though, disconnecting the filter capacitor does not affect the audio much because your ears can’t respond to 32 Khz sound.

DDS quantization is most visible at low frequencies, using the smaller tables. Here you can clearly see the 16 steps and 32Khz fuzz on the trace.

50 Hz 16 Step Waveforms

50 Hz 16 Step Waveforms



The 64 step sine synthesizer with quarter wave symmetry was successfully added to my keyer project.  I see no degradation of the morse timing at 50 WPM.  A brief video is here.  Also I recorded MP3s of the tone before and after.  The tone produced by the stock Ardino tone() function is here.  The tone from the 64 step (16 values) DDS function is here.



Get every new post delivered to your Inbox.