HDTV OTA

The other day we decided to try out the HDTV reception over the air (OTA). We are close to the CN tower, but facing away from it and shielded from the signal by a building. For starters I ordered a  nice indoor antenna from DELL. Works nice, however could not pick up more than three channels in one position. For more channels we had to constantly move the antenna. Tried it at a neighbour’s who faces the tower, perfect. However, we have to rely on signal-bounce and this one seem to be too directional for that.

Good news was that it was a time to tinker a bit. It has been a long time since I calculated some antennae, but with a help of the ARRL Handbook and some web search I was quickly in business.


Here are some antenna configurations I have tried:

  • two spoons (tea spoon-dipole),
  • two paper clips,
  • two tape measures,
  • tape measure + tea strainer,
  • coat hanger antenna (without reflector),
  • aluminium foil + resistor (T2FD = tilted terminated folded dipole).

All of the above configurations worked as well as the fancy commercial antenna, check out some pictures. The last one proved to be the best, we get six channels in one spot and takes a small move to get one more channel.

This is what it takes:

  • Some aluminium foil (usually found in the kitchen).
  • One 390 OHM resistor (1/8 or 1/4 W).
  • TV matching transformer 300 to 75 Ohm (cost = $1).
  • A piece of coax cable (already attached to the TV).
  • Scotch tape to keep it in place.


This works better (at our location) than the fancy commercial antenna. At the end it was mounted on a 12-inch wooden ruler and a wooden salad-spatula bracket was added to support the transformer and the coaxial cable. A nut (1/4) was super-glued to the bottom of the spatula to allow tripod-mounting. Anything looks good mounted on a tripod. Here is the final configuration.

With this we can get the following HDTV channels:

Station Channel (DTV) Frequency (MHZ)
CBC 20-1 (5-1) 507
CTV 40-1 (9-1) 627
Omni2 44-1 651
City TV 53-1 705
Omni1 64-2 771
Global 65-1 777
Sun TV 66-1 783


If you feel like trying, and are close enough to the tower, here is the procedure:

  1. Find a 12 inch wooden ruler or piece of cardboard 12×2 inches;
  2. cover it with aluminium foil and secure the foil using scotch tape;
  3. download the template and print it, make sure it is not resized during the print;
  4. place the template over the foil and cut through with an X-Acto knife;
  5. remove the excess foil, make sure the loop stays aligned;
  6. mount the ruler on a support (a spatula will do) to form a T, using glue or adhesive pads;
  7. mount the TV matching transformer to the spatula;
  8. slide the transformer leads below the aluminium foil and tape over;
  9. slide the resistor leads below the foil and tape it in place;
  10. attach the coaxial cable to the digital signal input of your TV.

Notes:

  • Your TV must have a digital (ATSC) tuner for this to work.
  • Somewhere in the TV setup menu you should select antenna instead of the cable input.

Creepy-crawly robots

Yuck, amazing.


Slow plot in Excel

It takes a click or two to create a chart in Excel, but it was not always that easy.

Once upon a time, in the days of Commodore 64, Sinclair ZX81 and Spectrum, Amstrad/Schneider 464/6128, and BBC Micro, charts had to be programmed using PLOT(x,y) or a direct POKE to the screen-mapped memory. Sounds tedious, but it was a definite improvement over the IBM 1130 with a drum plotter which had to be fed punch cards; drum and pen movement were controlled separately in incremental mode. Well, I am the same age as Fortran IV.

The machines were slow, so one could always see the chart being plotted dot by dot. That is what I miss these days—for some charts (scatter, polar) it is useful to slow down plotting so one can actually see the line being plotted.

Here is a small VBA program to animate a scatter chart by dynamically changing (increasing) the chart's data source range—row by row every time increment (tick).

In a VBA module:

Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
'
Public Sub AnimateChart(SheetName As String, _
                    DataRangeName As String, _
                    Optional ChartIndex As Long = 1, _
                    Optional Tick As Long = 50)
    '
    ' Comments  :  Animates chart by dynamically changing the
    '               data source range
    '
    ' Parameters:  SheetName - name of the sheet the chart is on.
    '              DataRangeName - named range for the data,
    '                              includes header.
    '              ChartIndex - 1 for the first chart on the sheet,
    '                           2 for the second etc..
    '              Tick - update interval;
    '                     suggest: 50, 100, 150
    '
    ' Modified  :  2008-06-29
    '
    On Error GoTo PROC_ERR
    Dim Chrt As Chart
    Dim rngSrc As Range
    Dim rngRef As Range
    Dim NumberOfPoints As Long
    Dim CurrentPoint As Long
    Dim OldPoint As Long
    Dim Strt As Long
    Dim rw As Long
    Set Chrt = Worksheets(SheetName).ChartObjects(ChartIndex).Chart
    Set rngRef = ThisWorkbook.Names(DataRangeName).RefersToRange
    NumberOfPoints = rngRef.Rows.Count - 1
    CurrentPoint = 0 'current animation point
    'clear the chart (show first point only)
    rw = 2
    OldPoint = 1  'first point is in the second row of the range
    Set rngSrc = rngRef.Resize(rw)
    Chrt.SetSourceData Source:=rngSrc, PlotBy:=xlColumns
    DoEvents 'update screen
    Strt = GetTickCount 'remember start tick count
    Do
        CurrentPoint = CLng((GetTickCount - Strt) / Tick)
        If CurrentPoint > OldPoint Then
            rw = rw + 1
            Set rngSrc = rngRef.Resize(rw)
            Chrt.SetSourceData Source:=rngSrc, PlotBy:=xlColumns
            OldPoint = CurrentPoint
        End If
        DoEvents
    Loop While (CurrentPoint <= NumberOfPoints)
