Category Archives: Arduino

Arduino Projects or variations of other published projects.

“Most Accurate” SB-630 – An Update of an Old “Timer”

Or, “Most Accurate” SB-630: Retro Style Desk Accessory, Updated on a Budget

A while back, I was given an SB-630 Station Console by an old timer acquaintance.

The SB-630 is a nice, but not especially necessary station accessory. Some hams built them just to have the complete SB-line. The console consists of a passive SWR meter, a phone patch, a motorized Digital Clock and the unique feature: a 10-minute Identification Timer. Better versions of the SWR Meter and Phone Patch were sold separately; the clock-timer was unique, so the SB-630 was merely an opportunity to wrap them all up in a single desktop accessory. Since there’s nothing unique about the SWR Meter or the Phone Patch, for my purposes, I shall focus on the clock-timer combination.

My plan was to build a new clock display, keeping some of the old style (albeit 1970’s style, not 60’s), and drive them with an Arduino micro controller. The real-time clock is provided by a Maxim DS1307 (formerly Dallas Semiconductor) 8-pin IC. The chip is tiny, uses very little current when it’s ‘on’, and is backed up (according to the datasheet for 10 years!) by a single CR2032 3-volt lithium battery.

The LCD is from SparkFun, a Red-on-Black, Backlit LCD which fits well.

Construction

All Tubes and the Plate-Filament transformer were removed (and saved, for future tube projects). The clock was given to a local collector who prefers to keep his Heathkits original. The functionality replaced – and enhanced – by adding a Real-Time Clock (RTC) chip, a WWVB receiver and Arduino code to interpret the 1950’s era clock signal.

The WWVB receiver reads each ‘pulse’ of the signal and interrupts the Arduino (INT1) to add the ‘tick’ to the buffer. Once the whole signal is received, it can be interpreted as a date and time. The RTC pulses (INT0) each second in order to drive the display clock.

In addition, an LM35 sensor provides the current room temperature.

Original WWVB decode source from http://duinolab.blogspot.com/2009/06/arduino-cmmr-6p-60-almost-accurate.html (Capt Tagon) and all others who’ve improved this code. Website seems abandoned, but the source code is good. My alteration is to remove the timer interrupt (1000 times a second) which operates the 1-second tick and replace it with the square wave output (SQWE) signal from the RTC chip, a Maxim DS1307.

The LCD is 16×2, and the layout needs to accommodate Date, Time, and Day, along with an ID Timer. A room temperature indicator is ‘extra’.

SB-630 LCD Layout
Character Display is laid out on the 16×2 LCD Display.

It’s a bit cramped, but I’m able to show everything I wanted to display, and I have plenty of Arduino pins left to trigger the ‘IDENTIFY’ lamps and ‘audio tone’, and a few pins left for future expansion.

Schematics

The DS1307 has it’s own battery-backup, which retains the time on power-off.

DS1307 schematic
Detail of the DS1307 Real-Time Clock connections.
Schematic of the CMMR-6P-60
Schematic of the CMMR-6P-60 (now unavailable)
Overall Schematic of the Microcontroller
Overall Schematic of the ATMEGA168 IC and it’s connections.

 

The WWVB Receiver IC is no longer available. A better choice today would be a GPS receiver, which would provide the same (or better) accuracy and is in the same price range now, with some GPS modules selling for as little as US$14.

Finally, the ATMEGA168,  LCD, ID Lamp Relay, Temperature Sensor, and the Tie-in with Original Switches.

Code

Source Code contains classes for the DS1307 and the CMMR-6 WWVB receiver.

 

Garage Parking Light

I really liked the Nuts & Volts Magazine project “Garage Parking Assistant” in January 2010, but I don’t ‘do’ Basic Stamp – no reason really, just not my favored platform and N& N & V seems to base a lot of projects on that platform.

So, I translated it to Arduino and replaced the Basic Stamp with a minimalist Arduino (Atmega 168, a clock resonator, a couple of resistors and capacitors, and an LM7805 voltage regulator). From there, code translation (BASIC to  “C++”) was easy. I make no originality claims and I’ve only provided a code translation.

Garage Parking Light – Translation to Arduino

This is a project I’d been thinking about for some time, but was too lazy to do. Finally a version came out in Nuts & Volts, January 2010. Their version was based upon a Parallax Basic Stamp module. Not a huge problem: I translated it for Arduino and built the whole thing on a small circuit board. This project is also well documented over on
Savage Circuits. I have nothing against the Basic Stamp modules, it’s just that I had parts on hand to build an Arduino version.

