Sunday, May 9, 2010

50 MHz AM Transmitter and Receiver



My fist adventure in radio! I started off by building a Hartley oscillator with one transistor and then amplitude modulated a signal with a second transistor. I then built an AM receiver schematic I found and calculated the tank circuit for the 50 MHz band.

Understand that this transmitter is extremely simple and haphazardly thrown together, it does not transmit any further than across the room but it is useful for understanding the basic concept of a transmitter.


AM Transmitter Schematic
(Q1 makes the Hartley oscillator, Q2 amplitude modulates the signal. It's only broadcast across a room. To increase power you would need to add some amplification. You may find this helpful for calculating the resistance values needed)

AM Receiver Schematic
(I recommend replacing the 120k
regenerative feedback resistor with a variable resistor. I used 2N3904 transistors in my build)

The Tank Circuit

The operating frequency of the Hartley oscillator and the frequency tuned in by the receiver is determined by the inductor (L) and the capacitance (C) values in the tank circuit.

Explanation of a "tank circuit".

In my circuit the variable capacitor's max capacitance is at 265 pF (estimated 290 pF to account for some stray capacitance) and the coils are roughly 1.746 uH (Micro Henrys). Turning the variable capacitor lowers it's capacitance and thus increases the resonant frequency.

I made the air-core inductor out of a .25 inch diameter soda straw.

Specs:
Diameter: .25 inches
Length: .75 inches
Turns: 31


This equation can be used for calculating the dimensions of an air-core inductor,

$\LARGE \color{white}\L_{(\mu H)}=\frac{d^2\cdot n^2}{18d+40l}$

Where,
  • L is inductance in uH
  • d is coil diameter in inches
  • l is coil length in inches
  • n is number of turns.

I found this air-core inductor calculator to be a very handy tool for designing coils.


Calculating Inductance Needed

To calculate the inductance L (in mico Henrys) needed you will need to know 2 things. What frequency you want to operate in (I chose 50 MHz because its in the amateur band) and your maximum variable capacitance (265 pF + 25 pF estimated stray capacitance = 290 pF)

The easy way to calculate this is,

$\LARGE \color{white}\L_{(\mu H)}=\frac{25330.3/Min. Frequency_{(MHz)}}{Max. Capacitence_{(pF)}}$

So using my values as an example,

$\Large \color{white}\L_{(\mu H)}=\frac{25330.3/50_{(MHz)}}{290_{pF}}$

Which comes out to,

$\Large \color{white}\L_{(\mu H)}=\ 1.746$

Thursday, April 1, 2010

Digital Clock - 7490 Decade Counters and a Hacked Quartz Clock



No microcontrollers needed here! I started playing with some 7490 decade counters and decided to build a digital clock. The first trick was getting an accurate 1 second time base. There are a few options here, you can divide the 60 Hz AC line frequency (in the US) down to 1 Hz or you can build a crystal oscillator and divide that frequency down with decade counters.

I decided to take a more hacked approach and took a 1 Hz oscillator circuit out of an analog Micky Mouse clock. There are a few different ways you can wire these up explained very nicely here. With my clock I didn't have to run the outputs through diodes or transistors (each output is 1/2 Hz), connecting them directly together worked just fine. I also powered it off the 5 volt supply by using a current limiting LED across its power input, the alternative is to have a separate battery for the clock. Every quartz clock circuit is different so its something you have to experiment with on the breadboard before building!


digital_clock_schematic.pdf

The time is kept by six 7490 decade counters. The 1 Hz clock is pulsed into a 7490 wired up as a mod 10 counter (for seconds 0-9). The output of the mod 10 counter is pulsed into a 7490 wired as a mod 6 counter (for seconds 0-5). That circuit is then duplicated for the minutes (0-59). The hours are then counted by two 7490s wired up as a mod 24 counter. (0-23).

The tens of seconds are displayed by 3 LEDs in binary. The 7 segment displays are driven by four 4511 BCD-to-7 segment decoders. I needed thirty-three 100 Ohm resistors in total for all the displays and LEDs. Good luck!

Saturday, January 30, 2010

Time Delayed Door Alarm


My cat likes to open the front door if we don't latch it properly, which is often. Waking up to a cold house sucks! I designed a time delayed alarm with a couple of 555 timers, if the door is open for roughly 30 seconds it sounds off a piezoelectric speaker until the door is closed again.

Here is the circuit.
(Printer Friendly PDF)



Parts Needed:

- 555 Timer (x2)
- 100k Resistor (x2)
- 10k Resistor (x3)
- 1 Meg-ohm Resistor
- 33uF Electrolytic Capacitor
- 2.2 nF Ceramic Capacitor
- NPN Transistor
- Diode
- Piezoelectric Speaker
- 16 Pin Socket
- 9 Volt Battery Clip
- 9 Volt Battery Holder
- 9 Volt Battery
- Magnetic Contact Switch (found much cheaper at Radio Shack)
- Radio Shack General-Purpose Circuit Board (46.8 x 72.2 mm)

If you don't have any of the resistors it would be cheaper to get a grab bag rather than buy individual resistances in bulk.

Also this circuit is not picky about voltages, you could probably use anywhere from 3 to 16 volts, anything that the 555 will handle.

How it works:

When the door is closed the diode keeps the capacitor (C1) discharged to ground.

When the door opens and the magnetic switch is disconnected the pull up resistor (R2) sets the trigger, on the first 555, high and allows the 33uF capacitor (C1) to charge through the 1 meg-ohm resistor (R1). When the charge reaches 2/3 of the supply voltage the output pin on the 555 is set low. The time it takes for the capacitor (C1) to reach 2/3 of the supply voltage is found by this equation,

Time(sec) = (1.1) x (Resistance) x (Capacitance)

For example if we take the values used in my circuit,

Time = (1.1) x (1,000,000) x (.000033)

The time delay comes out to about 36 seconds. Depending on the quality of the capacitor its not going to be totally precise for such a long delay but its close enough for our purposes. For more precise timing you would want to use a decade counter clocked with a 555.

Anyway, the output on the first 555 is inverted by the transistor, so when the output goes low after 36 seconds R4 pulls the output high, its basically a logic NOT gate. The second 555 is a simple multivibrator circuit which generates a square wave used to drive the Piezoelectric Speaker. The alarm will keep sounding until the door is closed thus resetting the circuit.

If you wanted to cheat you could do away with the second 555 timer and get a Piezoelectric Buzzer which will generate a tone on its own when a DC voltage is applied to it.

Let me know if you bother building one.


Tuesday, November 24, 2009

Tunnel Firefox through SSH with a SOCKS Proxy

You should always be careful when connecting to a public WiFi connection, you don't want to end up like these poor saps at the Defcon convention.

I'm sure you have found yourself in a situation where you had an overzealous network filter block websites on a public connection (like at a library, work, or school). Or perhaps you don't quite trust the connection you are on?

If you have a Linux box at home that you can SSH into, you can set up a socks proxy to tunnel firefox over an SSH connection. To anyone else it will appear as if you were surfing from your servers connection.

The command is:

ssh -D 8080 user@host -N

(This will work with putty on windows too)

Leave that terminal running in the background then in firefox go to...

Tools > Options (Edit > Prefrences in Linux) > Advanced > Network > Connection Settings

And set up a manual proxy configuration under the SOCKS Host to connect to localhost (IP: 127.0.0.1) and port 8080.

You can also set up Pidgin to use a SOCKS proxy in the same way for more secure IM conversations.

Cheers.

Sunday, November 8, 2009

Set up a free Dynamic DNS for your home Ubuntu server.

This tutorial assumes you are using Debian based linux, such as ubuntu, and you have a server set up with root privileges on a home connection.

DNS stands for Domain Name System, it is the service that allows you to go to google.com instead of having to remember google's IP address. A Dynamic DNS service will accept a change in IP address for a domain name. So instead of remembering your latest IP address assigned from your ISP to connect to your home server we will only have to remember one name, for example myhomeserver.dyndns.org. The server will then report any IP changes to the Dynamic DNS service.

There are a number of free Dynamic DNS services out there, for this tutorial we will be using DynDNS.

Head over to http://www.dyndns.com/ and enter in a name for your server.



You will then need to make an account with Dynamic DNS. Once you are finished it should set an IP address from where you logged in from by default. Now we are going to get your Ubuntu server to check if there is a change in IP address and if so log into your DynDNS account and report the change.

To accomplish this we are going to use the ddclient program.

First lets get ddclient from synaptic; execute this command:
sudo apt-get install ddclient

It will then run through a command line based installer and ask you a few questions to set up a basic config file. Answer all the questions it asks you, the DynDNS hostname you set, your DynDNS username and password, etc.

The tricky part is when it asks, "Enter the interface which is used for using dynamic DNS service."

If you are not behind a router or a firewall you can simply enter: eth0

But in my case I am behind a router so I cannot see what my global IP is, so I am going to use another server that will check the IP for me.

So if you are behind a router just skip this question and we will fix it manually in the config file later.

After synaptic is done installing ddclient we are going to have to manually edit the config file and add a few things. For this tutorial I am going to use emacs to edit the files.

Run the command: sudo emacs /etc/ddclient.conf

Your config file should look something like this:


# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=
server=members.dyndns.org
login=[your dyndns username]
password=[your dyndns password]
yoursite.dyndns.org


If your server is not behind a router then the use line should be set to "use=if, if=eth0".

However if your server is behind a router change this line,

use=if, if=

to this,

use=web, web=checkip.dyndns.com/, web-skip='IP Address'

And lastly put a new line that says,

daemon=600

This will tell the script to check your IP address every 10 minutes (600 seconds) using checkip.dyndns.com as a reference. If the IP has changed it will send an update to DynDNS else it will wait another 10 min and check again. The smallest value you are allowed to set for the update interval is every 60 seconds.

If you are using the emacs editor hold down the CTRL key and hit "X", then "S" to save your file. Then hold down CTRL again and hit "Z" to get back to the command line.


So your final configuration file should look something like this,


# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

daemon=600 #reports IP every 600 seconds

pid=/var/run/ddclient.pid
protocol=dyndns2
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
server=members.dyndns.org
login=[your dyndns username]
password=[your dyndns password]
yoursite.dyndns.org



Now that we are all configured it is time to restart the ddclient program.

Cross your fingers and execute this command,

sudo /etc/init.d/ddclient restart

Assuming everything is set up properly ddclient should report any IP address changes. Now there is still one problem, DynDNS expects an update at LEAST once a month or else it will set your account as inactive. This is an issue if you keep the same IP for more than a month.

To avoid this we are going to make a cron job that will force ddclient to update every month.

Execute the command "crontab -e". You will be greeted with a simple editor. Add this on a new line,


00 00 28 * * ddclient -host yoursite.dyndns.org -force


Then hold down CTRL and hit X, it will ask you if you want to save, type "y" to say yes and hit enter.

Everything should work beautifully now!

Cheers.

Wednesday, July 1, 2009

Early 80's Pirate Computers

Pete Perkins, an early pioneer of pirate hardware. He created, improved, and sold copies of Apple and IBM computers. A much simpler time for computers indeed. Core Duo's are great but when it comes to homebrew 8 bit was, and still is, king.

"Whatever you're mind can conceive and your heart can believe, than you can achieve; that's the purpose of this chip."
-Pete Perkins


Friday, March 27, 2009

Internet Controled Car v2 Parallel Port



My first version of the Internet Controled Car used a BASIC stamp to handle serial communication. This was a mundane task for a complex and expensive little microchip

This new version uses a parallel port printer cable which is controlled by a C program on the server. Using a parallel port also fixed an issue where the direction commands would get "stuck" if you hit two keys at once as the BASIC stamp code didn't have a buffer. I also mounted the components to a piece of wood and some standoffs so it wasn't a mess of wires all over the place.


The Parallel Port C Program

The parallel port program, written in C, will take a parameter to set the data lines, that is pins 2 through 9, to a logic high or logic low.

Example: ppp 1l 2l 3h 5h 8l



Here is the C source code for Linux.

#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/io.h>

//#include <asm/io.h>
// Didn't work, replaced with sys/io.h


char *binprint( unsigned char x, char *buf )
{
int i;
for( i=0; i<8; i++ )
buf[7-i]=(x&(1<<i))?'1':'0';
buf[8]=0;
return buf;
}

int main( int argc, char *argv[] )
{
char c;
unsigned char val;
char buf[9];
int x;
if( argc<2 )
{
printf("Example usage: ppp 1l 2l 3h 5h 8l\n");
return 2;
}
if( ioperm(888,1,1) )
{
printf("Couldn't find parallel port (888)\n");
return 1;
}
val = inb(888);
printf("old = %s\n",binprint(val,buf));
for( x=1; x<argc; x++ )
if( argv[x][1]!='h' )
val &= ~(1<<(argv[x][0]-'1'));
else
val |= 1<<(argv[x][0]-'1');
printf("new = %s\n",binprint(val,buf));
outb(val,888);
return 0;
}

To compile save the above code, in a text editor, as ppp.c
Then in the command line execute,
gcc ppp.c -o ppp

And then drop the compiled executable into $/bin/ so it can be executed from anywhere as a linux command.

Flash controller code:
The flash controller is pretty similar to netcar v1, it detects what arrowkey is being pressed and sends the information to the PHP script. I did change the variables though so use the new actionscript,

Download: car_remote_pp.as

PHP
The PHP program, combined with the C program, is basiaclly replacing what the BASIC stamp did, turning pins high and low to control the relays.

The PHP program gets the command from the flash aplication and, depending on what that command is, executes the C program with the paramaters to turn the proper data pins logic high or low.

In my hardware configuration I mapped pin 2 for forward, so to make the car go forward you would execute,
ppp 1h
2l
Pin 3 is mapped to backward so I make 2 a logic low because you can't be going forward and backward at the same time.

To make PHP execute a program you put the command in single quotes, for example 'ppp 1h 2l'

Let this PHP file sit in the same directory as your flash app.

Hardware
The rest of the hardware, for me, is the same as Net Car v1 sans the Basic Stamp. You will have to find a parallel port cable to splice open and use a multimeter with a continuity check to find what wires correspond to the data pins and, of course, ground. If you can find a ribbon cable parallel port those are very easy to solder into a chip socket and can be plugged into and removed from a breadboard or another chip socket if you decide to make a circuit board.

The hardware interface to the car remote circuit will be a little bit different depending on how the remote works. I used some double pole, double throw relays, turned on by transistors, to make the connections on the circuit board, which replaced what would normally be the connections made by the controller sticks. Now that I think about it I could have just used the transistors. You may have to put a diode on the base to make sure no higher voltage can back-feed into the lower voltage TTL circuitry, because most car remotes operate on 9v. Please correct me if I am wrong!

Edit: A couple of people recommended in the comments to use optoisolators instead of relays. They draw less power off the parallel port and are simpler, and quieter, than having a transistor turn on a relay. Actually now that I think of it using relay's is probably the most ridiculous idea I have ever had! I kinda like the clicking sound though :-)

The next step is to put a mini wireless webcam on it and stream the video through a webcam service. Or you can just have a webcam look at the car in a room and drive it around with an overview.

Let me know if you complete this project successfully, take a video and post it as a video response to my youtube video.