PROC_EXIT:
    Set rngSrc = Nothing
    Set rngRef = Nothing
    Set Chrt = Nothing
    Exit Sub
PROC_ERR:
    MsgBox Err.Description
    Resume PROC_EXIT
End Sub

In a Worksheet module, the button's click event—cbtAnimate_Click()—prepares data for a specific chart and calls AnimateChart(). Chart data should be defined as a named range which is passed via the DataRangeName parameter.

Private Sub cbtAnimate_Click()
    cbtAnimate.Caption = "busy..."
    AnimateChart SheetName:=Me.Name, _
                DataRangeName:="Lissajous_Data", _
                ChartIndex:=1, _
                Tick:=50
    cbtAnimate.Caption = "Animate"
End Sub

You can download the workbook with examples for a Lissajous curve, a logarithmic spiral, and a rose curve.

List tables, columns and defaults in a database

The code snippet lists all tables, columns, data type, null-ability and default values for a database. Tested on MS SQL Server 2005. Handy for a quick check of data types and defaults.

/* List tables, columns, data type and default values */
USE ASI2353;
SELECT   [TABLE_NAME] AS "Table"
        ,[COLUMN_NAME] AS "Column"
        ,[DATA_TYPE] AS "Data Type"
        ,[CHARACTER_MAXIMUM_LENGTH] AS "Data Length"
        ,[COLUMN_DEFAULT] AS "Default"
        ,[IS_NULLABLE] AS "Nullable"
    FROM INFORMATION_SCHEMA.COLUMNS
WHERE [TABLE_NAME] != 'sysdiagrams'
ORDER BY [TABLE_NAME];

Stuff between your ears


WP DB

It is fun to reverse engineer databases. OK, you may have a different idea of fun. Here is the WordPress 2.5.1 database diagram from my server. See the online documentation for more details on tables and columns. This may help to clarify the previous post about tags.

Electric flight

A beautiful story of ingenuity, engineering, motivation and accomplishment.

 

The last table

Well, not really. Within a Data Pump SQL project it is called [dbo].[Last] and is primarily intended to be queried by third-party applications, like SCADA, EP, CEP or reporting tools. The table contains only one row with the latest serial number and the time-stamp from the [dbo].[PartData] table. Here is a typical example:

ID Val TimeUTC TimeLoc
1 200805151007 2008-05-15 14:30:01 2008-05-15 10:30:01

 

The table structure may vary, depending on the project. Time column in UTC allows for applications outside of the time zone.

Column Name Data Type Description
ID int ID column for this table; always 1 (one row only).
Val bigint Serial number of the last entry from [dbo].[PartData].
TimeUTC datetime Time-stamp of the last entry in UTC (GMT).
TimeLoc datetime Optional. Local time of the last entry.

 

The "third-party" application should query the [dbo].[Last] table and determine if there were any changes to the [dbo].[PartData] table since the last query.

SELECT [Val], [TimeLoc]
    FROM [dbo].[Last] WHERE ID = 1;

Once a change is detected, it is OK to query the [dbo].[PartData] table.

/* Time of the last query */
DECLARE @LastTime DATETIME;
SET @LastTime = '2008-05-15 14:30:01';
--
/* Query the table */
SELECT *
    FROM [dbo].[PartData]
WHERE [RecordDate] >= @LastTime;

Standard tables

Here is the list of tables in a typical Data Pump SQL project:

Object Name Schema Type Description
ClientPrivate dbo TABLE Client (Excel) setup info
Error dbo TABLE Error codes & descriptions
Field dbo TABLE Fields collected in the dbo.PartData
Header dbo TABLE Collection of header fields and order in reports
Limit dbo TABLE Process limits; LSL, USL
PartData dbo TABLE One row for each part
Station dbo TABLE Station names and IDs
Style dbo TABLE Style names and IDs
Last dbo TABLE Serial number and time-stamp of the last entry to the PartData table

 

For more details see the knowledge database article.

How to ask for a raise

Brain is the new frontier. Once upon a time, it was enough to work more and harder than most people and results were almost always granted. Not anymore. The average work week is rapidly approaching 70 hours—not counting the commute and chores—and income is not following, in many cases is going down. People hardly have any time left. One must work smarter, so we have to understand how the brain works and harness results of science and all the research. Here is Dr. John Medina’s presentation at Google and a link to his book, “Brain Rules”.