Parts

The Parts List is similar to the magazine defined project.

Qty Description Source Notes
1 Project Enclosure, approximately 3″ x 2″ x 1″ Anywhere For the Sensor
1 Project Enclosure, approximately 5″ x 3″ x 1.5″ Anywhere For the Controller & LEDs
1 PerfBoard to fit the Larger Box Anywhere
1 10mm Red LED Red is brighter; use a larger resistor
1 10mm Yellow LED
1 10mm Green LED
1 PING))) Ultrasonic Sensor Radio Shack
1 470 ohm, 1/4W Resistor Anywhere Red LED is Brighter
2 220 ohm, 1/4W Resistor Anywhere
1 Minimal Arduino or RBBB Kit www.moderndevice.com RBBB Kit or build a Minimal Version from parts

Arduino Code

The original Basic code for the Stamp was translated to Arduino’s familiar  C++. I’ve retained the original author’s comments and I’ve used the constants provided therein for evaluating distances to the arriving car. I didn’t provide the “Setup” mechanism, including the momentary press button, but I’ve included

PING Ultrasonic Sensor
PING))) Ultrasonic Sensor, mounted on the wall at bumper height.

it in the translated code. I used the original vehicle distances, as they suited my needs.

The Arduino platform used can be whatever is on hand. I usually use an RBBB from Modern Device, but in this case, I used a minimal Arduino built from a couple of resistors, a resonator for clock (or a crystal if you have one). The minimal Arduino, and a programming
header was constructed on the same board as the LEDs are placed, but off to the side.

One feature I did add was a ‘darkness’ sensor — I didn’t feel that the PING))) Ultrasonic Sensor should be working when it’s not needed, so I sense darkness with a simple analog read of the voltage drop across a Cadmium Sulfide (CdS) resistor.
Since the garage is dark except for:

  • Daylight – bright light enters from the open garage door
  • Night – headlamps will turn the Parking Light on
if ( analogRead(LightSensor) > 600 ) {		
	// Lights are on, or door is open and it's daylight.. Start to Work...
		
	// establish variables for duration of the PING))), 
	// and the distance result in inches and centimeters:
	long duration, inches, cm;
	:
	: (rest of PING))) Loop here...)
}
else { 
	// DARK! Sleep Now...
	digitalWrite(RedLED, LOW);
	digitalWrite(YellowLED, LOW);
	digitalWrite(GreenLED, LOW);
	delay(1000);
}

The CdS sensor peeks through the enclosure via a small hole above and to the left of the LEDs.

Hardware Differences

Since the controller changes from a Basic Stamp to an Arduino, there are a few hardware changes. The Arduino Digital and Analog Pins selected are:

  • Ping Pin – In/Out, Digital Pin 8; uses the PulseIn Function to detect the reflected Ping
  • Red, Yellow and Green LED Driving Transistor Bases: Digital Pins 11, 10 and 9
  • Program Button (implemented in code, but not used): Digital Pin 12
  • CdS Voltage Sensor: Analog Pin 5 –> inputs from a voltage dividor including the CdS sensor

The original article uses the Basic Stamp to drive the LEDs directly. I used a transistor to drive them, as the Arduino pins cannot source about 40ma of current. The Digital Pins might be able to supply enough current, but I’ve used the pin to drive the transistor base and let the transistor switch the current as a conservative design choice.

Source Sketch Files

  • Version 1 – works with Arduino-0018, uses a CdS light to turn off when garage is dark.

FM Stereo Broadcaster

Part 15, Low Power, FM Stereo Transmitter on a Budget

I have two good AM transmitters – one I’d built using a single 6888 Tube plus an old KnightKit Broadcaster that I’d refurbished, as well as a high-quality solid state transmitter from SSTRAN that I use to play music over the several antique AM radios I’ve repaired or refurbished.
I wanted a high-quality FM Stereo transmitter to stream iPod / iTunes output around the house and to my FM-band radios.

FM Stereo, however, is a bit more difficult to home-brew. I wanted to avoid the poor frequency control of the Ramsey FM-10C (with the BA1404 chip), and the low modulation of the little iPod FM transmitters you find for use in the car – although frequency control is quite good on these, the audio on these is just terrible. I’ve had about 3 of these iPod transmitters and they were all completely unusable.

