Main, skip to top

Electrical

Morse Code Bicycle Safety Blinker

Front View of Morse Code Bicycle Safety Blinker

$3 in parts
Runs 4 days on 2 AA's

Tired of the boring steady blink? Sport a blinker that will get the attention of any old school ham radio operator! Check the Youtube video of the action.

This is my first project using an AVR microcontroller and really the first embedded systems project I've done since college. I had two options for programming languages C and assembly. I chose assembly because I was familiar (at least with the 8051) and because it is well documented in the datasheets. Another advantage of assembly is the ability to know exactly what is going on especially when using a device simulator.
Tools Needed: Parts Needed:
Soldering Iron
USBtinyISP
Breadboard
Computer
Free Software
#22 Solid Hookup Wire
Wire Strippers
Needle Nose Pliers
Tactile Switch
ATTiny85v Microcontroller
Bright RED LED
9V Battery Clip
2xAA Battery Holder
#24 Stranded Wire (similar to that on the battery clip)
Useful Datasheets:
Battery Holder
LED
Tactile Switch
ATTiny85v Microprocessor
  • Step One: Install the USBtinyISP Drivers. I've found the LadyADA writeup to be quite adequate.
  • Step Two: Install WinAVR. This Ladyada writeup is also worth a look.
  • Step Three: Install AVR Studio 4 (requires registration).
    • Don't bother to install the Jungo USB Driver.
  • Step Four: Write your program in AVRStudio.
    • Open Start -> Programs -> Atmel AVR Tools -> AVR Studio 4
    • Select New Project
    • Select ATMEL AVR Assembler
    • Give your project a descriptive name and choose a folder. Remember the folder name, you will need it later.
    • Choose a debug platform, if you aren't sure use AVR Simulator.
    • Choose the target device. ATtiny85.
    • Copy and paste the code. If you're brave feel free to tweak it a little.
    • Press F7 to compile the code.
  • Step Five: Program Fuses (this needs to be done once per IC)
    • Check out the The Engbedded AVR Fuse Calculator.
    • Choose the ATTiny85 AVR Part. (There is no ATtiny85v option).
      • Feature Configuration
      • Select "WD. Osc. 128 kHz; Start-up time PWRDWN/RESET: 6CK/14CK + 64ms: [CKSEL=100 SUT=10]
      • A slow clock requires less battery power.
      • Uncheck "Divide clock by 8 internally; [CKDIV8=0]
      • Check "Serial program downloading (SPI) enabled; [SPIEN=0]"
      • All other's should be unchecked.
      • Brown-out detection should be disabled.
    • No changes will be made to the Manual Fuse Bits section
    • Under Current settings copy down the generated AVRDUDE arguments
      • These should look suspeciously like -U lfuse:w:0xE4:m -u hfuse:w:0xdf:m -U efuse:w:0xff:m
    • Stuff to watch out for:
      • Any Clock selection beginning with EXT (you will need a crystal to program your chip)
      • Forgetting to check serial program (SPI) enabled. (Chip is bricked).
      • Disabling reset to gain an extra pin. (Chip is bricked, reset needed for programming.)
    • Open a DOS Prompt and execute the following command: avrdude -p attiny85 -P USB -c USBTINY -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
  • Step Six: Breadboard the programmer and microprocessor.
    • Set the processor on the breadboard across the channel.
    • Press the pins into the breadboard by gently pressing on the processor.
    • Use #22 solid wire to connect the pins on the processor to the ones on the programmer's 6 pin cable.
    • Keep in mind that your processor may have a dot above pin 1 rather than the notch shown.
  • Step Seven: Program the microprocessor
    • Open Dos and change to the folder your project resides in.
    • type: avrdude -p attiny85 -P USB -c USBTINY -U flash:w:my_project.hex -B 10000 (the -B 10000) slows down the programmer for the slow clock speed.
  • Step: Eight: Connect up the circuit
    • This is much easier to do on the breadboard to get started.
Advanced Concepts
Integrating USBTinyISP w/AVR Studio
The Simulator (See AVR Studio Help Screens)

In this case I mounted the whole deal to a Fi'zik - Saddle Attachment system.

Installing Modem Drivers for a Sanyo SCP-7050

I just upgraded my cell phone and wanted to be able to use it as a modem as well as update my contacts from my old phone with BitPim. I had my old Sanyo usb cable laying around but it took almost an hour of searching to find the drivers for this new phone. What I had to do was download the Sprint PCS Connection Manager and then only install the driver for Sanyo phones. I then plugged in my phone and it auto-detected it and found the drivers.

How ESN's Work

