Friday, July 28, 2017

Olde Skool Antenna Design with NEC2 on OpenBSD

The Numerical Electromagnetics Code (NEC) is a powerful and efficient program for the analysis of the electromagnetic properties of antennas and other objects. It is a Method of Moments type of successive approximation program and dates back to the time of the dinosaurs. 

In theory, 
practise and theory are the same, 
but in practice not.
To measure, is to know!

NEC was developed on a CDC 7700 in the mid 1970s to early 80s at Lawrence Livermore by Burke and Poggio for the US Navy and it was paid for by the friendly US tax payers - free for use by anyone now.


Dipole Antenna Example

CDC - Control Data Corporation, became Computing Devices Canada, which became General Dynamics Canada - I worked there through all the name changes - but you don't need to go hunt in a museum for a CDC 7700 to run NEC - an Intel PC will do.   The NEC documentation amusingly still refers to stacks of punch cards, but these have been replaced with simple text files.  I learned programming with punch cards on a Sperry-Univac, so the batch processing way that NEC works is not strange to me, but it does bring back some scary memories of the good old, bad old days of iron age, hollow state computing...

NEC was considered a large program, requiring a powerful mainframe to execute.  However, what used to require a big room full of computing equipment, can now be done on a laptop computer.  Just to prove the point, I installed NEC on my Lenovo S10e netbook running OpenBSD.

The original FORTRAN code is still available, but it has been rewritten a few times into C and C++, to improve the efficiency and ability to handle very large numbers of wire elements. The new versions can handle tens of thousands of elements and can be used to model a whole aircraft for example, but then you would need something with a wee bit more RAM than my netbook.

You can also use NEC to calculate scattering from an incident plane wave to determine the Radar Cross Section of an aircraft, as described here: https://www.aeronetworks.ca/2017/09/scattering-rcs-calculation-with-nec2.html.

Here is another similar method of moments approach for the calculation of scattering (RCS) of very large objects (Ships).  However, this program is not maintained at the moment and needs to be installed on a specific version of Ubuntu Linux: http://www.aeronetworks.ca/2015/04/rcs-calculations-puma-em-on-ubuntu-linux.html

As usual with high tech things, there is absolutely no correlation between price and quality.  You can spend $100,000 on an antenna design program from ANSYS or others, or you can use NEC2 or Puma EM - for Free - or buy a LLNL NEC4 license for $300 to $1500 https://ipo.llnl.gov/technologies/nec.

The difference is that the $100,000 package comes with training and support, whereas with NEC, you have to figure it out yourself - but figuring it out yourself over a few days, is rather less than $100,000 me thinks and even with the commercial support and training session, you still need to sit for a few days to figure it out anyway.  If you have big money burning your pocket, then spending it on RF test equipment may be a better idea.

Getting Started With NEC2 Antenna Modelling

The place to start is here: http://www.nec2.org/

Download the manuals, and read them:

The first manual describes how NEC works and the third manual describes how to use NEC to model an antenna.  There are many examples, from dipoles to Yagis and helixes - it is all there.  To get started, you could find a suitable example and tweak it to suit your purpose.

Download the NEC example files from the American Radio Relay League:

Download an antenna handbook or two and clue up on antennas, so that you can tell when your simulations are going wrong:

If you are broke, get this one - the author passed away before he could complete it and his legacy is a free antenna book: 

NEC on OpenBSD

If you are a very recent convert and don't have an OpenBSD laptop computer yet: http://www.aeronetworks.ca/2017/02/openbsd-on-netbook.html

Assuming that you have a machine which is minimally working, first set up the OpenBSD ports system.  Look for a file named ports.tar.gz on the mirrors.

$ cd /tmp
$ ftp https://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/{ports.tar.gz,SHA256.sig}
$ signify -Cp /etc/signify/openbsd-$(uname -r | cut -c 1,3)-base.pub -x SHA256.sig ports.tar.gz

Untar this file in the /usr directory, to create /usr/ports and all the directories under it.

# su -
password
# cd /usr
# tar xzf /tmp/ports.tar.gz

Look for nec2 based antenna design software:
# cd /usr/ports
# make search key="nec2"
  Port:   xnecview-1.36p0
  Port:   necpp-1.2.3p3

Build necpp:
# cd cad/necpp
# make install
... looong wait ...
# make clean

Build xnecview:
# cd cad/xnecview/
# make install
... looong wait ...
# make clean