You can get really GOOD FM transmitter kits but you have to go on up to $140+ to find a kit with suitable audio quality and frequency stability (think: Ramsey FM-25B).
To home-brew, first you have to build a stable exciter, preferably PLL synthesized, but the ICs for doing so are simply no longer readily available (Motorola MC145170, Plessey NJ88C30). Secondly, you’ll need to encode the left and right channels into Left+Right, Left-Right and tack on the 19 khz pilot tone, the 38 khz sub-carrier (See: Wikipedia, FM Broadcasting, FM Stereo).



The NS73M FM Transmitter module from Niigata Seimitsu Co. is ideal for this task. Unfortunately,
it needs a controller to setup the pre-emphasis, modulation level, frequency and power level.
And, if you’re going to use a controller, you might as well include an LCD so you can know what
frequency you’re on. I named this the “FM Stereo Broadcaster” since it reminded me ofthe old
Knight-Kit Wireless Broadcaster of the 1950’s (I have one of those too!).

The Plan

I selected a Bare-Bones Board (BBB) from Modern Device Company (that I had on hand) to provide an Arduino controller.
The Arduino is an open platform, the development tools are free, and can be programmed in a variant of “C”
language. The LCD is a 16 x 1 device from AllElectronics.com
made by Varitronix. Finally the NS73M is provided on a convenient breakout board from
Sparkfun Electronics.

The Code

I found some initial code built by Cai Maver (Arduino + NS73M = ARRRduino!)on the SparkFun forum. The original (ur-code?) sample BASIC code from Sparkfun / ZAPNSPARK (Jim G.) gave the original ‘protocol’ for interfacing with the NS73M.

The code was first built with 3-wire mechanism using 3 digital pins (after the sample code)..
After some back-and-forth collaboration, he changed the Arduino to NS73 communication it to use
the I2C protocol (Arduino Wire.h library).
I added the 4-bit LCD interface and did some fancy-schmancy handling of the up/down/set buttons so you can
take the transmitter offline, change frequencies, and put it back on the air, and I added some code to save
and restore the frequency in EEPROM so the last frequency is restored on power up. The Feature-List
includes:

  • Power-up and recall the last-known frequency
  • Provide access to the entire FM-broadcast band (USA; code is easily modified for other markets)
  • Allow the FM Carrier to be taken ‘off-air’ or ‘on-air’ as needed
  • Show the current frequency and carrier state on an LCD Display

The project becomes a matter of not assembling discrete components so much as putting together 3 highly integrated modules.

The LCD4bit library was altered in only two spots:
1. Disable the RW Pin – the LCD RW pin is tied to ground (LOW). We’re only ‘writing’.
2. Change the Enable Pin from ‘2’ to ’11’ (use the unused RW pin).


				The Arduino pins are budgeted this way:
				Digital Pins -
				D12 = RS (from LCD)
				D11 = RW (NOT USED - The RW pin on the LCD is tied LOW)
				D11 = Enable (from LCD)
				D10, 9, 8, 7 = 4 data bits for LCD
				D6, 5, 4 = UP, DOWN, SET buttons
				
				Analog Pins:
				A4 = SDA, A5 = SCL
				
				There are a few pins remaining for future expansion.

FM Stereo Broadcaster - Frequency Stability
Final code is in this
Arduino Sketch for An FM Stereo Broadcaster.
As currently configured, the NS73M transmits at 2 mw power output, with a 75 us pre-emphasis, and 100% modulation to occur at 200mV of input audio. The first time it powers up, it will start at 97.3 mhz.
Afterward, the start-up frequency is remembered from the last time.

Everything is reconfigurable for other countries, including the FM Broadcast band edges
(87.5 mhz to 107.9 mhz USA), and the channel spacing (200khz USA). The 4-Bit LCD interface is as follows:

LCD is being used as Write-only, so we can save a pin by tieing RW LOW and disabling RW in the LCD4bit library.
Also the LCD4bit library was slightly modified to move the ENABLE pin from Arduino Pin 2 to the (now unused)
Pin 11.
The Two LCD4bit library changes are two lines:


				int USING_RW = false; // make sure the USING_RW value is set to 'false'...
				
				... and Change THIS Line:
				int Enable = 2;	
				TO:
				int Enable = 11;	  // making use of the now unused RW pin...
				

