Index


Blog Index Encyclopedia

Weather Station Facelift

Tyler Pattison N1QQ Arduino Weather Station

The online user interface for my weather station project got a nice face lift recently. I've managed to streamline some of the php code and do some formatting using bootstrap which resulted in a much more pleasing GUI. I also am in the process of adding humidity measurements to my weather stations, but I'm not happy with the current platform. Ideally I'd like to have all digital sensors to avoid noise problems that I'm dealing with using long cable runs to outdoor locations. Another option might be using an ADC at the sensor with enough resolution to give a precise temperature reading.

I'll be exploring this problem more in my free time, but for now, take a look at the updated display page. Also, thanks to the generosity of family in Spokane, I now have two identical weather stations taking measurements, and they both can be accessed online in real-time thanks to the recent changes I made in the php code.


Low power HF beacon project using Arduino

I recently got a cheap 40MHz signal generator board off of ebay for a few bucks. I modified some code I found online to use it to be able to send morse code from the serial port on my computer using putty. Putty is a nice piece of free serial terminal software. The output power is very low (easily measured in microWatts with a small antenna) but after some impedance matching and a amplifier stage you could easily use this for a nice HF beacon project. Here is the code if you want to try it for yourself:


//Has the ability to send morse code from the serial port

#define WPM 20
#define pttOut 13
#define pwmOut 5
#define toneFrequency 400  //Hz
#define W_CLK 8       // Pin 8 - connect to AD9850 module word load clock pin (CLK)
#define FQ_UD 9       // Pin 9 - connect to freq update pin (FQ)
#define DATA 10       // Pin 10 - connect to serial data load pin (DATA)
#define RESET 11      // Pin 11 - connect to reset pin (RST).
#define txfrequency 14015000

byte morseLookup[] = {
                      //Letters
                      B01000001,B10001000,B10001010,B01100100,B00100000,B10000010,
                      B01100110,B10000000,B01000000,B10000111,B01100101,B10000100,
                      B01000011,B01000010,B01100111,B10000110,B10001101,B01100010,
                      B01100000,B00100001,B01100001,B10000001,B01100011,B10001001,
                      B10001011,B10001100,
                      //Numbers
                      B10111111,B10101111,B10100111,B10100011,B10100001,B10100000,
                      B10110000,B10111000,B10111100,B10111110,B10111110,
                      //Slash
                      B10110010
                    };


void setup(){
  Serial.begin(9600);
  Serial.print("Loading...");
  pinMode(pttOut,OUTPUT);
  pinMode(pwmOut,OUTPUT);
  pinMode(4,OUTPUT);
  digitalWrite(4,LOW);
  pinMode(3,OUTPUT);
  digitalWrite(3,HIGH);
  setupDDS();
  delay(500);
  Serial.println(" complete");
}

void loop(){
  if(Serial.available()){sendSerialMessage();}
  transmitString("73 de N1QQ");
  delay(5000);
  transmitString("QST de N1QQ");
  delay(5000);
}

// transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line
void tfr_byte(byte data)
{
  for (int i=0; i<8; i++, data>>=1) {
    digitalWrite(DATA, data & 0x01);
    pulseHigh(W_CLK);   //after each bit sent, CLK is pulsed high
  }
}

void sendFrequency(double frequency) {// frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32
  int32_t freq = frequency * 4294967295/125000000;  // note 125 MHz clock on 9850
  for (int b=0; b<4; b++, freq>>=8) {
    tfr_byte(freq & 0xFF);
  }
  tfr_byte(0x000);   // Final control byte, all 0 for 9850 chip
  pulseHigh(FQ_UD);  // Done!  Should see output
}

void pulseHigh(int pin){
  digitalWrite(pin, HIGH);
  digitalWrite(pin, LOW);
}

void setupDDS(){
  pinMode(FQ_UD, OUTPUT);
  pinMode(W_CLK, OUTPUT);
  pinMode(DATA, OUTPUT);
  pinMode(RESET, OUTPUT);
  pulseHigh(RESET);
  pulseHigh(W_CLK);
  pulseHigh(FQ_UD);  // this pulse enables serial mode - Datasheet page 12 figure 10
}