OK, so which programs do we have now?
$ ls /usr/local/bin/*nec*
  nec2++              nec2diff            xnecview

Apparently we have nec2++ for antenna design and xnecview to plot the results.  A text editor and some RTFMing is all that is needed to create the input files.  Mousepad or even vi will do.

Helical Antenna Model

Let's look at a helical antenna model.  There is one in the other.zip file from ARRL.  The NEC manual has two parts, part 1 describes the program and part 3 describes how to use it, with exhaustive examples.  A volunteer is needed to write part 2!   A helical antenna card stack is described on page 20 of part 3 of the manual.

Helix - CocoaNEC

A helical antenna definition is extremely simple, since it is only one wire.  Nevertheless, you need to refer to page 20 of the third manual to know what exactly the Geometry Helix (GH) line means:

$ cat HELIX.NEC
CE  HELIX TEST
GH 1,60, .05,.5,.1,.1,.1,.1,.00001
GE
EN

RTFM:
$ man nec2++
$ man xnecview

Let's put the card stack in the hopper and run it to see what happens.  Watch out for the continuous paper spewing out of the high speed line printer...

$ nec2++ -iHELIX.NEC -ohelix.out

Let's view it:
$ xnecview HELIX.NEC helix.out

To make the original example useful, one has to add definitions for the EX signal source and RP antenna pattern cards.

With EX 0 1 1 0 1 and RP 0 1 360 360 1000 0 0 1 1,  I eventually got something to plot, but it didn't look pretty and an attempt to calculate an admittance matrix caused the netbook to run out of RAM and the program was terminated.

Eventually, I got the NEC syntax sorted and the plots made sense once I used a very large number of elements (500 or more).  As the elements are straight sections, if you specify too few, then the simulation of the spiral becomes complete nonsense.

CM Helix, 900 MHz, 15 loops, 1.15 meter
CM Herman Oosthuysen, July 2017
CM Wave length = 2.998x10^8 / 900MHz = 0.333 m
CM Use Kraus formula:
CM Radius = 116.2 / 2 = 58.1 mm
CM Loops = 15
CM Spacing = .23 = 76.6 mm
CM Length = 1150 mm
CM GH 1,200,.0766,1.150,.0581,.0581,.0581,.0581,.0066
CM EX element 1 has voltage source of 1V
CM EX 0,1,1,0,1,0,0,0,0,0,0
CM FR Freq response 800 to 1000 MHz, 5 points
CM FR 0,5,0,0,800,50
CM RP 72 points x 5 = 360 degrees
CM RP XNDA = 0 (max pwr gain) works best
CM RP 0,1,72,72,0,0,0,5,5,0,0
CM The simulation needs a very large number of elements, 500 or more
CE
GH 1,500,.0766,1.150,.0581,.0581,.0581,.0581,.0066
GE
EX 0,1,1,0,1,0,0,0,0,0,0
FR 0,5,0,0,800,50,,,,,
RP 0,1,72,72,0,0,0,5,5,0,0
EN


Helix 900 MHz

The little netbook can calculate up to about 5 frequencies in a sweep.  For more accurate rendering, a better computer is required!

Equations from Kraus:
G= 10.8 + 10*log10( (C/lambda)2*N*(S/lambda) ) (Note1)
Z= 150/sqrt(C/lambda) Ohm
D= lambda /PI
S= C/4
HPBW= 52/( (C/lambda)*sqrt(N*(S/lambda)) ), Half power beamwidth.
BWFN= 115/( (C/lambda)*sqrt(N*(S/lambda)) ), Beamwidth first nulls.
Ae= D*lambda2/(4*PI)
Where C is circumference, which is about one wavelength for axial mode.

What exactly the gain of this antenna will be, is not clear - somewhere between 7 and 15 dBi - but the simulation at least shows that it radiates in axial mode.

Log Periodic Antenna Model

Just for fun, I tried a few more example files and a log periodic design plotted beautifully.

Logperiodic Example Plots

Therefore the design software is shown to be working fine and now the real work can start, to make a new antenna from scratch.  This becomes complicated when you add all the parasitic things: Stubs, ground plane, loading...

Vertical Dipole Model

Here is something simple that I created with xnec2c on Fedora Linux.  The picture is at the top of the page.

CM VERTICAL HALF WAVELENGTH ANTENNA,
CM 900 MHz, WL = 0.333 m, 1/4 WL = 0.083 m
CM Limitations of xnec2c visualization program RP card:
CM Cannot plot a 360 degree sweep with ground plane (need to remove GN cards)
CM The XNDA field must be 0
CE
GW     1     9  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  8.30000E-02  1.00000E-03
GE
FR     0     0     11     0  8.00000E+02  2.00000E+01  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00
EX     0     0     5      0  1.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00
RP     0    72    72      0  0.00000E+00  0.00000E+00  5.00000E+00  5.00000E+00  0.00000E+00  0.00000E+00
EN

 

Why?

A helical antenna is the general case of a wire antenna.  If you squash it up, it becomes a loop and if your stretch it out, it becomes a long wire.

Helical antennas can radiate in two modes (and everything in between...) Normal, or Axial.  Normal mode occurs when the helix circumference is smaller than 1/2 wavelength (0.2 nominal) and Axial mode occurs when it is larger than 0.8 wavelength (1 nominal). (See John D. Kraus, The Helical Antenna, Proceedings of the IRE, 1949).

As you can see in this graph from Kraus, there is almost no right or wrong way to make a helical antenna, provided that you stay close to the two D lambda curves.  To increase the gain, use more wire and reduce the spacing.  To make it more wide band, make the loops bigger.  To match the impedance to your radio, you can either add a tuner, or bend the first loop a little bit!

Axial mode is good for a ground antenna pointing at a small aircraft just like a Yagi-Uda, but the circular polarization will ensure minimal changes in signal strength when the aircraft banks in turns.

Normal mode is good when a retired radio amateur tries to fit a 160 meter HF dipole antenna into the attic of a small cottage.  If one uses two curly cords then a dipole becomes much smaller - any size you want it to be really, so it is a guaranteed fit, whether in your roof or outside in the yard.  Wrap the dipole wire around a plastic drain pipe, stretch it out as much as you can and stick a tuner on it to match it to your radio for whatever frequency you want to work at - as easy as borscht.

Axial mode concerns me at the moment and the normal mode will eventually!

While playing with example designs from the web in order to get going with the modelling programs, I noticed that many published designs and 'antenna calculators' are quite dreadful.  I even found some Yagis that radiate more backwards than forwards, so you really should model an antenna before you build it.

Heretics

Heretic geeks can buy EZNec for Windows and Linux cowboys can do dnf install nec2c xnec2c, or apt install nec2c xnec2c.  For Mac users, there is CocoaNEC.  All these programs work the same, since the underlying engine is the same, but they do have different bugs.

For example, xnec2c has trouble with the radiation pattern plot when there is a ground plane (remove the GN card) and the RP XNDA field must be 0.  Despite this, xnec2c seems to make better plots than xnecview as it handles edge cases better (where things go to zero).  CocoaNEC creates the best graphics by far, but it also struggles with a helical antenna (it won't display the helix structure, but it can display the radiation pattern) and CocoaNEC always inserts its own RP card - which ensures that it always works.

Note that when NEC crashes due to a divide by zero, then moving a ground plane or other element by a fraction of a millimeter can make the problem go away!

Different RP Card Handling:
  • xnec2++:     RP 0,1,72,72,1000,0,0,5,5,0,0
  • xnec2c:        RP 0,72,72,0,0,0,5,5,0,0,0
  • CocoaNEC: RP 0,91,120,1000,0,0,2,3,5000
So, you just have to pick one and play with it a bit till you figured it out - they all work - eventually.

However, the fancy GUIs only implement a small subset of what NEC can do.  Therefore, to do anything special, you need to stick your nose into the manual and edit the source card stack file with a text editor, the old fashioned way.  This is not easy and fancy GUIs cannot make it so.

A Two Port Vector Network Analyzer

The proof of the pudding is in the eating.   At the end of the day, after you stopped playing with NEC2, you need to actually build the antenna and measure it.  Test equipment can be very expensive to a hobbyist, but you can get a 2 port VNA second hand at a reasonable price, or buy a new one from China.

The aliexpress web site lists many different VNA models from $300 to $3000, which is orders of magnitude less than a couple decades ago.  I got a Measall KC901V, and I am very happy with it and can now characterize antennas up to the C-band quickly and easily.
 

La voila!

Herman



Monday, July 3, 2017

Cube Satellites

For a few years, it has been possible to launch tiny educational satellites - for free - to fill up some of the unused payload space on big rockets.  http://www.asc-csa.gc.ca/eng/satellites/cubesat/default.asp


This opportunity has been used by many universities and radio amateur groups: http://www.asc-csa.gc.ca/eng/sciences/canadian-cubesat-project.asp

A few months ago, the American University in Sharjah also launched a cubesat called NAYIF-1: http://www.arrl.org/news/nayif-1-cubesat-to-have-funcube-transponder

It has been passing overhead many times and I was a bit miffed that I did not know about it before the launch, had no idea how to connect to it and to my knowledge, the radio amateur law in the UAE did not allow foreigners to operate.  The NAYIF-1 satellite is a CubeSat-5, which is a little different from the CubeSat-1.

 
Here is the AmSat data warehouse for the NAYIF-1 (EO-88), which shows all the pertinent information on the satellite in real-time:
http://data.amsat-uk.org/nayif1/index.html


NAYIF-1 (EO-88)

The radio beacon uses V/UHF Upper Sideband:
145.940 MHz 1200 bps BPSK FUNcube beacon.

500 mW inverting SSB/CW linear transponder:
435.045-435.015 MHz Uplink
145.960-145.990 MHz Downlink

The final straw was when I learned that Russia and Slovakia launched three cubesats in the same week:  


It turns out that in preparation for all this, the UAE radio amateur law was changed last year https://www.tra.gov.ae/assets/Le2rh2VP.pdf.aspx, a radio amateur society (EARS) was founded in Sharjah and expats are welcome: http://ears.ae/en/

NAYIF-1 Cubesat

The NAYIF-1 has a Funcube transponder, which has a beacon and a bent pipe.  Anyone can listen to the beacon (using the FunCube Dashboard Windows only software and matching SDR widget), but to send something through the transponder would require a ham license: http://wp.rac.ca/uae-satellite-will-have-amateur-radio-transponder/

Cubesat Ground Station

The Funcube project is based in the UK: https://funcube.org.uk/

Educational material is posted here: https://funcube.org.uk/education-outreach/

To connect to the NAYIF-1 (or other) satellite, you need to know when it is passing: http://data.amsat-uk.org/nayif1/index 

To see all the cubesats currently flying, try this: https://in-the-sky.org/satmap_worldmap.php?day=4&month=7&year=2017&hour=10&min=50&show=sl&show=st  There are hundreds.  Which ones are actually working is another matter though.

To send data through a cubesat transponder, you would need a V/UHF radio, which could be an off the shelf SSB ham radio, or a Software Defined Radio specially built for this purpose: http://www.funcubedongle.com/

In practice, you need to know exactly when the satellite will pass overhead and then you have one or two minutes (depending on the height of the orbit) to bounce a message through the transponder before it disappears over the other horizon and then you may not see it again for several hours.

Ham Equipment

A new Yaesu/Kenwood/Icom/Xiegu/Alinco transceiver will cost around $800 to $8000, but you could buy a radio kit for $200 and assemble it yourself and end up with a similar high quality transceiver.

For example:
http://qrznow.com/kenwood-tm-v71a-full-dual-bander-144430mhz/

or:
http://www.kenwood.com/usa/com/amateur/ts-2000_b2000_2000x/ 

If you design the whole toy from scratch like I usually do, then it may take years to complete, it will likely end up costing $500 or more and the quality will be much inferior, but it will be a whole lot more fun to do and you could then say: This is a total piece of junk, it barely works, but I built it myself!

You could follow a somewhat easier path and build a ham radio kit, some of which are amazing quality and will look exactly the same as a factory built unit, but you could buy a second hand rig on Ebay for much less.

Absolutely amazing high quality factory built or DIY radio kits:

The best value kit which was refreshed recently in 2016, is BITX40, a 25 Watt, SSB, digitally controlled transceiver, built and tested PCB for only $60:
Due to the present low sun spot cycle, the 40 meter (7 MHz) HF band is best for long distance work and the BITX40 is ideal for that.  With the BITX40, you can chat to someone on the other side of the globe on SSB if you have a proper antenna (With a 15 meter flag pole and a tuner you can look very patriotic too!).

Very simple fun kits (which perform much worse and could cost more than the above!):

There are also crazy kits for ancient vacuum tube sets (for old fogeys like me), or little transceivers using only 7 parts that barely work, or radios built entirely from 2N2222 NPN bipolar transistors just because...:

Of course, someone then went and did the same with a radio built entirely from small signal PNP transistors!

A simple little radio can be much fun to chat to people around your city, but they are usually unstable and the transmit frequency will drift.  A good radio will lock on and follow a bad radio, so you can have fun provided that whoever you try to talk to has a good quality rig.  It will also help a lot if you run your fun radio off a battery and let it warm up and settle down for 15 minutes before you transmit.

A 7 Ah motorcycle battery is stable and has no noise and will make your toy work much, much better than a noisy unregulated wall wart and then you may be able to rag with someone hundreds of kilometers away on less power than a child's night light.

Ham Software

The best ham resources are probably the DXzone and ARRL web sites.

Here is a laundry list of Linux ham software and what they are good for:
http://www.dxzone.com/catalog/Software/Linux/

and this is for Macintosh:
http://www.dxzone.com/catalog/Software/Macintosh/

All the radioham utilities are available on Fedora, Ubuntu, Slackware, OpenBSD, Mac...  but you can also try Knoppix or Shackbox if you want to run off a USB stick without actually installing Linux on a machine.


Morse Code???

Everybody associates ham radio with Continuous Wave Morse code and if you listen to the HF bands, then you will hear a lot of it.  CW with Morse was the first digital telegraph modem about 200 years ago.  However, nobody learns to send Morse any more.  I was in the Corps of Signals in 1982 and didn't learn Morse - it was already long obsolete.

However, if you want two data link radios to connect to each other, then they have to use the same modem waveform on both sides of the link and Morse is the 'lowest common denominator', which can even work with a friendly doddering OM (old man) or XYL (ex young lady) clutching a pencil on the other side...

There are a multitude of modem programs that run on common garden variety computers that send data via the sound adaptors.  The most common ham modem modes are RTTY, PSK31 and CW Morse - there are many, many others, but it doesn't help if you are the only one trying to use it, since it will make you feel very lonely.

The best modem program at the moment, which works on Windows, Linux, BSD and Mac, is FLDigi: https://sourceforge.net/projects/fldigi/

However, as with most software things, you need at least a half decent computer and any half decent computer works better with Linux or BSD than with Windows. The Windows scheduler is not good for real-time operation and therefore cannot do encoding and decoding very reliably since it stutters too much.  This is why you will see many disparate reviews of the same amateur radio software, with one bloke saying it works great and the next bloke saying it doesn't.  If you don't want any hassle, use a Macintosh (which runs a kind of BSD).

FLDigi and Satscape are the most fun you can have with your geek hat on...

Best of all, you don't even need a radio to try it.  You can install FLDigi and play through your sound system to hear first hand what it does, or even let two computers side by side, talk to each other over the air, never mind the ether!

NAYIF-1 CubeSat Beacon and Transponder Summary

The information on the NAYIF-1 CubeSat is scattered all over the place. Here is a summary of what I could figure out.

The AmSat web site for this satellite shows real-time information from the radio beacon:
http://data.amsat-uk.org/nayif1/radio.html

According to that, it is working fine.

The radio beacon uses V/UHF Upper Sideband:
145.940 MHz 1200 bps BPSK FUNcube beacon.

The beacon can be received with the Windows only FunCube Dashboard software and matching SDR dongle.

It should be possible to get something with a RTL-SDR widget and FLDigi set to BPSK, but first I would like to see a power spectrum density graph, since I have no idea how the beacon data is encoded. It sends packets with error detection and correction, but I haven't found any useful details yet.

The transponder is a linear 'bent pipe', so one can send anything through it with a suitable 5 Watt transceiver, a right handed helical antenna and a modem program.

500 mW inverting SSB/CW linear transponder:
435.045-435.015 MHz Uplink
145.960-145.990 MHz Downlink

So to send/receive through it, one needs something like a HackRF1 SDR radio with fldigi and a 9 dBi RH helical antenna. This should be a generic AmSat setup that should work with any other amateur satellite transponders.

The orbital ephemeris data is available on the http://www.heavens-above.com web site under the name EO-88.



--. .-. --- ..- -. -.. / -.-. --- -. - .-. --- .-.. / - --- / -- .- .--- --- .-. / - --- -- / -.-. --- -- -- . -. -.-. .. -. --. / -.-. --- ..- -. - -.. --- .-- -. --..-- / . -. --. .. -. . ... / --- -.

Have fun with the Funcubes!

Herman