Results

  • Frequency stability is tip-top – I connected a frequency counter and it NEVER drifted.
  • Transmitted Audio quality is superb – I don’t hear much hiss at all and the audio has great dynamic range, so FM modulation is quite good.
  • Range – I didn’t expect much, but with proper input volume (iPod nano, about 60% volume), and a short (read: legal!) antenna it reaches my living room about 50 feet away!
  • Frequency Agility – I’ve tested it down to 87.5 and up to 107.9 and other than some very small ’rounding’ inaccuracies, it reaches all of the channels on the US FM broadcast band.
  • Cost – compares favorably to the Ramsey FM-10C ($45): the Bare-Bones Arduino($15), the FM module ($15, Sparkfun.com),
    an LCD module ($5, Allelectronics.com), and some parts on hand (buttons, a 3.3v regulator,
    resistors, trimpot for LCD contrast), but has the features of a Ramsey FM-25B ($139.95).
  • I still need to package it in a suitable enclosure.

FM Stereo Broadcaster - Breadboard Version
Finishing: since this is an RF project, an enclosure should be metal. I’ve settled on a Hammond 1455N1201 extruded aluminum enclosure – they’re easy to work with and I like the style. The datasheet indicates the RF Output is 50 ohms impedance, so a BNC Connector would be suitable. Each of the separate ‘modules’ (LCD, Arduino, FM Transmitter) can be mounted to a perf board and interconnected. Breadboard power is from a 5-volt lab supply, so a 5-volt regulator (and filtering) will be added to power the Arduino and the LCD; the NS73M uses a separate 3.3-volt regulator.

I initially forgot to add a level-shifter between the Arduino and the NS73M. The Arduino will produce 5-volt swings and this needs to be buffered to 3.3-volt swings in the Clock and Data. A great guide for this is SparkFun’s Tutorial on 3.3v Sensor Interfacing.
However, I avoided the more complicated solution (BS170’s on each side) and simply used a pull-up resistor to +3.3V on both I2C
pins of the NS73M. Connecting these to the +5V Analog pins (4 and 5) now restricts the up-side voltage to +3.3V, but allows enough
of a swing to assure a good I2C signal.

Finally, connecting the buttons (or the rotary control) requires debouncing of the mechanical switches.
A good look at this great tutorial on debouncing: http://www.ganssle.com/debouncing.pdf
will turn up the RC method (on or about page 12-14). I chose this for it’s simplicity and it’s quite good at
cleaning up either pushbuttons or a mechanical encoder.

Schematic

Updated May 7, 2009 – Schematic. Finally!

FM Stereo Broadcaster - Schematic (partial)

Eagle CAD Schematic

    Notes on the Schematic

  • 1/18/2011 Discovered a MISSING connection on the Schematic: Note that for I2C operation, “LA” must be pulled ‘high’ or 3.3V. So: Change U1, Pin 7 (LA) to go to +3.3V
  • This is by no means a pre-bottled solution; you’ll probably want to tinker with it a bit, depending on what components or
    enclosures you have handy (switchs, power choices, LCD types).
  • I used the simple, cheater-way of handling the I2C – just two 10k pullups … to 3.3V! This limits the up-swing since the
    Arduino is at +5V.
  • S1, S2 and S3 – can be switches (version 1 of the code), or a Rotary Encoder (with a set switch) (Version 2).
  • LCD code is written with a 16×1 in mind; 16×2 LCDs are now more readily available and cheaper. This just gives you
    more display real-estate to use; tinker with the LCD output lines
  • Not shown on the schematic – I used the ‘TEB’ output on the NS73M to provide an ‘On-Air’ LED. Just use a current limiting
    resistor (maybe 1000 ohms to start). The TEB goes HIGH (+3.3V) to signal a LOCK (Low for Unlock), so this is a good visible check for ‘On Air’.
  • Some builders put a small electrolytic (10 or 22uf) between the LCD Contrast and Ground.
  • Remember this is an RF application; shield audio inputs, bypass early / bypass often.
  • This is my first EagleCad schematic and I’m too new at it to know any ‘best practices’; please email any suggestions or errors. Thanks.

Source Sketch Files

  • Version 1 – works with Arduino-0011, uses buttons for UP, DOWN and SET.
  • Version 2 – works with Arduino-0012, replaces add-in LCD4bit library with the new built-in LiquidCrystal library, uses a single Rotary Encoder for Frequency change and Set.
  • Version 3 – works with Arduino-0017, works with new, improved LiquidCrystal library.

I used a Bourns rotary encoder with a built-in push-button to replace the 3 buttons with a single control.

FM Stereo Broadcaster - Enclosure Final arrangement with an LCD, ‘On Air’ or PLL-Lock LED (in blue), and a rotary encoder with push-to-set switch for tuning.
Initially used a 16 x 1 character LCD from AllElectronics.com — A Varitronix #MDL16166.