void sendSerialMessage(){
  delay(10);
  char message[64];
  int length = 0;
  
  while(Serial.available() && length < 64){
    message[length] = Serial.read();
    length++;
    message[length] = '\0';
  }
   transmitString(message);
}

void transmitString(char* message){
  for(int i = 0; message[i] != '\0'; i++){
    Serial.print(message[i]);
    transmitChar(message[i]);
  }
  Serial.println();
  wordSpace();
}

void transmitChar(char character){
  int lookupValue;
  if(character > 64 && character < 91){  //Capital Letter (0-25)
    lookupValue = character - 65;
  }
  else if(character > 96 && character < 123){  //Lower Case Letter (0-25)
    lookupValue = character - 97;
  }
  else if(character > 47 && character < 58){   //Number (26-36)
    lookupValue = character - 48 + 26;
  }
  else if(character == 47){  // slash (37)
    lookupValue = 37;
  }
  else if(character == 32){  // space
    wordSpace();
    return;
  }
  else{
    return;  //Invalid Character
  }
  byte length = (morseLookup[lookupValue] & B11100000) >> 5;
  byte pattern = morseLookup[lookupValue] & B00011111;
  byte mask = 1 << length-1;
  for(int i = 0; i < length; i++){
    if(mask & morseLookup[lookupValue]){
      dash();
    }
    else{
      dot();
    }
    mask = mask >> 1;
  }
  charSpace();
}

void dot(){
  digitalWrite(pttOut,HIGH);
  sendFrequency(txfrequency);
  tone(pwmOut,toneFrequency);
  delay(1200/WPM);
  digitalWrite(pttOut,LOW);
  sendFrequency(0);
  noTone(pwmOut);
  delay(1200/WPM);
}

void dash(){
  digitalWrite(pttOut,HIGH);
  sendFrequency(txfrequency);
  tone(pwmOut,toneFrequency);
  delay(3 * 1200 / WPM);
  digitalWrite(pttOut,LOW);
  sendFrequency(0);
  noTone(pwmOut);
  delay(1200 / WPM);
}

void charSpace(){
  delay(2 * 1200 / WPM);
}

void wordSpace(){
  delay(7 * 1200/WPM);
}

Homemade ECG machine using infrared

N1QQ Arduino ECG Machine phototransistor Scott Harden Tyler Pattison

Some interesting projects that I recently found online showed people using infrared phototransistors and op-amps to build basic light-based ECG machines. I thought that I'd try it for myself just to see how well it would work. It was certainly interesting to build this little circuit on a breadboard. Perhaps I'll build on this design in the future, but I havn't done so yet. The output signal is a bit noisy, but using an Arduino as an A/D converter I was able to capture my heartbeat and convert it into audio using Goldwave. This design was based on a circuit posted by Scott Harden.


Bench Power Supply Part 2

Now that I've got my specs figured out, it's time to start some high level design. This will allow me to get the layout of the power supply set before diving into the small details. Hopefully this will make the design process more efficient. One of the biggest things that will affect this high-level design is one particular design specification. That is, the call for a switching knock-down stage. The reason I chose to include this is efficiency. Many lab power supplies I've seen out there have one thing in common: Many of them use linear regulators like the LM7805 or LM317. These are good devices, but they all have very low efficiency, especially when the dropout voltage is high. Enter switching regulators. Switching regulators can have very high efficiency (upwards of 95%) which allows for higher current handling, and less heat dissipation. However, they have a drawback. Switching regulators typically have more noise on their outputs. They may be OK for some circuitry, but this inherent noise will not do for the lab power supply I intend to build. To get the best of both worlds, I plan to use both types of regulators in my design. The switching regulator will take care of most of the voltage dropout first, while leaving about 2-3 volts for the non-switching (a.k.a. linear) portion to drop second. This will reduce power dissipated in the non-switching section of the power supply, which has numerous advantages, including (hopefully) eliminating the need for a noisy fan, as I'd like to make this thing as small, quiet, and cool as possible. This would definitely not be possible without the switching section in front. Now, it's time to make some initial part choices:

