Thursday, January 26, 2023

ADS-B Quarter Wave Whip Antenna

I reclined in the winter garten nursing my back and watched a gaggle of geese and aircraft soar overhead, which made me realize that it's been a while since I made an Air Traffic Control (ATC) antenna, so I dug in my Junque Bochs for an old Raspberry Pi v3, a RTL-SDR dongle and a tripod telescopic test antenna, downloaded the latest ADS-B (Automatic Dependent Surveillance-Broadcast) decoder image from https://www.adsbexchange.com/ and went to workplay.

The last time I worked with ADS-B transponders was maybe five years ago, when I used a RTL-SDR to test a Sagetech Mode-S ATC transponder and the free decoder software has improved dramatically since then.  It took about an hour to set the system up and I could immediately see a handful of aircraft, as far away as 80 nautical miles (150 km), using a wonky little telescopic antenna on my office window sill.

After a while I captured an Emirates A380, a USAF Galaxy and a Slovak AF LET 410 Turbojet from the military airport nearby and I could see aircraft all the way to Vienna and Brno on my phone web browser - so how about aircraft around Prague?

To make a (hopefully!) better antenna, I broke out the O'l Slide Rule and calculated a quarter wavelength of 1090 MHz using λ x f = c, and λ = c / f, with c = 299792458 m/s. 

Therefore an ideal quarter wave whip needs to be 68.8 mm long, or that is what the comictext books would want you to believe. 

In practice an antenna is always shorter than the ideal, due to coupling to the environment, and the antenna support system - usually about 3% shorter.  

If you want your antenna to be spot on, you need a Vector Network Analyzer (VNA), so you can clip little pieces off the driven element, till the center frequency is exactly where you want it to be.  If you don't have a VNA, then you need to build five or ten antennas, each 1 mm shorter than the previous and then try them all and see which one works best, but to measure is to know!

With the help of my trusty Chinese VNA, I eventually found that the element length should be 62.5 mm, which is a good 10% shorter than the calculated ideal!

To make the antenna base, I cut a little wheel of fibreglass PCB with a hole saw and mounted it on a tripod with a piece of rigid strapping (a holy metal strip usually used to tie roof rafters together, but which is great for making ad hoc brackets, since it has an endless number of mounting holes at the ready).

The antenna elements were made from 18 SWG (1 mm) tinned copper wire, which is easy to work with.

The whip is soldered to the tip of a RG316/U coax, with the shield soldered to the copper board and the tip pointing up through the middle of the hole.  I glued it in place with epoxy. 

To make an earth plane, I soldered four quarter wave wires to the base PCB and bent them down - if you keep the earth plane flat, then the antenna will be very narrow band and difficult to tune.  

Bending the wires down, makes the earth plane fade away towards the horizon, which makes the antenna much more calm and open minded.  This bandwidth widening effect is amazing to see on a VNA - about 45 degrees seem to be optimal.  I also added a couple of ferrite beads to the wire, but found that they don't have any effect - the bent earth plane wires dominate.

To tune the antenna, I let the VNA run and snipped tiny 1 mm pieces off the tip of the whip, until the VSWR dip was near enough to 1090 MHz.  To tune an antenna, only adjust the driven element, leave the other metal parts alone.

The final tuned up antenna presented a VSWR of 1.1 and an impedance of 48 Ohm at 1090 MHz, which is a pretty good match to a 50 Ohm coaxial cable.

With the new finely tuned antenna sitting on my window sill, I can see about twice as many aircraft, up to about 108 nautical miles (200 km) away.

If you can mount an antenna outdoors, then it will work much better, but that is too much effort for me.  I'll just leave it in the window. 


I think this antenna build should be quite repeatable - the downward bent reflector wires make the bandwidth wide enough that it should work very well, even if your build is off by 50 MHz this way or that.

If you would add a 15dB Low Noise Amplifier to it, then you will get signals from 400 km or more, with too many aircraft to see on a phone.  A little googling will find little ready built pre-amplifiers specially made for ADS-B, with an integral SAW filter to reduce interference, but I don't think I'm going to bother, since my tuned-up antenna is good enough.

It would be best to build an antenna on top of a bulkhead mounted RF connector, but I buy RF jumper cables from Pasternack or Mouser for serious work and then when one end breaks off, I use the remainder for these kind of experiments, which usually reduces the cost of my hobby antennas to practically zero.

La Voila!

Herman


Wednesday, January 4, 2023

To C or not to C, That is the Question

As most would know, the Kernighan and Ritchie C Programming Language is an improved version of B, which is a simplified version of BCPL, which is derived from ALGOL, which is the Ur computer language that started the whole madness, when Adam needed an operating system for his Abacus, to count Eve's apples in the garden of Eden in Iraq.  The result is that C is my favourite, most hated computer language, which I use for everything.

At university, I learned FORTRAN with punch cards on a Sperry-Univac, in order to run SPICE, to simulate an operational amplifier.  Computers rapidly lost their glamour after that era!