If I were making another unit, I’d use a 16 x 2 display.

FM Stereo Broadcaster - Enclosure - Rear
From left-to-right: female BNC Antenna Connector, a 5-way binding post for ground, 3.5mm stereo input, 2.5mm coaxial power jack (9 volts, 1 amp wallwart), and
a power switch.

Ground seems an optional item, as it works very well with just a short whip.
Here the FM Stereo Broadcaster is connected to a TM-100 Clone
for an antenna.

Screws are standard-head, socket-cap screws with a black-oxide finish (McMaster-Carr: 91251A148)

FM Stereo Broadcaster - Inside This is the essance of a ‘modular’ project: The FM Transmitter IC, the LCD, the Arduino that controls them all, along with a bit of inter-module glue: a 3-to-5 volt interface from the FM IC to Arcuino, 3.3 volt and 5 volt regulator ICs, and a RC-debounce circuit between the mechanical rotary encoder and the Arduino.

FM Stereo Broadcaster - Front Panel The 16 x 1 character LCD from AllElectronics appears very faint when looking directly on, or from above. Investigating other LCD options turned up some similarly sized LCDs that will probably work better; the final version (at left) uses an LED backlight and had the exact same measurements as the Varitronix MDL16166 (to fit the opening!).

Screws are flat-head, socket-cap screws with a black-oxide finish (McMaster-Carr: 91253A148). They work well and look great with these
extruded aluminum enclosures.

What’s it take to get the nice, square, straight LCD hole in the front panel? About 30 minutes with a Nipper tool.

  • Mark the exact opening, making sure it’s square. I use a red Sharpie, but on the back side.
  • Drill a hole large enough to admit the end of the nipper tool.
  • Nip, Nip, Nip. Nip around the edges, always – ALWAYS – noting the position of your nipper against your red line.
    This is for consistency more than accuracy in size.
  • Nip slightly small; you can always use a file to ’embiggen’ the opening a bit. It’s less desirable to have
    the exact-sized opening than an even, square one.

Epologue

Any mistakes are probably my own. Thanks very much to Cai Maver for his original work on the Arrrduino FM – I’ve only extended his code a bit to include EEPROM store and some of the LCD behaviors. Many thanks to all the superb folks on the Arduino.cc website and their libraries, code samples and tips.
This project is not guaranteed for any specific outcome or purpose. I cannot be held responsible for illegal uses. This project is solely for educational, hobbyist, and experimental purposes.
Please check your local (and national) regulations regarding unlicensed transmissions. Do not interfere with other, licensed transmitted signals. FCC’s Part 15 Regulations are recommended reading, particularly

Bulletin 63 (October 1993)
“Understanding the FCC Part 15 Regulations for Low Power, Non-Licensed Transmitters”. This project describes an “Intentional Radiator” and as such (operating in the band 88 – 108 Mhz), according to Section 15.239 (b): “The field strength of any emissions within the permitted 200 kHz band shall not exceed 250 microvolts/meter at 3 meters.” Using their calculations, this works out to about P = 0.3 E2 watts, or 0.3 x (250 x 10-6V)2,
or 0.3 x 0.0002502, or: 0.00000001875 watt (.01875 μ-watt).

Updated May 13, 2009

Don’t know how I missed this one, but there’s a great rule-of-thumb allowance for AM and FM, unlicnesed, low power broadcast transmitters. The Document is from July 24, 1991:

“Permitted Forms of Low Power Broadcast Operation”

Page one has the technical power rule: AM – .05 watts (or 100mw to the final RF), and FM – 0.01 microwatts. But since these are difficult to measure since calibrated RF meters are expensive, the general intent of the rule is defined as an ‘Approx. Maximum Coverage Radius’ or 200 feet (radius) for both AM and FM low power transmitting.

Updated May 13, 2009

Found a swell link that produces a list of unused FM Frequencies in your area. Searchable by City / State, or by Zipcode, it will return a graphic showing the signal strength of the stations in your area, plust a list of “best”, “better” and “good” frequencies. For example, in Dallas / Ft. Worth, Texas, there AREN’T any unused frequencies (!), but it gives a list clear of all but the weakest stations.

http://www.radio-locator.com/cgi-bin/vacant

Update:
This made it to HackaDay.com. The project has an enclosure now, although I wish I’d used a back-lit and 2-line LCD. Too bad – the hole is already cut.