Parts List:

  • Linear Output transistor: P-Channel MOSFET IRF9540
  • Switching Regulator: LM2679-ADJ
  • Switching Regulator Inductor: Digikey# 553-1121-ND
  • Switching Regulator Capacitor: Digikey# P15372CT-ND
  • Current Sensor: ACS712

This should help lay the groundwork of the power supply. Next we'll look at putting in some control circuitry, including op-amps and so on...


Bench Power Supply Part 1

Graduation is on the horizon, and I've spend too many years using wall-warts as my primary bench power supplies. I'm ready to finally build something I can be proud to have on my bench. So, I'm setting out to build a really high quality bench power supply. Every good project starts with a list of goals and in this case that means setting the specifications for my power supply. I think it's good design practice to decide what you seek to accomplish before you spend too much time designing. So, without further delay, here are the initial specs that I'll be designing to. Design Specifications:

  • Dual Floating Outputs
  • Adjustable Voltage, 0-30V, Steps of 10mV
  • Adjustable Constant Current 0-5A, Steps of 1mA
  • Soft output On/Off Switches (Default: OFF)
  • Output On/Off Indicator LEDs
  • OLED Text Display
  • Voltages/Currents set with single rotary encoder
  • Serial Computer Interface (Read/Set Voltage/Current)
  • High power efficiency, switching knock-down stage, regulated final stage
  • ICSP Header for firmware updates
  • Made from low cost parts

Now that the specs have been written down, I'll begin designing the circuitry. Stay tuned for part 2.


Weather Station

I've been spending some of my spare time tinkering with the famous Arduino again. This time I've managed to build a network enabled weather station platform. It's pretty simple so far. It is currently only measuring temperature using an LM34 temperature sensor. It's just strung out my window, and is programmed to take a reading every 15 minutes.
The communication is done through an Ethernet Shield. This device sits on the Arduino and allows it to make basic HTML requests and pushes data to a PHP script on my website using the URL and the PHP _GET function. The data is then stored in a CSV file and displayed via a Google Graphing API. BTW, this is live data you're seeing and the time is local time (Pacific). View the weather station page


KGHP Radio Station

Tyler Pattison KGHP Radio N1QQ Peninsula High School

Most hams will remember the first time they spoke on the air, weather it was on an HF radio of an elmer down the street, or a VHF handheld. I was in high school and got interested in the school radio station, KGHP, during my freshmen year. Leland Smith, a teacher, introduced me to the radio station after school one day, and the memory of fading two songs together for the first time was pretty cool. Peninsula High School is one of very few high schools with a radio station these days. The cost of keeping these stations on the air isn't too attractive to most school districts, but the students, the school district, and members of the community have done a fantastic job at getting some support and funds to keep the station on the air. Spencer Abersold has been at the front of this effort to keep the lights burning at KGHP. Spencer and some of the students involved with the station have managed to get enough money recently to do a station re-model. It makes me happy to see a local radio station going so strong.


More Features For The Repeater Database

Repeater Database Washington Puget Sound Ham Radio Tyler Pattison N1QQ

I've been spending a bit more time on the repeater database. It's evolved from a simple html table with data from various sources, to a full-blown database-driven system that supports user editing and has more features than you can shake a stick at. You might ask, "Are all these features necessary?" and the answer is no. I didn't do this to try and compete with some ham radio repeater websites. I just did it to learn about databases, and to have some fun, while getting a useful list of repeaters in the area. The database now has a google map for every repeater, as well as websites, and other information in every entry. It's probably overkill, but like I said, it was a learning experience.


Selecting a Power Supply

Tyler Pattison Ham Radio Power Supply Astron RM-60M

Many modern ham radios operate on low voltage DC instead of high voltage AC. This is done for several reasons. First, most of the circuits inside these radios actually run on low voltage DC, so high voltage AC isn't needed. Second, running the radio on low voltage DC saves space inside the radio. This is because the radio can directly accept the low voltage DC it needs, and dosen't need an internal power supply to convert from high voltage AC to low voltage DC. Finally, the last advantage is that these radios can easily be installed in a car or run on a car battery.

So, this leads to the main point. What power supply do I need for my radio if it says it requires DC? The short answer is: Many different supplies will be adequate. The two most important things to pay attention to are the following:

  • Does it produce the proper voltage?
  • Can it supply enough current?