Nobody taught me C.  I bought the book and figured it out myself.

Over time, I wrote a couple of assemblers, a linker-locator, various low level debuggers and schedulers and I even fixed a bug in a C compiler - not because I wanted to, but because I had to, to get the job done!  

Much of my software work was down in the weeds with DSP and radio modems (Synchronization, Compression, Encryption, Error Correction...) - which, nobody taught me, I had to figure it out myself.  Those were indeed primitive times.

This article is however about the other C - CancerAbout 30% of people get some kind of cancer. It is distressingly common.

Similar to learning C, Cancer is a journey of discovery, it is not something engineers would study at university - maybe we should though, since there is a huge market for diagnostic and treatment machinery.

High School Biology Revisited

As you should recall from your high school biology, almost every cell in a mammalian body has one or more mitochondria. Muscle and brain cells can have several. These organelles resemble bacteria, since they have a cell membrane.  The purpose of the mitochondria is to manufacture special molecules that are needed by a cell.  The most common product is ATP (Adenosine Triphosphate).  ATP is the main source of fuel for a cell, since it can be readily oxidized to produce heat.

Cancer is primarily a mitochondrial disease.  The mitochondria in a group of cells sometimes go haywire and start to produce the wrong chemicals and too little ATP.  The unwanted chemicals are a strain on the liver and kidneys, which must get rid of it and the lack of ATP can make one feel super tired very quickly.  A cancer patient should drink lots of water, to help the liver and kidneys.

The mitochondria normally also produce chemicals that trigger cell death - apoptosis.  If they stop producing that, the cells do not die when they should and the result could be growth of a hard tumour of faulty cells,  which consume nutrients and produce poisons.  A tiny tumour a few mm in diameter is enough of a producer-consumer problem to make one feel really dreadful.

Diseased mitochondria can mean that while walking on level ground may be OK, climbing a single flight of stairs can feel like climbing a mountain, making one reach for the banister and leaving one wobbly and out of breath at the top.

One may be able to do something for an hour, but then have to lie down for ten minutes to recover.  If this is you - better go see a doctor and keep going till you find one that actually listens to you.

Snake Oil and Blood Letting

Engineers have no issue with telling a client: I don't know, but I will find out and get back to you next week.

Some Doctors however, since the use of snake oil and blood letting in time immemorial, will never admit that they don't know.  Some will spin a feel good story, give an Aspirin and tell one to come back in 10 days.  The better doctors, will do blood tests.

When I hurt my back while working around the house and eventually went to a doctor,  complaining about a stiff back and terribly tired legs, he checked and said that my spine is OK, the muscles can be sorted with a massage session, but my tired legs require a battery of blood tests and when he looked at the blood tests, he referred me to a different doctor.

The second doctor went: "Hmm, I can see why you were sent to me" and immediately ordered a full body MRI scan.

Magnetic Resonance Imaging

I happened to work at Elbit in Israel on a military project, when they developed the first MRI machine.  Everyone in the company were absolutely astonished when the first pictures started to appear.  The anatomical detail was just mind blowing compared to the familiar fuzzy X-ray pictures.

An X-ray camera or CT Scanner can visualize soft and hard tissues.  A MRI Scanner though, is the closest thing to a mythical Star Trek Tricorder, since it can visualize the difference between healthy and diseased tissue.

Full body scanners are always located in the basement of a hospital building, since they are incredibly heavy.  The shielding provided by the surrounding earth also helps to get a good SNR (signal to noise ratio) which improves the picture quality.

When you visit a full body scanner, comfortable clothing is advised - athletic tracksuit pants and a T-shirt are good - you have to lie motionless in the machine for about 20 minutes.  Bring a sports bag to keep your documents and all your metal trinkets and metal zippered jackets that you got to take off.  A MRI machine is quite noisy, but for once in a lifetime, it is OK.

When the doctor got the MRI results, he double checked the identified problem area with a small sonar scanner (it is also astonishing how small and effective these hand held devices have become), mentioned that there is a small tumour which started maybe three years ago and which should be curable, then referred me to an oncologist.

Cyclotrons

When I was at university, I gave a hand (literally - with a steel file!) with the manufacture of huge magnets for a powerful 100 GeV four sector cyclotron.  It was envisaged for use for cancer treatment.  The machine was completed, but never much used, since it was overtaken by cyclotrons with superconducting magnets, which were smaller and cheaper to operate by a factor of hundred!

The old cyclotron was a beast, and was my first involvement with a working, but effectively failed project.  The sad life story of many an engineer!

Modern 10 GeV cyclotrons made by IBA in Belgium, are used to produce radio active isotopes such as Iodine 124 or 18 FDG, which previously required a nuclear reactor to produce. These isotopes are used in PET (Positron Emission Tomography) Scanners, which are used to look for cancerous tissue and heart problems.