ESN's are an 8 digit hexidecimal number or an 11 digit decimal number. Either one represents a 32 bit binary value.

Keep in mind that one digit of HEX equals 4 binary bits.

Manufacturer IDSerial Number
HEX0-F0-F0-F0-F0-F0-F0-F0-F
BINXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DEC0-25500000000-16777215


For example:
ESN HEX: E6 9F FF FF

The Manufacturer Code is E6 (hex) or 230 (dec).

The Serial Number is 9F FF FF (hex) or 10485759 (dec).

So the decimal ESN is: 23010485759

Conversely, for decimal ESN: 23010485759

The Manufacturer Code is 230 (dec) or E6(hex).

The Serial Number is 10485759 (dec) or 9F FF FF (hex).

So the hex ESN is: E6 9F FF FF

Wireless Power Transmission

After I got ahold of an Braun Electric toothbrush, the concept of inductive power coupling has intrigued me. The charger connection is completely insulated. The toothbrush has a hole on the bottom that mates with a small cylinder sticking out of the charger. (PICTURE)

To check out the effect I took a coil of wire wrapped around a plastic spool and set it on top of the charger. I obtained approximately 1.5V open circuit and 500mA short circuit. I couldn't get too near the cylinder so the coupling wasn't the best. (PICTURE)

Next, I cut a 120V to 12V E shaped core "filament transformer" about the size of my fist in half, to produce two seperated E shaped iron cores. Cutting through all the copper windings, paper and iron core made a real mess, took a lot of time to cut and dulled my hack saw. I used a vice to keep the core slices from seperating.

I next wound the core with about 200 wraps of transformer wire I got at Radio Shack (I used the entire spool however many wraps that was). Clear plastic tape was used to keep the windings in place. I used a small piece of 220 grit sandpaper to take the enamel off the ends of the wire. I checked the inductance with my wavetek multimeter and it showed .3 mH. The resistance showed 3.3 ohm. The reason I am worried about this is that I don't have extra 20A fuses for my meter and I want to get an estimate of the quiescent current of my transformer without blowing up my circuit breaker, my meter and myself.

A little math (determine impedience from resistance and inductance):
V = I Z => I = V / Z
Z =R + jwL =R + j * 2 * pi * f * L =R + j * 6.28 * 60 * .0003 =3.3 + .11304j
I = 120 / (3.3 + .11304j) = 40A
This doesn't look good for my meter fuse or my breaker!

After further thought about the way a transformer works and electric versus magnetic circuits I determined the following.

The small quiescent current of a power transformer is a function of the reverse magnetic field produced by the voltage impressed on the secondary windings and not on the inherant impedience of the coil. When the magnetic field is broken (with an air gap) in a transformer it behaves like a shorted secondary and draws potentially lots and lots of current.

For this to really work well, a higher frequency should be used. I'm curious what my toothbrush uses.

Breakthrough discovery! I just hooked up my handy dandy yet old as dirt Freq Counter to that inductive coil and viola! 21 kHz and change.

I need a higher frequency source than 60Hz. I have a function generator, but it tops out under a single Watt power output and has a 50 ohm output impedience. Higher impedience means more coil wraps... no good. I discovered that an old audio amp I have laying around will put out 50W up to 70kHz at 8 ohm output impedience. I think I will choose 20 kHz however. Higher frequencies may cause extra loss in the rectification process later.

The coil inductance that I need to produce more than 8 ohms of impedience at 20 kHz.

More Math:

Z = j*2*pi*f*L
Z = 8j ohms
L = Z/(2*pi*f)
f = frequency = 20,000 Hz
pi = 3.14
L = 64uH

This is definately more reasonable. In fact I may try and wind this around a plastic core.

2.4 GHz Discone Antenna for 802.11b

Why Use a Discone Antenna?
The discone antenna is best suited for a situation where a true omnidirectional pattern is needed. The gain (8 dB over the internal antenna) is several dB higher than competing omni-directional designs such as the colinear and construction is much simpler because matching sections are not needed. The ideal situation for this antenna would be mounted on a tower or tall structure to provide access 360 over a full degrees. The design is inherently stable both electrically and mechanically. The device is small for reduced wind-loading and impediance changes due to ice or rain on the antenna are minimal especially if enclosed in a shroud such as a 2.5" PVC pipe. If you are looking for a point to point connection, take a look at Dr. Frohne's recycled primestar dish and other designs.

Our Goals
It was our goal to implement an antenna for the 802.11b (Wi-Fi) specification. This covers the frequencies of 2,400 MHz through 2,440 MHz. Our goals were to achieve a higher gain than the internal card antenna located in a common PCMCIA wireless card, smaller size and greater portability than current external antennas and omni-directionality for use in a mobile enviroment. We also tryed to keep costs under control.