Many DC power supplies on the market today provide 12 Volts DC (Actually 13.8 Volts is considered "nominal"). It is important to check the specifications and make sure that the output voltage on the supply is close to what your new radio calls for. A few volts difference is usually OK.

Next, check the maximum continuous current rating of the power supply. The power supply should provide at least the amount of current your radio needs plus 10%. The extra 10% is headroom to prevent your power supply from overheating. Most hams follow this extra 10% rule and some go even higher. Remember that you radio will not always need the max current that is listed on the radio's specs. This is usually the current drawn when the radio is transmitting on full power. The current the radio requires when it's receiving is typically much less.

So, in conclusion, you will need a power supply that matches the voltage of your radio, and can supply enough current to keep your radio running. Extra features like meters aren't absolutely necessary, but can be nice for troubleshooting problems, however, they cost more!


Washington State Repeater Database

Repeater Database Washington Puget Sound Ham Radio Tyler Pattison N1QQMy latest project has been to develop and easy-to-use repeater database for the state of Washington. It is currently filled with repeaters from across the state on bands from 10 meters up to 900 Mhz. I'm in the process of verifying all of this data which has been collected from various sources on the internet. Some of them are cited with a link, and some were not able to be confirmed. I need help doing this. If you'd like to lend some help by simply getting on the air and trying out the listed frequencies in you're area, let me know! I'll get you access to the database editor right away.


How To Use an Antenna Tuner

Repeater Database Washington Puget Sound Ham Radio Tyler Pattison N1QQ

Using a manual antenna tuner can be a daunting task for someone who has never used one before. Before we begin using the tuner let's take a moment to define what an antenna tuner is, and some of its most important parts.

Contrary to what it's name implies, an antenna tuner does not "tune" an antenna. In fact, it does not modify your antenna in any way. It simply serves as an impedance matching device, or impedance matching network. Allow me to use a metaphor. The gears on a bicycle serve to connect the pedals to the wheel so that the person riding the bicycle can turn the pedals at an efficient speed, which is somewhere between 70-100 rpm depending on the rider. If you did not have these gears you would have to turn the pedals very fast when riding down hill, and very slowly when riding up hill. This is not efficient. The gears simply allow you to pedal at an efficient speed so that you can deliver maximum power to the wheel at all times. The antenna tuner serves a similar, albeit much more complicated purpose. Note that the gears on a bicycle do not change the way the back wheel works, they simply change how the wheel is connected to the pedals. The antenna tuner operates in the same way. It does not change the antenna. Rather, it modifies how the antenna is connected to the radio so that the radio can deliver maximum power to the antenna.

In almost every antenna tuner you will find capacitors and inductors. These capacitors and inductors can be wired in several configurations, but the most common is two capacitors and an inductor wired together in a "Pi" network. Take a moment to look inside your antenna tuner sometime and identify these components. See how they move when you turn the dials on the front of your tuner.

Now that you have an idea of the basic components inside your tuner, and the purpose a tuner serves, let's take a look at the steps required to tune an antenna.

First, begin by setting the capacitors to their highest setting. Next adjust the inductor until the background noise in your receiver peaks meaning you see a rise in the S-meter. If you are not able to produce a peak in the receiver try reducing the settings of the capacitors to 90% of their highest setting, then adjust the inductor. If you are still unable to produce a peak in the recieved signal, reduce the capacitors to 80%, then 70% etc.

When you have found a strong peak in the received signal, you are close to you're optimal tuning point. It should be noted that there are many tuning points which will produce a low SWR, but in order to maximize efficiency you'll need to minimize the inductor setting and maximize the capacitor settings.

Next, put your radio in CW, FM, or AM mode. Do not use SSB mode because no power will be produced unless you are talking into the microphone. Make sure the output power setting is set to it's lowest value. After making sure that you can legally transmit on the frequency you've selected, key the transmitter and observe the SWR on the tuner. Fine tune the two capacitors until a low SWR is obtained. Again, remember that there are many combinations of settings that will produce a low SWR, but combinations with low inductance and high capacitance will have higher efficiency and reduce losses in the tuner.