The cyclotron which I worked on still exists, simply because the machine is big, heavy and radioactive hot, so there is no economical way to recycle it.  These older type machines are so inefficient that a hospital really cannot afford the huge amount of electricity needed to run them.  Overtaken by new developments, they got entombed in locked and disused hospital basements forever.   

Maybe in a few thousand years, archeologists will dig some old cyclotrons up and wonder what the religious significance of these strange multi-sector objects were and ponder their alignment with the stars. Hopefully they won't die from a mysterious disease soon after examining the machines.

PET Scanners

Whereas a MRI Scanner is perfectly safe, using only extremely high power magnets to excite your tissue, a Positron Emission Tomography (PET) Scanner is decidedly unsafe and should only be used by patients who already have a serious heart problem or cancer (After all, what are the odds of getting another cancer?).

A PET scanner needs to be close to a cyclotron - usually in an adjacent building - so staff can quickly walk across the road with a lead lined container with the required tracer isotopes, before it decays away to nothing.  

Getting to a PET scanner may require a bit of a walk, from the parking lot, up a hill to a basement scanner, since the equipment is best dug into a mountain side for safety and shielding and most lay people would not want to get too close to it, out of an abundance of caution, so you may need to pass though multiple lackadaisical security gates to reach the facility.

From the outside, a PET scanner doesn't look much different from any other kind of full-body scanner - a big and expensive doughnut, with a movable bed.  It is a positron sensor system that measures the concentration of radio-active tracer in your organs.  Areas with very high blood flow will show up hot and an experienced radiologist knows what should be glowing hot and what should not be.

Different types of cancerous tumours, brain and heart problems are best seen with different tracers.  Brain scans use radio-active Glucose and most other things use Iodine.  Therefore, patients are grouped in batches, so that the cyclotron can manufacture the required isotopes.  Therefore you will find yourself with an amazing crowd of people with similar problems.  Over the next few years, you will meet the same bunch of crocked up old fogies multiple times, so you can just as well introduce yourself!

Glowing In The Dark

A PET scan requires some preparation.  A nurse will put you in a cubicle and make you drink a litre of drilling fluid (Barium Sulphate) - it really tastes like drilling fluid too - and after a while you will get a drip with the Iodine or Glucose tracer.  The drilling fluid absorbs background radiation and improves the picture contrast.  After leaving the tracer to circulate for about 40 minutes, you will get the scan, which takes about 20 minutes.

