Introduction: Computer Controlled OTA TV Antenna.

About: computoman.blogspot.com Bytesize articles instead of a trilogy in one post.

Setup to use a stepper motor to control the direction of a DTV antenna

Parallel port add-on to set the direction of an antenna. it could be used for most any antenna, but I did it for the hdtv antenna (https://www.instructables.com/id/Yet-another-dtv-antenna/).

Note: This instructable requires programming. I did not include my code for legal reasons.

Warning: Please be careful with this project. Not properly hooking wires correctly could cause shock and or even death. You could also damage your computer and other electronic parts. Please get a professional electronics technician to help if you are not sure what to do. . Please use a breadboard first before doing any soldering. Get expert help if you are not sure.


Pseudocode:
Get needed tv station degree from input.
Get current angle  from compass.
If compass angle less than tv station degree then use stepper motor to turn in that direction till correct direction is achieved,
otherwise go the opposite till correct degree is achieved.

Step 1: Whats Needed:

Computer:
PC with parallel port.
Linux (can be easily done on MSWindows also)
Freebasic compiler (available for both mswindows and linux)

Parts:
1 - 5 wire stepper motor from an old 5 1/4" floppy drive (or equivalent).
1 - 1 x 1 inch square flat plastic for mounting tube.
1 - parallel port breakout cable (i.e.https://www.instructables.com/id/No-solder-parallel-port-break-out/ or https://www.instructables.com/id/Mini-parallel-port-break-out-cable/) or an equivalent.
1 - OTA TV antenna ( i.e. https://www.instructables.com/id/Yet-another-dtv-antenna/)
1 - 1/2 to 3/4 inch two foot pvc pipe. low pressure pipe is ok.
2 - 1/4 inch screws (long enough to go through pipe and the antenna, 4 washers, and 2 nuts,
1 - uln2803 or equivalent integrated chip (i.e. nte2013)
1 - socket for the above chip.
1 - small plank to hold stepper motor steady.
Solder
Glue
Wire
Optional: breadboard for testing circuits before soldering (recommended)

Tools:
Multimeter
Compass
Saw
Soldering Iron

Other website information to be named later.

Step 2: Rescue a Part.

You will want to rescue a 5 wire stepper motor from an old 5 1/4 inch drive.  You may have to be gingerly with the cable on some of them. Four wires receive impulses and the other wire is for power (+12 volts). Other stepper motors that have more or less wires will require additional electronics which I do not want to deal with.

Slot power cable adapter is great for using the pc ps to power your projects.

Note
You can see the hole where the stepper motor came out of. The connector bar did not come from the drive. I just did not detach it because I wanted to use it for some experiments.  Some really old drives may also have the uln2803, but you will have to de-solder it from a board.

Step 3: Which Wires Are Which?

You need to find the common wire to know what to hook the +12 volts to. Normally the other wires are in order(like the last pic below) but not always.

Using a multimeter:

   1. Each of the two phases should have the same resistance when measured with a multimeter. When measuring the resistance across one wire from each of the two phases, the resistance should be infinite because the circuit is open. Locate the two pairs of wires that represent the two phases, and both pairs of wires will have similar internal resistance.
   2. Connect each phase to the amplifier and ignore the polarity (+ / -), for now. You have a 50% chance of guessing right.
   3. Send a command to move the motor. If the motor rotates in the wrong direction, then switch either phase A and A- or B and B- (effectively reversing directions).

Common will be half the resistance to any of the wires compared to the resistance of one phase.
I.e.
A+ to B+ = 144 ohms
A+ to B-  = 144ohms
B+ to A- = 144 ohms
B- to B- = 144 ohms
Common to any other wire is 72 ohms. Do not hook anything up till you are sure of this!! The last picture is an example that worked for me. It may not work for you.

Note: I am using I think a Teac 14769070-30 4x0 4 stepper motor,

Step 4: Soldering.

Since we are only using one stepper motor and the uln2003 chip has 7 outputs,  we will use every other pin to make soldering easier or you can follow the schematic below.  Since the stepper motor required 12 volts you make to  make an adapter to attach to one of the drive power cables +12 volt line. The ground from the computer will have to be attached also to the common ground point. Do not attach +12 volts to ground!!!!!!!

Note :
Some chips have eight outputs. You probably only need to ground to pin 8 only (on 16 pin chips). Common (pin 9 on 16 pin chips)  goes to +12 volts (9 and 10 respectively on the 18 pin chips). Does also not hurt to use a socket so you do not have to solder directly to the pins of the chip than to take a chance on ruining the chip. Please use a breadboard first before doing any soldering.

uln2003 = nte2013 = 7 inputs/outputs
uln2803 = nte2018 = 8 inputs/outputs

Step 5: Build the Antenna Setup.

Take your Pvc pipe and and drill two holes for 1/4 inch screws to hold the antenna. Distance between the the holes should be less than that of the length of the antenna page.
Take the 1 x 1 in square and glue it to the end of the motor.
Let it dry.
Take the uncut end on the pipe and glue it to the square. (Note antenna needs to be straight up and down with no leaning.)
Let it dry.
Get enough two conductor wire to go from the antenna to your receiver.
Connect the wires.

Step 6: The Software.

This is not a tutorial on programming. You can use what ever language you want but I will use basic for sake of simplicity for these code snippets. If motor goes opposite from what you expect then the wiring is backwards. Use this test code to make sure the steeper motor is working right. Caveat: this worked for the motor i used. you may have to use different wires. Once of the reasons it is good to use a breadboard first before soldering.

Clockwise:

out 888,0
for x = 1 to 10
out 888, 1
sleep 1
out 888, 2
sleep 1
out 888, 4
sleep 1
out 888, 8
sleep 1
next x
out 888, 0

Counter clockwise:

out 888,0
for x = 1 to 10
out 888, 1
sleep 1
out 888, 8
sleep 1
out 888, 4
sleep 1
out 888, 2
sleep 1
next x
out 888, 0

You will compile this code with:
fbc -lang qb progname.bas

Note I will probably put up more extensive code later. You have enough to get you started. The code I have written is copyrighted and has some very special routines which I do not want to publish at this time.

Example: http://www.electro-tech-online.com/general-electronics-chat/3631-qbasic-program-controlling-stepper-motors-i-wrote-one.html



----------------------------------------------------------------------------------------------

What someone else wrote in legacy basic.
If anyone out ther is interested in controlling a unipolar stepper motor via the parallel port on your pc and also uses Qbasic then copy the code below into a qbasic file and have at it. The program will prompt the user for mode of operation eg. single coil excitation mode or double coil excitation mode, direction and how many clock cycles to make the delay. A good value for my "VERY ANCIENT" pentium 133mhz pc is anywhere from 45 to however long you want the delay between coil energization to be. below 45 clock cycles the stepper motor likes to malfuntion. I am using parallel printer sentronics? connector. Modify the program to your liking. Sorry I did not include comments.
pins #2 for coil 1
#3 for coil 2
#4 for coil 3
#5 for coil 4
#18(can be any ground) for ground.

I am also using a uln2803 darlington transistor array to drive the motor.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
;Written by Sam Bixler ;
;Date 03-10-03 ;
;For controlling a unipolar stepper motor via a parallel port ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;

CLS
VarMode = 0
VarRot = 0
VarRev = 0
VarDelay = 0
int1 = 0


Main:
CLS
OUT 888, 0
DO UNTIL INKEY$ <> ""
PRINT "Enter the number of revolutions"
INPUT VarRev
VarRev = VarRev * 50
PRINT "Enter the Mode of operation"
PRINT " 1 for single coil excitation"
PRINT " 2 for double coil excitation"
INPUT VarMode
PRINT "Enter the number of delay cycles"
INPUT VarDelay
PRINT "Enter the direction of rotation"
PRINT "5 for CW 7 for CCW"
INPUT VarRot
VarMode = VarRot + VarMode
IF VarMode = 6 THEN GOTO ScCW:
IF VarMode = 7 THEN GOTO DcCw:
IF VarMode = 8 THEN GOTO ScCcw:
IF VarMode = 9 THEN GOTO DcCcw: ELSE GOTO nd:

LOOP

ScCW:
DO
GOSUB Step1:
GOSUB Step2:
GOSUB Step3:
GOSUB Step4:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

ScCcw:
DO
GOSUB Step4:
GOSUB Step3:
GOSUB Step2:
GOSUB Step1:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCw:
DO
GOSUB Step5:
GOSUB Step6:
GOSUB Step7:
GOSUB Step8:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCcw:
DO
GOSUB Step8:
GOSUB Step7:
GOSUB Step6:
GOSUB Step5:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

Step1:
OUT 888, 0
DO
OUT 888, 1
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP


Step2:
OUT 888, 0
DO
OUT 888, 2
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step3:
OUT 888, 0
DO
OUT 888, 4
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP

Step4:
OUT 888, 0
DO
OUT 888, 8
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step5:
OUT 888, 0
DO
OUT 888, 3
IF int2 = VarDelay THEN RETURN
int2 = int2 + 1
LOOP

Step6:
OUT 888, 0
DO
OUT 888, 6
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP

Step7:
OUT 888, 0
DO
OUT 888, 12
IF int2 = VarRev THEN RETURN
int2 = int2 + 1
LOOP

Step8:
OUT 888, 0
DO
OUT 888, 9
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP



nd:
OUT 888, 0

Step 7: Available Stations.

You want to go to http://www.antennaweb.org/ to find out what stations are available and what direction the antenna should be pointed. Now you can use the compass to see which way is North or 0 degrees.

Step 8: Setting the Stepper Motor.

You need to set the antenna is facing due north (0 degrees)  so that you can calibrate the stepper motor. I am assuming you have used a compass before.The antenna will only need to go 90 degrees either side of north. you could get one of these and use it to keep the right direction: http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/98/List/1/Default.aspx?SortField=UnitCost,ProductName But that is another instructable.

You will need to experiment with the code that I showed earlier to see how much it takes to go 1 degree. The stepper motor code will also have to know where it is at. Now if someone manually moves the antenna this will of course throw all the settings off. You will have to reset the antenna and the software.

Step 9: Watching TV.

Most stations are with in degrees of each other and setting the antenna once would be fine, it was an interesting experiment. if you do rotate the antenna, you may need to rescan the channels. I get about 40 channels as is. There are a few more channels I want to get.

Note: updated pictures coming. Camera died.

Step 10: Extra Video Card I2c.

You will need a vga breakout cable: https://www.instructables.com/id/Vga-breakout-cable/ or equivalent

Setting up the software:

$ sudo yum install i2c-tools i2c-tools-eepromer

$ modprobe i2c-dev

$ i2cdetect -l
i2c-0 unknown    nouveau-0000:01:00.0-0           N/A
i2c-1 unknown    nouveau-0000:01:00.0-1           N/A
i2c-2 unknown    nouveau-0000:01:00.0-2           N/A
i2c-3 unknown    SMBus nForce2 adapter at 5000    N/A
i2c-4 unknown    SMBus nForce2 adapter at 5100    N/A

Good basic way to see whether it is working.

$ sudo i2cdump -r 0x60-0x68 -y 0 0x50 b
[sudo] password for eddie:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
60: 45 4c 4c 20 4d 37 37 30 0a                         ELL M770?

$ sudo i2cdump -r 0x5f-0x68 -y 0 0x50 b
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
50:                                              44                   D
60: 45 4c 4c 20 4d 37 37 30 0a                         ELL M770?


Seen some variations that use a y-cable for the vga connection. Think I have a Y-cable somewhere. Looking for it.  We were using the s-video port so the vga port would be left free. may still try that. Cut a vga cable from a dead monitor to use for the interfacing.

Also see:
http://www.paintyourdragon.com/?p=43

One place to get an i2c compass: (Think I purchased mine from Jameco)..
https://www.sparkfun.com/products/7915

Step 11: Adding the Compass.

Under construction.

I2cget and i2cdump will be used to get the data from the compass. Must be very carefull with the commands. Read the documentation first.

$ man i2cget # i2cget
$ man i2cdump

Debugging: http://www.linurs.org/linux/html/I2c.html

Step 12: Abandoned I2c Interface.

Was going to use the parallel port but the vga seemed so much easier.