Our Results
Our gain was as high as 8 dB over the best gain of the internal antenna in the Lucent Bronze card. Our overall dimensions were 3x3.75x3.75 centimeters. We fed our antenna using 50 Ohm thin coax and connecters rated for 2.4 GHz, probably availible at your local Radio Shack with the exception of a special pigtail that can be purchased from nearly any wireless networking vendor. The antenna was fabricated from a short section of copper (water) tubing often used in plumbing, copper foil and a piece of copper thin single sided copper board (fiberglass board plated with copper on one side). Fabrication from aluminum may also work well provided a suitable insulater electrically seperates the disk and the cone (like a rubber stopper). Our final impediance was 56 + j 7.5 and resulting SWR was calcuated at 1.4 using a slotted line.

Building a Discone
In building a discone we adapted plans from the ARRL Antenna Book 19th edition for building an HF discone. They suggest using an angle theta of approx. 64 degree angle on the cone and 7/10 ratio of disc diameter to bottom of the cone. The hypotenuse of the cone should be approx. 246/(frequency in MHz) feet. after building a discone of these dimensions, we discovered that by increasing the size of the disc slightly we could decrease our SWR greatly, while only slightly decreasing radiated power (less than 1%). This was discovered on the slotted line using aluminum foil to alter the dimensions of our antenna to optimize the SWR. You may notice the little disc in the picture above. This was our original disc that is fiberglass on the bottom and copper foil on top. When we moved to a larger disc, the old one was retained because the fiberglass on the bottom functions as an insulator to keep the disc from touching the cone. Any insulator will do here, a second disc is not needed.

To construct the cone:

  • Cut out a circle of foil with radius 246/(frequency in MHz) feet (sorry about the funny units, that's what the equation used in the ARRL antenna book, but they didn't give the units, we had to rederive the equation!) that's a radius of 3.35cm, mark the center and cut a slot from the outside of the circle to the center along a radial line.
  • Slowly work the circle into a cone shape. Until you get the desired cone angle, we used 64 degrees. You may wish to construct several cones for experimentation purposes. The easiest way to achieve 64 degrees is to work the bottom into a circle drawn on a piece of paper that has a 1.75cm radius.
  • Solder the edges of the cone to keep its shape. This may require a little patience or a big soldering iron or both. We used a 100 Watt "big pencil" soldering iron that worked quite well.
  • Using diagonal cutters clip off the top of the cone to make a hole very slightly larger than the coax you are using, a thin microwave grade coax is recommended.
  • Use a drill bit or other rounding implement to round off any sharp edges on the hole.
  • Insert the copper tubing into the cone until it rests firmly agains the walls of the cone. Solder the tube to the cone.
  • After the antenna cools, thread the coax through the tube.
  • Strip off an inch of outer insulation from the coax and unbraid the shielding wires back to the remaining insulation.
  • Fan the shielding wires out and solder to the top of the cone. This should firmly hold the coax in place.
  • Strip off the inner shielding leaving about 0.25 cm of space between the inner insulation and outer insulation to prevent the center conductor from shorting to the shield braid.
  • Cut your disc out of the copper board. We used a board that was insulated on one side to prevent shorting between the disc and the cone. You could probably also use cellophane tape or any other insulator around the center of the disc to prevent it from being electrically connected to the cone. Now punch a small hole through the center of the copper disc.
  • Set the disc on top of the cone, stick the inner conductor of the coax through the disc.
  • Fan the center wires out and solder them down to the top of the cone. If you have a solid centerconductor, apply a blob of solder to the top and let it flow down, then clip off the remaining conductor that extends above the disc.
  • You now have a discone antenna!

Tuning and Testing
Tuning and testing is an important step to maximizing the "coolness" of your antenna. Remember that antenna building, especcially at microwave frequencies remains highly a "black art" and nearly always requires some tweaking for maximum performance. A good suggestion would be to manufacture several discs and cones to use for testing purposes. Another neat idea is to use aluminum foil that will easily bend and is readibly availible at the grocery store for testing purposes. There are several varibles that are availible for tweaking. In most cases if your antenna works okay try messing with just one. If it is hardly working at all change a couple. Keep in mind this is a reiterative process (and can be lots of fun).

  • Disc Diameter
  • Disc-Cone Seperation
  • Cone Angle