Just for fun, you could build a Geiger Counter (https://mightyohm.com/blog/) to check the radiation levels around you.  These devices have been causing engineers and scientists to wonder about life, the universe and everything, for more than a century.

The MightyOhm Beta and Gamma ray detector is easy to build and works a treat - Click, click, clicketyclick - Uhm, maybe I should get ECC memory for all my computers...

Iodine 124 has a half life of about 4 days, so for the next week, you will be glowing in the dark (unfortunately not really - could have been fun!) and you should avoid pregnant women and children, out of an abundance of caution.  FluoroDeoxyGlucose (18 FDG), has a half life of about 2 hours, so you will be fine when you get home already.

The Bumpy Road to Recovery

Getting diagnosed correctly is half the problem.

Once you are an oncology patient, general practitioner doctors may not really want to see you anymore and will tell you to first get the cancer fixed, then you can come back for whatever still ails you.  Even a dentist may be very hesitant to treat you and may at most offer to fill an obvious cavity.  If you break a dental crown, the dentist may try to fix it with plastic and will try his best not to replace the crown.  Even a Thermal Spa or Massage is off limits to oncology patients.

There are various reasons for your newfound Persona Non-Grata Status.  The metabolism of an oncology patient is different from ordinary mortals.  There is a concern that the increased blood and lymph circulation caused by thermal waters and massage, can cause cancer to spread (Though this is not proven).  Due to a diminished immune system, you can however get sick more easily and should avoid crowds and other sick patients, while minor infections that used to heal in a few days, may now take weeks or months to cure with repeated doses of antibiotics.  So there is some method in the madness and whatever you do, don't get sick - you are already sick enough!

Treatments and Cures

Many people (about 97%) get cured of cancer and go into complete remission.  Others are treated periodically for decades, which is just as good.  It is the luck of the draw how it will progress.

Treatment of cancer takes many forms and can continue for months or years.  Hormone therapy is used to change your metabolism and slow the cancer growth down. Chemo Therapy is a treatment with special poisons to kill certain types of cells.  Internal radiation therapy (Brachytherapy) is used with certain hard tumours and involves implantation of tiny pellets of radioisotopes to damage the tumour from the inside. External radio therapy could be done with beams of photons (X-rays), or protons, to damage the tumour from the outside.  Immunotherapy can be used to assist your immune system to clear damaged cells.  It all depends on your particular problem and the available treatment facilities, since new potions and tools are invented all the time.

I got a series of 20 X-ray treatments to burn the little tumour, using a combination MRI and Linear Accelerator machine.  The MRI rotates around to make a 3D image used to position you exactly right, to the mm, on a 6 DOF gantry and then the LINAC rotates around to zap the tumour.  It is not painful, but not exactly something I would recommend for a leisure activity.  After 10 sessions, I could convince myself that I may be starting to feel better and by the 15th session I was sure of it.  However, radiation is a blunt weapon and you end up with damage from both the tumour and the radiation, so recovery will take a while.

You may need to remain close to your assigned oncology centre and your life may need to be arranged around your repeated scans and treatments for the next few years - you got to adapt and get used to your new reality!

Dosage

A LINAC is a magnetron powered tube, that accelerates electrons over a distance of about 50 cm and slam them into a heavy metal target, which releases X-rays, with an energy of about 20 to 25 MeV, which is then focused into a beam with a collimator.   Some LINACs are configurable to enable the use of the electron beam to treat skin tumours and the X-ray beam to treat internal tumours.

Just to put it into perspective.  If you consider a full chest X-ray as the worst thing ordinary people will get, then 20 radiation treatments with a Magnetron powered LINAC, is equivalent to about 2000 to 3000 full chest X-rays, focused onto a small spot!

Cancer Myths and Cures

There are a few cancer myths doing the rounds.  Here are some for your amusement.

The Italian Dr Simoncini, proposed that some cancer is caused by a fungus and tried to use baking soda to treat it.  It did not work, but it could possibly be beneficial to people who have a fungal infection and cancer at the same time though.

The Mayo Clinic studied the use of high dose Vitamin C to treat cancer.  It doesn't work, but it is beneficial to people who do not absorb vitamin C properly and have (sub-clinical) scurvy and cancer at the same time.  Vitamin C will make them feel a lot better within a few days, by curing the scurvy, but they will still have cancer.

The Human Papilloma Virus (HPV) has been proven to cause Cervical, Mouth and Throat Cancer.  There is now a vaccine against HPV, so there is at least one type of cancer which has a cure (prevention actually).   This indicates that some other cancers may also be caused by viruses and eventually there may be a series of anti-cancer vaccines.

So if you are looking for a miracle cure - there isn't one - but taking multivitamins is always a good idea.

La voila!

Herman

Thursday, December 8, 2022

Aye Eye Bed-Time Story Generator

Machine Learning is used for various hard practical problems, such as the safe control of autonomous cars that have to navigate a cluttered and dynamic environment, without bumping off cyclists and running over old people trying to cross a village road.  

There are also other more entertaining uses for it, such as the creation of bed-time stories for your grand children.  (Yup, I'm that old.  I started learning programming FORTRAN on a Univac with punch cards, eh.  Now get of my pennisetum clandestinum... :).

Go to OpenAI ChatGPT and make yourself a free account: https://chat.openai.com/auth/login

Let the fun begin: 

Write a short story for ten year olds. Scary government people created a video of a moon landing and will catch you if you deny it.

NASA Artemis Moon Shot

Give the protagonist two buddies with distinctly different personalities.

Result:

Once upon a time, there was a young boy named Jack who loved watching the stars at night. He dreamed of one day becoming an astronaut and exploring the moon.
One day, Jack's teacher showed the class a video of a moon landing. It showed a group of astronauts walking on the moon's surface and collecting rocks and samples.
But Jack had his doubts. He didn't believe that the moon landing was real. He tried to tell his classmates, but they all thought he was crazy.
Luckily, Jack had two friends who believed him. One was a shy and timid girl named Alice, who was always afraid to speak up. The other was a bold and brave boy named Max, who was always ready for adventure.
Together, they decided to investigate the moon landing and find out the truth. They went to the library and did some research, and they discovered that the video was actually a cleverly made fake and that the government had been lying to the public for years.
They also learned that many people who questioned the moon landing had disappeared without a trace. They knew they had to be careful, or the government might catch them too.
Jack, Alice, and Max came up with a plan to expose the truth to the world. They made their own video and posted it online, showing the evidence of the fake moon landing.
The government was furious, but they couldn't stop the truth from spreading. Soon, the whole world knew that the moon landing was a hoax.
Jack, Alice, and Max were heroes for standing up for the truth, even though it was scary. And they all lived happily ever after.


Given the distinct lack of effort required to specify the story line, the result is quite entertaining and if the rug rats are not sleeping yet, then you can generate another one in seconds!


La Voila!

Herman

Wednesday, October 12, 2022

Let There Be Light

I made a ceiling light fixture for my workshop (it is supposed to be my garage) from scrap wood.  Since LED lights do not get hot, one can do that without danger of burning the house down, but it would be a good idea to incorporate a 250 mA polyfuse in there for peace of mind.

 

The light of my life.

To hide the ceiling house wires and chocolate block connector, I made a big hole in one block with a hole saw and glued it to another block.  The vertical stick is mortised into the ceiling block - rubbed some wax on it all and there we have a little Tinkertoy Chandelier.  I used bees wax, but good old boot polish will work as well and it comes in multiple shades.

Cantilever Desk Lamp

BTW, the easy/lazy way to make a rectangular mortise hole, is with a drill and a jigsaw.   You just slowly grind the wood away with the saw blade till you have a perfect fit.  A hammer and chisel does not work well on soft wood, no matter how sharp the chisel, while a jigsaw will happily chew up anything!

I made two of the ceiling lights and one desk lamp.  The lamp fixture is invisibly fastened to the end of the stick with a little screw and epoxy glue.  The counterweight more or less balances it, which makes it easier to adjust and stay in place.

Now I had enough of sandpaper and lamps for a while - if I can just stop sneezing!

La voila!

Herman

Wednesday, May 11, 2022

Wooden Post Thumper

We planted a new tree and wanted to stabilize it with three posts, so it won't blow over in a storm, while it is still young.  It turned out that planting the tree was the easy part.  Hammering the 2.5 meter support posts into the ground, was a whole 'nuther problem.

One cannot use a sledge hammer on a tall post, since climbing onto a ladder and swinging a heavy weight around, two meters above ground, is sure to cause a rapid, unplanned descent from the ladder.

The safe solution is a pile driver - a heavy pipe that is closed at one end.

I could not find a pile driver at the local hardware store and in any case it would cost around 65 Euro, so I took some scrap wood and a two hundred year old sledge hammer and there we go.  The only expense was a handful of screws.  

The thumper works remarkably well.  It took longer to make the thumper than to set the three posts, but now I can also use it to drive in a sand point shallow well for the garden.


 

Start with a 15 cm piece of a square fence post - larger than the diameter of the stake that you want to drive in.  Build a box around it such that you have a channel of at least 50 cm below the block.  Strap a heavy weight above the block and there you are.  It doesn't have to be ridiculously heavy.

Obviously a steel thumper will last forever, while a wooden one will eventually wear out/split, but a wooden one like this, will last long enough for use by ordinary mortals.

Do sand the wood down to avoid getting splinters in your hands while using it.


Make a mark 50 to 75 cm from the tip of the post so you can see when to stop!

Put the top of the post into the thumper, then stick the point into the ground and raise it up.  Bonk the post in by raising and dropping the thumper 30 cm or so.  Wedge the post with your foot to help it go vertical.

Removing the thumper from the post can be tricky, since it is unbalanced with the big weight at the top, so it will likely drop onto the ground as soon as you clear the top of the post - try not to drop it on someone's foot! 

 

 

 

For driving a Sand Point Well Pipe into the ground, I built a tripod gantry with two pulleys, to make it easier to lift the thumper.  

 Here is a picture of the pipes about 2 meters into the ground:


 

 

 

 Only 5 meters more to go...

 

 

I'm sure the neighbours will be happy when I reach the end of my pipe.

 


Wheelies

Speaking of heavy stuff. I built some heavy gates and needed to drag them about 20 meters from the garage to the corner of the yard and my back was getting sore.


So, I re-invented The Wheel!

Two wheels close together, roll better over bumpy paving stones, than a single wheel.

It only has to work twice.


 


The above wooden wheels turned out real good, so I made a couple more, to clamp on and drag random heavy things around, such as my work table - which is an old recycled kitchen table with strengthening around the legs.

Now I can tip it over and then just need to balance it a bit, when I drag it off to the storage area.  I may cut another pair of wheels and screw them to the table permanently.

For something that won't get hundreds of miles of use, scrap wood wheels are great and cost nothing - OK, you need a screw and two washers also, but that won't break the piggy bank.

 

 

A little wooden wheel, cut with a 50 mm hole saw, can make a nice low friction Garden Gate Support:


The roller and block (with a rounded corner) lifts the door a few mm, so that the sliding bolt lines up perfectly, making the gate easy to open/close.  Don't glue the block - use two screws instead.  When the system needs adjustment, unscrew the block and reposition it.

 

La voila!

Herman

Sunday, May 8, 2022

Sawz

Simple Table Saw

To me, much of the fun of woodworking is making my own tools and jigs and then using them in a project.  Jigs made of wood do not last very long, since they either wear out, or warp (or both!), so making new jigs is a constant process.  The trick is to keep it simple, so that any worn or damaged guide piece can be replaced quickly with whatever is in your scrap wood bin.

Table Saw With Guide

When machining large pieces of wood, it is best to keep the wood still and move the machine, so a hand circular saw is a must have.  However, when working small pieces of wood, it is best to keep the machine still and move the wood, so a table saw is also a must have.  A table saw can however be rather expensive and a cheap, inaccurate, wobbly one, costs 3 times more than a hand tool.

Table Saw Saw Guide

Making your own table saw with an upside down hand saw is not difficult and it also has some advantages, notably that cutting through the table results in a zero clearance blade slot, which helps to reduce tear-out.  I set the blade to 90 degrees and leaves it that way.  I never cut at an angle with a circular saw, since it much increases the danger of a jam and kickback, which can hurt very badly.  I rather use a jigsaw for fancy cuts.

When selecting a circular saw, compare the different models on display and select the one with the sturdiest guide plate chassis.  The biggest problem with DIY tools is wobble.  Makita saws are very sturdy, while my other cheap American saw is rather wobbly, so I learned from the experience.

I made an Ikea scrap wood MDF box with a top and no bottom, to house the saw.  To adjust the blade height, I tip the box up to get to the lever and since there is no bottom, saw dust falls out and doesn't build up in the box.  However, it is a good idea to cut a hole in the side for a vacuum cleaner nozzle, to reduce the dust flying up into the air.

 

Upside Down Table Saw

When using the table saw, I clamp a piece of wood to the back of my work table, to keep the saw box from sliding off.   That works well enough.

Simple Saw Guides

The top overhangs the sides of the box by 5 cm, to enable the use of simple guide blocks and clamps.

The saw rip guide (Yankees call it a fence) slides along the front side, wraps around the table edge and clamps in place.  The guide ends at the middle of the blade.  At that point, the wood is cut, a longer guide doesn't help anymore and could cause the wood to jam between the guide and the blade and get flung back at high speed, which will hurt badly, so I keep the guide short.  American table saws have guides that go all the way to the back of the table - that is not a good idea.   

When you make the rip guide, glue the pieces, then clamp them to the blade and the front edge of the table.  By doing that, the guide is guaranteed to be perfectly parallel to the blade, even if the table edge is not. Once the glue set, you can add a couple of screws if needed.

Yootoob is full of fancy saw guide designs.  If you make a fancy guide, then when it breaks and/or warps, you need to spend a lot of time making a new one.  So I keep it simple, don't make fancy sliding slots in the table top and use a G clamp to secure my saw guides to the table edges.  A saw guide could be as simple as a piece of junk wood that was lying around, or a plastic rafter square.

To use a saw rip guide, clamp it lightly with a G clamp to the table edge and adjust it with a rubber mallet, then tighten the clamp.

I cut with the blade set much higher than the wood thickness.  This directs the cutting force mostly into the table and not at me, which reduces splintering and also reduces dangerous fly-back of wood pieces. It is a good idea to use a smaller size circular saw (a 5 to 7 inch blade is enough) with less power.  You will never be sorry if your puny little 5 inch table saw jams and stalls - while you will be very sorry for yourself if your saw goes Whump! and throws the wood piece back to you at 100 miles an hour.   

A ten inch table saw is a killer - A bigger table saw isn't better! 

Table Saw Cross Cut / Mitre Jig

A table saw cross cut sled is very useful.  I made one from scrap wood, that fits over the table saw box, guided by the edges.  

Table Saw Cross Cut Jig

When you glue up such a jig, put two layers of masking tape on the edges, to ensure that after you glued it, it will not stick to the table and there will be enough clearance to slide smoothly when you remove the tape.  Some wax will also help to make it move and keep it from warping as soon as you want to use it.

For miter cuts, I clamp a triangle to it.  For multiple cut offs, I use a G clamp with a stop block.

Hand Saw Cross Cut Sled 

Another jig I use a lot, is a cross cut sled for my hand saw.  The guide rails are left over oak edging.  Put some wax on them.

Cross Cut Sled

If I need a 45 degree cut, I simply clamp a plastic rafter square to the base.  Don't ever use a steel square as a cutting guide.  I would not like to accidentally cut into a steel square - the result of tungsten saw teeth binding into a steel tool won't be fun at all.  This sled has seen heavy use over the past year.

The Simplest Jigsaw Guide Ever

There are many videos on Yootoob showing how to turn a jigsaw with a long flexible blade into something resembling a band saw, by using a wooden overhead arm and ball bearings.  You don't need any of that.   

Simply buy Professional quality blades. It is the same type of blade you always buy, but with a P at the end of the part number.  Those blades are thick and stiff.  They don't flex and they cut straight!

Jig Saw with Dust Port and Professional Blade

Here is a picture of my little jigsaw, with a professional blade and a conical PVC rubber adaptor for the little 21 mm dust port to fit a vacuum cleaner hose.  You can get the conical widgets on Amazon in packs of 2 to 5.  Do yourself a favour and buy a bunch of them.

La voila

Herman.

Tuesday, January 11, 2022

Linux Security Cameras

Security Camera Management Programs

There are two decent Linux programs for managing security cameras: Motion and ZoneMinder.

For test purposes, I set a camera up inside my living room.  Once working, I'll install two outside, to watch the driveway and backyard.

 Streaming Camera with Fish Eye Lens

Motion is the simpler one of the two programs, but with almost 300 configurable options, it can do anything worth doing.  It works just as well as ZoneMinder, but it simply doesn't do things that are not needed.  For example, Motion supports a database, but Linux filesystem storage is usually good enough.  It doesn't have a fancy GUI, since it is intended to run on a server, stashed on a shelf in a dark corner.  There is a GUI which can be accessed with a web browser locally, or over the LAN, but I never used it.  One can also view real-time streams with a web browser.  Notifications can be sent and files uploaded to another machine with external programs such as mutt, wput and others.

While one can watch a TP Link security camera with a cell phone App,  I want to monitor what is going on when not at home, without spending money on a subscription service.  The simplest way to do this, is to use a free email account as an archive. Wherever I travel, I can log into gmail with a web browser and look at the stored security videos, to confirm that my house hasn't burned down and that there isn't an old Baba Yaga with a black cat and a white goat staying there.

In this guide, I describe how to configure Motion to handle a TP-Link C100 RTSP streaming camera and email a short video clip whenever motion is detected, using mutt with a gmail account.

Install Motion and Mutt

Mutt is a simple command line mail client which is fully supported and updated by Ubuntu Linux.  It provides the ability to send attachments using a free mail account from gmail, yahoo or similar service.  The parameter syntax of mutt is a little wonky - do yourself a favour and read the man page at least 3 times.

  • $ sudo su -
  • password
  • # apt install motion mutt ffmpeg 

Streaming Cameras

First of all, get the TP-Link camera to work.  You need to install an App on your cell phone to do that.   Using this App, create a user account with a password to use for the RTSP stream login.  With the App, you can also find the camera IP address - or look in your router DHCP list for it.

Use ffplay to verify that you can log in and play the camera streams:

  • $ ffplay rtsp://USERNAME:PASSWORD@IP.ADD.RE.SS/stream1

The above is the EXACT string that you need to use later in the camera configuration.

Security Considerations

For improved security, I configured mutt and motion to run under my user account on an Ubuntu Linux server.

Configure Mutt

  • $ cd
  • $ mkdir .mutt

Create a new gmail account for the security system, then go to the account security settings and set Support for Less Secure Apps ON.  Otherwise mutt will be blocked by Google. Simply send the attachments to this gmail address and leave it all there. Don't clog up your regular email account with security cam spam.  When Google eventually complains that the mailbox is full (you get 15GB for free), you can simply select all and delete it, then let it fill up again.

Create a file called mutrc.

Replace USERNAME, REAL NAME and PASSWORD with the exact details used when creating the gmail account. Put SINGLE QUOTES around the password to prevent the expansion of any $ signs in the password.

set from = "USERNAME@gmail.com"
set realname = "REAL NAME"
set imap_user = "
USERNAME@gmail.com"
set imap_pass = 'PASSWORD'
set smtp_url = "smtps://
USERNAME@smtp.gmail.com"
set smtp_pass = '
PASSWORD'
set folder = "imaps://imap.gmail.com/"
set spoolfile = "+INBOX"
set postponed="+[Gmail]/Drafts"
set trash = "+[Gmail]/Trash"

Configure Motion

  • $ cd 
  • $ mkdir .motion
  • $ cd .motion
  • $ cp /etc/motion/motion.conf .
  • $ cp /etc/motion/camera* .

Motion.conf

Make a file called motion.conf.  In the below example change USERNAME to suit.

# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.3.2
# Documentation:  /usr/share/doc/motion/motion_guide.html
#
# This file contains only the basic configuration options to get a
# system working.  There are many more options available.  Please
# consult the documentation for the complete list of all options.
#

############################################################
# System control configuration parameters
############################################################

# Start in daemon (background) mode and release terminal.
daemon off

# Start in Setup-Mode, daemon disabled.
setup_mode off

# File to store the process ID.
pid_file /home/USERNAME/.motion/pid

# File to write logs messages into.  If not defined stderr and syslog is used.
log_file /home/USERNAME/.motion/motion.log

# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL).
log_level 6

# Target directory for pictures, snapshots and movies
target_dir /home/USERNAME/Videos

# Video device (e.g. /dev/video0) to be used for capturing.
;videodevice /dev/video0

# Parameters to control video device.  See motion_guide.html
; vid_control_params value

# The full URL of the network camera stream.
; netcam_url value

# Name of mmal camera (e.g. vc.ril.camera for pi camera).
; mmalcam_name value

# Camera control parameters (see raspivid/raspistill tool documentation)
; mmalcam_control_params value

############################################################
# Image Processing configuration parameters
############################################################

# Image width in pixels.
width 1920

# Image height in pixels.
height 1080

# Maximum number of frames to be captured per second.
framerate 2

# Text to be overlayed in the lower left corner of images
text_left "CAM1"

# Text to be overlayed in the lower right corner of images.
text_right %Y-%m-%d\n%T-%q

############################################################
# Motion detection configuration parameters
############################################################

# Always save pictures and movies even if there was no motion.
emulate_motion off

# Threshold for number of changed pixels that triggers motion.
;threshold 1500 

threshold 10000

# Noise threshold for the motion detection.
noise_level 32

# Despeckle the image using (E/e)rode or (D/d)ilate or (l)abel.
despeckle_filter EedDl

# Number of images that must contain motion to trigger an event.
minimum_motion_frames 1
;minimum_motion_frames 5

# Gap in seconds of no motion detected that triggers the end of an event.
event_gap 10

# The number of pre-captured (buffered) pictures from before motion.
pre_capture 3

# Number of frames to capture after motion is no longer detected.
post_capture 0

############################################################
# Script execution configuration parameters
############################################################

# Command to be executed when an event starts.
; on_event_start value

# Command to be executed when an event ends.
; on_event_end value
 
# Command to be executed when a movie file is closed.
; on_movie_end value
on_movie_end "echo 'Security video'|mutt -i - -s 'Security Video' -a "/home/USERNAME/Videos/CAM1-%t-%v-%Y%m%d%H%M.mkv" -- USERNAME@gmail.com"

############################################################
# Picture output configuration parameters
############################################################

# Output pictures when motion is detected
picture_output off

# File name(without extension) for pictures relative to target directory
picture_filename %Y%m%d%H%M%S-%q
;picture_filename %Y%m%d%H%M-%q

############################################################
# Movie output configuration parameters
############################################################

# Create movies of motion events.
movie_output on

# Maximum length of movie in seconds.
movie_max_time 20

# The encoding quality of the movie. (0=use bitrate. 1=worst quality, 100=best)
movie_quality 45

# Container/Codec to used for the movie. See motion_guide.html
movie_codec mkv

# File name(without extension) for movies relative to target directory
movie_filename %t-%v-%Y%m%d%H%M%S
;movie_filename %t-%v-%Y%m%d%H%M

############################################################
# Webcontrol configuration parameters
############################################################

# Port number used for the webcontrol.
webcontrol_port 8080

# Restrict webcontrol connections to the localhost.
webcontrol_localhost on

# Type of configuration options to allow via the webcontrol.
webcontrol_parms 0

############################################################
# Live stream configuration parameters
############################################################

# The port number for the live stream.
stream_port 8081

# Restrict stream connections to the localhost.
stream_localhost on

##############################################################
# Camera config files - One for each camera.
##############################################################
camera /home/USERNAME/.motion/camera1.conf
; camera /usr/etc/motion/camera2.conf
; camera /usr/etc/motion/camera3.conf
; camera /usr/etc/motion/camera4.conf

##############################################################
# Directory to read '.conf' files for cameras.
##############################################################
; camera_dir /usr/etc/motion/conf.d

Camera1.conf

Make a file called camera1.conf.  Set the picture size according to your camera resolution.

Set the USERNAME and PASSWORD to the RTSP stream account that you created in the camera App.

# /usr/etc/motion/camera1.conf
#
# This config file was generated by motion 4.3.2

###########################################################
# Configuration options specific to camera 1
############################################################
# User defined name for the camera.
camera_name CAM1

# Numeric identifier for the camera.
camera_id 101

# The full URL of the network camera stream.
netcam_url rtsp://USERNAME:PASSWORD@10.10.10.78/stream1

# Image width in pixels.
;width 1280
width 1920

# Image height in pixels.
;height 720
height 1080

# Text to be overlayed in the lower left corner of images
text_left CAM1

# File name(without extension) for movies relative to target directory
;movie_filename CAM1_%t-%v-%Y%m%d%H%M%S
movie_filename CAM1-%t-%v-%Y%m%d%H%M 

Ditto for Camera 2.

Motion Configuration Tricks

Enable the Despeckle filter to reduce the amount of motion events. Set the maximum length of the movie clip to 20 seconds, to keep the file smallish and ensure that the email system will accept it.  

Remove the seconds parameter from the file names, since the system is already processing the next event when the current event is handled, which makes it impossible to attach the correct file down to the second.  Sometimes there will still be a problem when the minutes roll over, but most video files will get sent successfully.

Always specify the complete filename path.

Email Test

First test mutt interactively.  Run it from the console and play with it to ensure that you can send and receive email and that gmail is not blocking it.  

Motion Test

Run motion from the command line and play with it, to ensure that it works properly and will send emails with mutt.  If you get too many messages, increase the pixel change trigger level.

You need to find a happy medium where the system will not email a deluge of messages, since Google will block the account if you do. If you find that there is just too much movement in your situation, then you could also use the snapshot feature to email a picture once per hour or so and leave the movies on your home server.

Another option is to make the event gap much longer, so that it will detect motion, but not all motion.

You can view the real time video with a web browser on port 8081:

  • $ firefox http://localhost:8081/101 

Mailbox Cleanup

Deleting a few thousand messages manually using gmail with a webbrowser, would be extremely tedious.  When the mailbox gets full, it may be easier to delete the account and create a new one.

To clean the gmail box in one swell foop, you can try the following command with mutt:
  • mutt -e "push D~d>30d<enter>qy<enter>"
However - it may cause Google to disable your mail account for an hour, since this kind of mass mail delete with the IMAP protocol may look suspicious to their system.


La voila!

Herman