Once the SWR reads zero, and you are confident that the inductor is set to the lowest value that will produce an acceptable SWR, you are finished!


Space Weather Script

I've been working on a PHP script that can be embedded into webpages. This script that I've written is designed to collect the latest solar data from the NOAA FTP servers and display it neatly in a HTML table. If you'd like to place this simple script on your website you may do so for free (with no advertisements or credit required). If you'd like to see it in action check out the space weather page under radio resources.

<?php
$wwv = "http://services.swpc.noaa.gov/text/wwv.txt";
$dsd = "ftp://ftp.swpc.noaa.gov/pub/indices/DSD.txt";
$wwv = @file($wwv);
$dsd = @file($dsd);

$flux = get_flux($wwv);
$k = get_k($wwv);
$ssn = get_ssn($dsd);
$a = get_a($wwv);
$day = get_day($dsd);

function get_flux($wwv)
{
	$line = explode(" ", $wwv[7]);
	return($line[2]);
}

function get_k($wwv)
{
	$line = explode(" ", $wwv[8]);
	return(str_replace(".", "",$line[11]));
}

function get_ssn($dsd)
{
	$line = explode(" ", $dsd[42]);
	return($line[8] + $line[9] + $line[10]);
}

function get_a($wwv)
{
	$line = explode(" ",$wwv[7]);
	return(str_replace(".", "",$line[7]));
}

function get_day($dsd)
{
	$average = 0;
	for($i = 0; $i < 10; $i++)
	{
		$val = explode(" ",$dsd[(42-$i)]);
		$val = $val[8] + $val[9] + $val[10];
		$average = $average + intval($val);
	}
	return(round($average/10));
}
?>
<h2>
<center>
  <strong>Latest Solar Indicies:</strong>
</center>
</h2>
<table width="375" border="2" align="center">
  <tr>
    <td width="35%" height="18" align="center" valign="middle"><h4><strong>Current Solar Flux Index (50-350)</strong></h4></td>
    <td width="10%" height="18" align="center" valign="middle"><h4><?php print($flux); ?></h4></td>
    <td width="55%" height="18" align="center" valign="middle"></td>
  </tr>
  <tr>
    <td height="18" align="center" valign="middle"><h4><strong>Current K Index (0-9)</strong></h4></td>
    <td height="18" align="center" valign="middle"><h4><?php print($k); ?></h4></td>
  </tr>
  <tr>
    <td height="18" align="center" valign="middle"><h4><strong>Current A Index (0-400)</strong></h4></td>
    <td height="18" align="center" valign="middle"><h4><?php print($a); ?></h4></td>
  </tr>
  <tr>
    <td height="18" align="center" valign="middle"><h4><strong>Current Number Of Sunspots</strong></h4></td>
    <td height="18" align="center" valign="middle"><h4><?php print($ssn); ?></h4></td>
  </tr>
  <tr>
    <td height="18" align="center" valign="middle"><h4><strong>10-Day Sunspot Average</strong></h4></td>
    <td height="18" align="center" valign="middle"><h4><?php print($day); ?></h4></td>
  </tr>
</table>

Meet the Arduino

Arduino Ham Radio Tyler Pattison N1QQ

If you're a ham and you haven't heard about the Arduino then you're missing out!
The Arduino is a small micro-controller board that can be programmed on your computer. The possibilities are endless. All you need is the board itself (about $25) and a USB cable to get started. You can power the Arduino off almost any low voltage DC supply and use it to control all kinds of cool "smart" projects. I've used mine to control a beacon transmitter via the internet.
The possibilities are endless. For example, and Arduino could be used to generate the Morse code for a beacon and control its operation. Everything you would need to run a great 6 meter beacon in one PCB, all for under $30. Don't delay, buy an Arduino today!


Oscillo-what?

2213A Oscilloscope Tyler Pattison N1QQ

Yesterday was the annual flea market put on by the Mike and Key ARC down in Puyallup, WA. As always, I couldn't leave empty handed so I picked up (for a really good price) the nicest oscilloscope I could afford (with my starving college student budget). It is a Tektronix 2213A. It's a dual trace, 60Mhz, analog scope and should serve me well for years. It was bought from Eric, AD7BF of Everett.