Testing Your Antenna
Testing your antenna is accomplished to determine whether changes made were helpful or hurtful to factors such as gain and noise level. Many cards are accompanied with nifty software that displays dB measurements for things like signal strength td noise floor. You may have to go digging, but they are usually there. To set up a test bench you need a large open area with power availible. The two stations need to be far enough apart to read a fair signal strength using just internal card antennas. Make a mental note of the signal strength before and after attaching the antenna. The difference between these two numbers is the gain. Keep in mind that dB's are funny creatures and the number you see is probably negative so a smaller number may be better. For example if it read -68 dB before and -40 dB after you have +28 dB gain, and one serious discone Smile

Testing and Optimization
To test SWR and impediance we acquired a 2.4 GHz function generator with AM modulation and a slotted line with the help of our professor Dr. Rob Frohne. A slotted line is simply a length of 50 ohm transmission line that has a slot down the center with a slider that senses the voltage along the line through some sort of capacitive coupling. This is attached to a meter whichs allows you to read SWR and find voltage maxima and minima. From simulation we determined the biggest adjustment that can be made to the cone is adjusting the length between the disc and the cone. Since our design doesn't allow for such change easily we simply bent the disc up and down slightly. We also used aluminum foil to increase the effective surface area of our disc and cone structures. We were aiming for an optimal SWR of 1:1 and impedance of 50 + j 0 ohms. We finally measured 1.4:1 SWR and 56 + j 7.5 ohms impedance.

Finding Impedience on a Slotted Line

  • Short the end of the line.
  • Find the voltage manimum and mark its position. This is like the new end of the line because it is an integar muliple of lambda/2 from the end.
  • Connect your antenna to the line
  • Measure the SWR, then calculate Gamma (Reflection coefficient) = (SWR - 1)/(SWR + 1)
  • Find the next adjacent voltage minimum and calculate the distance d from this point to the "new end of the line" in terms of wavelengths.
  • Use a Smith Chart to find impedance using Gamma and distance d.
  • Plot a circle starting from 1 on the horzontal axis with a radius of the magnitude of Gamma. Note: The distance to the edge of the graph is Gamma=1 so your circle is proportional to this.
  • Starting from the leftmost side of the circle which corresponds to a voltage minimum and rotate using the marking on the outside of the chart distance d.
  • Read off the impedance Z at this new point on the circle

Measuring Radiation Pattern
To measure the radiation pattern of our antenna we set up a test range in the lawn in front of Kretchmar Hall. Our reference antenna was a 25 dBi gain Cushcraft Yagi pointing towards the test antenna. We planned our site in such a way to avoid reflections from nearby buildings and absorbtion from people walking in between the antennas. The discone was mounted on a soldiering stand that was mounted on a camera tripod. Our reference antenna was plugged into a Mac Airport. The discone was plugged into a Lucent Bronze 802.11 card plugged into a Dell laptop running the Link Test Software that came with the Lucent card. The link test gives the signal strength, noise strength and signal to noise ratio in dB. We then rotated our antenna in several different axes using the tripod, recording the values in each spot. We then graphed the values in MS Excel using radar plots and several nifty tricks to get it to come out looking right.

Simulation Graphs
SWR vs. Frequency
Zenith Plot
Azimuth Plot
Model of Simulated antenna

Real World Testing Result

Zenith Plot
Azimuth Plot
Smith Chart with Calculations of Imedance for discone

Standing Wave Ratio (SWR)
As it typlical for a discone, our antenna acts as a high pass filter. We disigned for the best SWR at 2.4 GHz. Note that SWR lower than 2.4 GHz gets worse exponentially and at higher frequencies linearly.

Zenith
The typical 3 dimensional radiation pattern for a discone is doughnut shaped as shown in our simulation and real world tests. The slight tip in our simulation seems to result from a strange abnormality in the current distribution of the NEC simulator. Note that the dB indicated on the real world graphs are dB received in the test not a reference measurement.

Azimuth
The typical 3 dimensional radiation pattern for a discone is doughnut shaped as shown in our simulation and real world tests. The slight tip in our simulation seems to result from a strange abnormality in the current distribution of the NEC simulator. Note that the dB indicated on the real world graphs are dB received in the test not a reference measurement.

Thanks to:
Dr. Rob Frohne -- Advice and rather effective encouragement to finish our project.

Ralph Stirling -- Letting us borrow his yagi and adapters for testing.

John Ash -- Letting us borrow his yagi for testing. Advice on choosing a testing program.

Seth McNeill -- For mocking our deisgn. Ha Ha it worked anyway!

Greg Kittle -- For being a wonderful grader and for all the extra credit we are getting for saying that!

David Paden -- For being such a great supervisor and picking up after Tim. Incredible insight and making all of the lousy ideas go away.

Tim Kyle -- For leaving parts all over Chan Shun. Oh yeah... and on a job well done.

Bottom, skip to top