Example

Did you know that cardiovascular exercise:

  • Boosts brain power;
  • elevates the number of BDNF molecules per unit cell within hippocampus;
  • increases blood flow to the hippocampus;
  • directly influences and improves so called executive functions.

 

Application

If you think that your boss is fat and stupid, instead of just quitting try to do something constructive: pick up a baseball bat and start chasing him around the building. For (minimum) four weeks, three times a week, for about 25 minutes each time. Stay few paces behind, no need to catch him, just keep going. Remember, you must keep running—static muscle toning does not yield the desired result. After four weeks his cognitive performance may actually double. This will have a direct impact on morale and productivity in your department; therefore, you should confidently ask for—and be granted—a substantial raise. How could they refuse? Ok, what if they do refuse, in spite of the overwhelming scientific evidence you presented? Do not worry, after all the running, your executive functions will improve too. There is always competition looking to hire an employee willing to go an extra mile or two.

Sigma Story [5]: Surveyor

She was a looker. For her debut in 1820, she was the first to sail under the New London Bridge—celebrating the ascent to the throne of King George IV. But there was no use for her at the time, so she laid low for about five years. Then, she was retrofitted as a survey vessel; giving up four of her cannons and gaining an extra mast.

By 1830 she completed her first voyage, four and a half years surveying the coasts of Patagonia and Tierra del Fuego. She was a good ship, but the surveying task was daunting and ultimately boring. After about two years at sea, her captain had slid into deep waters of depression and had committed suicide—that boring.

She was due to return to South America for another five years. Her new captain took her to a dock, arranged for a new deck, retrofitted whatever he could, and loaded her with the latest and greatest surveying gizmos of the time.

Determined not to suffer the fate of his predecessor, the captain decided to look for an interesting companion—a gentleman interested in sciences—who would  accompany him and provide stimulating conversation at the dinner table. Eventually, he settled for a “naturalist” from a respectable family of doctors and scientists. And so, once more, on December 27, 1831, she set sail towards South America. Onboard, Charles Darwin was getting seasick.

To be continued.

WordPress tags

One can find quite a few tag-related plug-ins for the WordPress, but adding tags to your old posts may prove to be quite a tedious task. Here is a simple method of adding tags to old posts, but this one is not for faint hearts—you have to run a SQL statement against the database.

Before you start

Back-up the database, better safe than sorry.

Caveat

The following technique works only if the table wp_term_taxonomy has not been modified by a weird plug-in or manually; columns term_taxonomy_id and term_id should contain same numbers. To verify this, run the following:

SELECT COUNT(`term_taxonomy_id`)
    FROM `wp_term_taxonomy`
WHERE `term_taxonomy_id` != `term_id`;

The result should be 0. If the returned result is greater than 0, do not use this procedure.

Step 1

In the Manage-->Tags list, note IDs of your tags. Float the mouse pointer above the tag name to see the  "ID" displayed in the status bar of your browser. For example, some of my tags:

ID Tag name
12 data collection
13 six sigma
14 standard deviation
18 database

Step 2

Note IDs of your posts; floating the mouse pointer above a post name displays the "ID" in the status bar of the browser.

Step 3

Create a table of associations between post and tag IDs.

Suppose we want to add tags "database" (id=18) and "data collection" (id=12) to the post Basic database checkup (id=95); tags "six sigma" (id=13) and "standard deviation" (id=14) to the post Mathematician with no diploma (id=45).
The table would look like this:

Post ID Tag ID
95 18
95 12
45 13
45 14

Step 4

Based on the previous table, add rows to the wp_term_relationships using the code snippet. If you have more rows just follow the pattern below the "VALUES" keyword. The third number within parentheses is always 0.

INSERT INTO `wp_term_relationships`
    (`object_id`, `term_taxonomy_id`, `term_order`)
VALUES
    (95, 18, 0),
    (95, 12, 0),
    (45, 13, 0),
    (45, 14, 0);

Worked nice for me on WordPress 2.5.1.

Presenting stuff

If you happen to be in sales or marketing, presentations are taken for granted, as are the time and resources needed for development and practice. Even a relatively simple presentation can take 40-60 hours to prepare. For some reason, if you happen to be in engineering, you are often expected to whip up a presentation in a few hours. Makes no sense, but this is how it is. Well, here are few dos and don’ts; compliments of Garr Reynolds and Google.

 

Secret

No comment—up to you.

Basic DB maintenance

The code is useful for machine installations of  Data Pump SQL projects which periodically clear the  [dbo].[PartData] table. Before using this, make sure you first check the database as described here.  Change the 'ASI2353' to the name of your database.

/* Shrink database, leave file size; just pack inside the file
   Initial file sizes: DB: 2048MB; Log:256MB */

DBCC ShrinkDatabase ('ASI2353', NOTRUNCATE);
--
/* Defrag Indexes */
DBCC IndexDefrag ('ASI2353', 'PartData', 'pk_Part');
--
/* Reclaim space from dropped chars, varchars text.. */
DBCC CleanTable ('ASI2353', 'PartData');