Tuesday, 28 April 2015

WSPR symbol generator

WSPR requires a set of 162 symbols 0-3, each representing one of four frequencies of transmission - see previous post. The encoding take place in four steps. Encode the call, encode the locator, this builds the first 81 bit word. This is then interleaved to generate a 162 bit output which is combined with the sync vector to produce the final output symbols 0-3.

Until now the way most people have generated the symbol table was to use a Windows program WSPR.exe. There seems to be no Mac version of this, and anyway I wanted to do it on the Arduino.

So here it is. To use it edit the sketch code to put in your person call, locator and TX power (in dBm - must end with 0, 3 or 7). In this example my call is M6KWH, my locator IO92 and my TX power 100mW or 20dBm. The call sign must be entered so that the third character is a number - so mine is "[SP]M6KWH". Upload the program, then open the IDE monitor window and hit RETURN, this will output the sync vector and symbols as below:

Screen Shot 2015 05 12 at 11 32 08

Cut and paste these into your WSPR transmit program (I am working on a WSPR TX program using my Universal_VFO design).

Code

// WSPR_symbol_generator input coded, output on monitor
// based on code from Martin Nawrath, Acedemy of Media Arts, Cologne

const char SyncVec[162] = {
  1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,1,0,
  1,1,0,0,1,1,0,1,0,0,0,1,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,0,
  0,0,1,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,1,1,0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,
  0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0,0,0
};

unsigned long n1;    // encoded callsign
unsigned long m1;    // encodes locator

byte c[11];                // encoded message
byte sym[170];             // symbol table 162
byte symt[170];            // symbol table temp

// put your data here
char call[] = " M6KWH";    // default values, 6 chars. 3rd numeric
char locator[] = "IO92";   // default value 4 chars
byte power = 20;           // default value 2 numberic

int ii,bb;

void setup()
{
  Serial.begin(9600);        // connect to the serial port
}

void loop()
{
  while(Serial.available() == 0);
  Serial.println("WSPR beacon");
  Serial.flush();
    
  encode_call();
  
  Serial.print("Call: ");
  Serial.print(call);
  Serial.print(" ");
//  Serial.print(n1,HEX);
  Serial.println(" ");

  encode_locator();
  
  Serial.print("Locator: ");
  Serial.print(locator);
  Serial.print(" ");
//  Serial.print(m1 << 2,HEX);
  Serial.println(" ");

//  for (bb=0;bb<=10;bb++)
//  {
//    Serial.print(c[bb],HEX);
//    Serial.print(",");
//  }
//  Serial.println("");
  
  encode_conv();

  Serial.println("");

  for (bb=0;bb<162 ;bb++)
  {
    Serial.print(symt[bb],DEC);
    Serial.print(",");
    if ( (bb+1) %32 == 0) Serial.println("");
  }
  Serial.println("");

  interleave_sync();

  for (bb=0;bb<162 ;bb++)
  {
    Serial.print(sym[bb],DEC);
    Serial.print(",");
    if ((bb+1) %32 == 0) Serial.println("");
  }
  Serial.println("");
  
  while(Serial.available() > 0) Serial.read();
}


// encode sequence
void encode() 
{
  encode_call();
  encode_locator();
  encode_conv();
  interleave_sync();
};

// normalize characters 0..9 A..Z Space in order 0..36
char chr_normf(char bc ) 
{
  char cc=36;
  
  if (bc >= '0' && bc <= '9') cc=bc-'0';
  if (bc >= 'A' && bc <= 'Z') cc=bc-'A'+10;
  if (bc == ' ' ) cc=36;

  return(cc);
}

// encode call sign
void encode_call()
{
  unsigned long t1;

  n1=chr_normf(call[0]);
  n1=n1*36+chr_normf(call[1]);
  n1=n1*10+chr_normf(call[2]);
  n1=n1*27+chr_normf(call[3])-10;
  n1=n1*27+chr_normf(call[4])-10;
  n1=n1*27+chr_normf(call[5])-10;

  // merge coded callsign into message array c[]
  t1=n1;
  c[0]= t1 >> 20;
  t1=n1;
  c[1]= t1 >> 12;
  t1=n1;
  c[2]= t1 >> 4;
  t1=n1;
  c[3]= t1 << 4;
}

// encode locator
void encode_locator()
{
  unsigned long t1;
  
  // coding of locator
  m1=179-10*(chr_normf(locator[0])-10)-chr_normf(locator[2]);
  m1=m1*180+10*(chr_normf(locator[1])-10)+chr_normf(locator[3]);
  m1=m1*128+power+64;

  // merge coded locator and power into message array c[]
  t1=m1;
  c[3]= c[3] + ( 0x0f & t1 >> 18);
  t1=m1;
  c[4]= t1 >> 10;
  t1=m1;
  c[5]= t1 >> 2;
  t1=m1;
  c[6]= t1 << 6;
}

void encode_conv()
{
  int bc=0;
  int cnt=0;
  int cc;
  unsigned long sh1=0;

  cc=c[0];

  for (int i=0; i < 81;i++) 
  {
    if (i % 8 == 0 ) 
    {
      cc=c[bc];
      bc++;
    }
    if (cc & 0x80) sh1=sh1 | 1;

    symt[cnt++]=parity(sh1 & 0xF2D05351);
    symt[cnt++]=parity(sh1 & 0xE4613C47);

    cc=cc << 1;
    sh1=sh1 << 1;
  }
}

// calculate parity
byte parity(unsigned long li)
{
  byte po = 0;
  while(li != 0)
  {
    po++;
    li&= (li-1);
  }
  return (po & 1);
}

// interleave reorder the 162 data bits and and merge table with the sync vector
void interleave_sync()
{
  int ii,ij,b2,bis,ip;
  ip=0;

  for (ii=0;ii<=255;ii++) 
  {
    bis=1;
    ij=0;
    
    for (b2=0;b2 < 8 ;b2++) 
    {
      if (ii & bis) ij= ij | (0x80 >> b2);
      bis=bis << 1;
    }
    
    if (ij < 162 ) 
    {
      sym[ij]= SyncVec[ij] +2*symt[ip];
      ip++;
    }
  }
}

Tuesday, 21 April 2015

More serious look at QRSS & WSPR

QRSS is a slow morse sending method, used at very low powers and narrow bandwidths. WSPR is a special signal coding carrying data, which is received and decoded by distant stations and give an idea of your propagation.

QRSS

To send QRSS you need a simple CW transmitter. For example the Universal VFO and the PA shields I have described for the Arduino UNO. The PA shield may be is a bit overkill and a lower output maybe should be used. An interesting design is a PA using a 74HC240 with out of phase signals fed to it from the VFO and the outputs connected to a balanced 1:4 transformer and LPF.

Screen Shot 2015 04 27 at 13 11 38

QRSS can be sent in basically three ways:

1 As simple CW, using dot = 3sec + 1 sec space, dash = 9sec + 1 sec space, word space = 2sec (1 space from each char + 2 extra = 3sec)

2 As frequency shift keying, with the same timing as #1 but on two frequencies, known as FSKCW. The frequencies are typically 2-5Hz apart, with the dot or dash being the higher frequency.

3 As two frequencies representing dot and dash, with a slightly longer gap for character spacing. The dot & dash are the same length. This is known as DFCW.

For example the letter 'C':

Screen Shot 2015 04 29 at 13 01 48

Different speeds have been adopted, but the most common is the one above called QRSS3, FSKCW3 or DFCW3. A transmitter must have better than 5Hz stability.

Reception is made by feeding the output of the RX audio (which can be from a simple direct conversion RX or an SDR RX) into your computer, and using an audio spectrum FFT display to show the frequency of the received audio.

Most HF QRSS activity is on 30m at 10140kHz.

Typical messages

Typical messages are very short, and replies are usually on a slightly different frequency to transmissions, for example:

CQ M6KWH K - M6KWH calling CQ

M6KWH ON7YD K - ON7YD replies

YD XDV 000 K - ON7YD call truncated, received, send report

XVD YD TU 73 K - received ON7YD back to you

YD XVD CL 73 SK - ON7YD received clear 73



WSPR

WSPR transmissions are a lot more complicated. As the message is encoded is a series of symbols/tones, each of which is transmitted on one of 4 frequencies (4FSK). For 30m the nominal "Dial freq" of the receiver is set to 10138.7kHZ USB. This transmits a WSPR message at 10140.2kHz, USB.

Screen Shot 2015 05 13 at 17 10 31

The symbols are transmitted as one of 4 tones like this

Screen Shot 2015 05 13 at 17 10 38

Where tones 0-3 are used for encoding the 4 tone FSK messages. The tone spacing is 1.46Hz (officially 1.465Hz but my DDS cannot resolve the last digit!). This uses a BW of just 6Hz and is transmitted at 1.4648baud, for the whole message the transmission time is 110.6sec. Transmissions are synchronised to start within 0-1 sec at 2 minute intervals based on UTC, that is for example at 00:00-00:01, 00:20-00:21 etc.

Messages

The WSPR message sent is a standard format which must be adhered to

Call Sign - Locator - power (in dBm, must end in 0, 3 or 7)

E.g. _M6KWH_IO92_37, where "_" is a space character - the third character MUST be numeric so there's a space at the front for my callsign

Their is a very good program called WSPR available on the web which runs under all OSs. This program both decodes and generates audio WSPR signals, including generating the symbol data from your information and outputting a modulated audio signal.

Screen Shot 2015 05 13 at 17 12 01

Your SDR radio tuned to dial 10138.7kHz USB will look like this

Screen Shot 2015 04 20 at 16 22 22

The WSPR program will display a narrow band of audio input from 100 - 300Hz around 1500Hz The display will look like this

Screen Shot 2015 04 20 at 16 22 59

It will read the signals being sent in the correct time slots (your PC clock must be accurate!) and decode them like this

Screen Shot 2015 04 20 at 16 23 07

the interesting parts which show the time (UTC), the frequency received, the call sign, locator and the power.

By uploading these received signals to a data base at WSPRnet you can plot them on a Google map and see either where you are receiving them from, or how far your signal is reaching.

Setup

There are two ways to set up a WSPR transmitter.

1 Use a program WSPR.exe to encode your symbols. Or use my Arduino based program described above, which tunes your transmitter with a sketch to shift the frequency of the DDS by the correct tone frequency.

2 Use an SDR TX shield and modulate your transmission with the audio output of the PC based WSPR program audio signals.

I will be investigating both or these methods and the transmission of QRSS in the future.

Tuesday, 10 February 2015

EAGLE - Making the PCB

Errata!!! In the previous post I had the connection VCC & GND going to the WRONG pins on the LM741. Here I have corrected this to pins 7 and 4.

So let's take the simple design of the previous post, complete it and make the PCB.

Here's the completed design:

Screen Shot 2015 02 10 at 16 42 28
I have added component values

- Edit > Value, to the resistors R1 & R2

I have named the signals IN, OUT, VCC, VCC2 & GND on the connector and on the circuit, so that Eagle will automatically connect them.

- Edit > Name

Now to create the PCB.

File > Switch to Board, and create it "Yes".

The square representing the board starts off large, reduced it to the size you want using

- Edit > Move, and dragging in the top and right sides to make a board about a inch square

- Tool > Move is used again to place the components on the board. Like this

Screen Shot 2015 02 10 at 17 04 41

The components have been moved around and rotated to simplify the layout (a matter of trial and error to get the best layout). The wiring is shown as thin black lines called Airwires.

Run the Auto-Router

- File > Autoroute. This is the result

Screen Shot 2015 02 10 at 17 05 35

As you can see there are only red lines. The red ones are on the top of the PCB (blue ones would be on the bottom). You can see all the layers of the PCB design using

- View > Layer Settings, which will open up a window showing all the layers. Various parts of the drawing are located on different layers. Partly defined by the Device characteristics and part by the routing, The most important are the 1Red (Top) and 16Blue (Bottom) layers.

The design as it is Auto-routed is over-complex and can be simplified if only we could get the GND wire from JP1 (centre pin) to the Pin 4 of IC1 without going all round the houses.

A cunning way to do this, and to save removing tons of copper from the PCB, is to create a ground plane. Draw a polygon round the circuit

- Draw > Polygon

Screen Shot 2015 02 10 at 17 10 34

Then name it as GND

- Edit > Name, and click on the dotted line

- Edit > Ripup the existing connection from JP1 to IC1 pin 4, as this will now be made with the ground plane (by the way all traces can be ripped up to start again by entering the command "RIPUP;" in the top command line.)

Screen Shot 2015 02 10 at 17 15 21

Now re-run the Auto-router and you will get this

Screen Shot 2015 02 10 at 17 32 57

As you can see the ground connection is now made with the ground plane which connects to JP1 centre pin and pin 4 of IC1

Layers

Within the Eagle PCB layout items are maintained on "Layers" as follows

Screen Shot 2015 02 12 at 16 40 46

You can view layers separately by turing them off/on using View > Layer Settings.

Checks

You can check two aspects of your design

1 Electrical rules in the schematic, Tools > ERC, which will report Errors and Warnings

Screen Shot 2015 02 10 at 17 18 06

2 Design rule check on the board, Tools > DRC. This will check that the layout meets the design rules, like the spacing of wires etc.

Screen Shot 2015 02 10 at 17 19 17

We have no errors so no report is made.

Design Rules

Suppliers, like Eurocircuits, provide their own Design Rules to ensure that you design will meet their fabrication specs. You can download these from their site and place them in Eagle's /drc folder. Then from the control panel chose Design Rules and load the Eurocircuit one you want to use.

EAGLE - Progressing with a PCB design

After the last post I will now continue with actual PCB design. Starting with drawing the circuit schematic.

A Project

A Project is a folder that will contain all your files - schematic drawings, board layouts etc

- At the Control Panel, right click on Projects and chose "New", name the project.

Screen Shot 2015 02 10 at 12 13 48

Then repeat and chose "Edit Description" and give your project a description.

Screen Shot 2015 02 10 at 12 14 08

Schematic

With your Project highlighted,

- File > New > Schematic.

- Click on the "Grid" icon top left and switch it On.

Screen Shot 2015 02 10 at 12 42 01

Now you can add the Devices to your schematic.

- Edit > Add, will open a window showing all your available Libraries of devices.

Screen Shot 2015 02 10 at 12 15 14

Find the one you want and click "OK"

Screen Shot 2015 02 10 at 12 15 30

- Add this to your schematic, position it and click. You can repeat the additions if you need more of the same Device, to exit hit ESC.

Add the other components you need, I used the "rcl" library for the resistors (To rotate a component hit CTRL-R)

Screen Shot 2015 02 10 at 12 17 03

Now wire up the schematic

- Draw > Net (do not use Draw > Wire as this only draws lines, not connections!). Click on the points you want to wire up.

Screen Shot 2015 02 10 at 12 18 19

Wires on your schematic can be given Names, and Eagle will connect all those with the same name, for example "GND" or "VCC", "IN" or "OUT"

- Edit > Name, select the wire and enter a Name.

Text can be added to the schematic to record the wire names

- Edit > Text, enter the name and add to the schematic, ESC to do another name, ESC ESC to exit

Screen Shot 2015 02 10 at 12 20 55

You will want to give your components values.

- Edit > Values, click on each component and enter its value (e.g. 4k7)

That's it. Next time I will complete the design and turn this schematic into a board layout.

Sunday, 8 February 2015

EAGLE - PCB design software

Eagle is not the easiest software to understand. But I have invested a number of hours to get to grips with it. This is what I have found. (This tutorial was written using the "Lite" version of the software from the Cadsoft web site £60).

This blogpost will cover the starting point for creating Devices to use in your designs if you can't find them in an existing library. A future post will cover drawing a schematic and generating the PCB layout. You could also check out this or this site.

Screen Shot 2015 02 10 at 11 10 23

Eagle

Eagle handles these levels, in descending order:

- PCB Design

- Devices or components

- Packages used on PCB layouts

- Symbols use on schematic drawings

- Gates, which are fundamental building blocks of devices (e.g. the individual op-amps in a quad op-amp device)

Libraries and the Device Editor

There are a myriad of libraries of devices from many suppliers, and your software comes with a lot of them, plus many others are made by users for devices they need. There are some web sites, for example this one, to help find if a device exists in a library somewhere.

I would recommend that you chose the libraries you need for your projects, then move all the other unwanted ones to a "oldlibs" folder. This make design a lot easier.

Often you may want to create new devices that you can't find. So here's how to do it using the Device Editor.

Definitions

Device - a combination of a symbol and a package. So that a symbol used on a schematic diagram can be directly translated to a physical device for the PCB layout.

Package - which is the outline and connection types and positions (e.g. SMD or thru hole)

Symbol - the device schematic graphic, and pins to which connections can be made

Gate - parts of a symbol if they are repeated in one device.

When Eagle is started this is the window that appears, called the Control Panel.

Screen Shot 2015 02 08 at 12 45 28

There are two important items on the left, Libraries and Projects. under the Library list are all the libraries that you have installed in your /lbr folder, under /Eagle. Under the Projects list are the designs you have made or are working on.

Screen Shot 2015 02 08 at 12 48 08

Screen Shot 2015 02 08 at 12 48 21

Libraries and new devices

If you can't find the component you need in existing libraries , you will have to design a Device. First create a new library for your components.

- Control Panel, File > New > Library

- Library > Description, enter a description of your library

- File > Save As...

With the Library open you will have this window

Screen Shot 2015 02 08 at 12 53 16I

At the top are three important icons, Device, Package and Symbol.

Screen Shot 2015 02 08 at 12 54 37

Making a new device

Start at the level of Gate, creating one of the internal parts of your device.

Symbol

- Chose Symbol icon, then File > New... and name it

Screen Shot 2015 02 08 at 13 08 09

In the editor window draw the device and the pins.

- Make an outline of the internal gate, Draw > Wire

- Add pins, Draw > Pins

- Name the pins, View > Info, like the component data sheet

- Set pin direction, Edit > Info > Direction and the pin visibility, Edit > Info Visible (note: chose "pin" to have only the pin name showing on the symbol/schematic)

- Add text, Draw > Text... ">NAME" and ">VALUE", and put these on the 95Names layer, Edit > Info... Layer 95Names

That completes the gate creation. File > Save.

Package

- Chose the package icon, then File > New... to name it

Screen Shot 2015 02 08 at 13 08 17

- Set the grid "on" at a suitable resolution for the physical package design, see data sheet

- Draw the pads, Draw > Pads (either SMD and set size) or Pins (thru hole and set shape) and position them correctly

- Draw the outline, Draw > Wire, then Edit > Info to change the lines to the 21Place layer.

Device

Chose the Device icon, then File > New.. and name it

Screen Shot 2015 02 08 at 13 08 30

- Add the gate(s) to the left hand pane, Edit > Add

- Rename the gates "A","B", etc Edit > Name

- Set the gate levels to "next", Edit > Info

Add a power supply connection if this is not one of the pins, this will provide a hidden connection to VCC & GND.

- Edit > Add "PWRN", right click PWRN symbol and set Add Level to "request" (Note: it will then not appear on the schematic, but the signals will connect)

- Add the package in the top right pane, New button... chose package

- "Connect" and chose correct pins and pads to be connected

- Set a naming Prefix, e.g "IC", "T", etc (Note: devices on the schematic will be names IC1, IC2 etc)

File > Save All

Additional help

It maybe that someone else has already drawn the package and a similar symbol to the device you are creating. You can use their Package and symbol drawing in your Device like this:

- Control Panel, open libraries. Right click on the library containing the Device with the Package and/or Symbol you want to copy.

- Open the Package or Symbol

- Edit > Group and drag a box round all of the Package or Symbol

Screen Shot 2015 02 10 at 10 47 55

This will high-light the selection:

Screen Shot 2015 02 10 at 10 48 08

- Edit > Copy

- Now open your Library, chose your Device. Open its Package and or Symbol and Edit > Paste

That's it.

Friday, 6 February 2015

New proposed version of the Radiono TXRX

The Radiono TXRX is a fascinating design, using a bi-directional FET output mixer for RX & TX, driven by a couple of amplifiers one in each direction.

Here's a proposal using MMICs for the two amplifiers. It also has AGC on the audio side to give more "punch".

The input BPF is based on the WA4DSY design aid

Screen Shot 2015 02 07 at 17 45 11

and has a response like this:

Screen Shot 2015 02 07 at 17 45 23

Screen Shot 2015 02 20 at 18 14 00

Saturday, 31 January 2015

SDR TXRX Block Diagram

As things are slowly getting sorted out, here is the block diagram of the four board SDR TXRX controlled by an Arduino Uno that I have in mind. The boards are useful individually for home constructor projects.

The Universal VFO interfaces with the LCD display and the Rotary Encoder/Button for tuning and band change. It outputs either VFO, VFO and BFO signals for CW transmit or superhet receivers, or /4 frequency I & Q quadrature signals for SDR use. The function depends on the Arduino software program.

The 403020 SDR is a complete SDR receiver with its own input BPF.

The Universal TX is an SDR based wide band transmitter (with around 100mW output). This can be used to generate SSB/AM/CW over a wide range of frequencies. If used stand alone it needs an external LPF.

The 403020 PA includes the LPFs for the three bands 40, 30 & 20m. It also provides the TX/RX switching of the antenna input from the ATU.

Screen Shot 2015 03 22 at 10 05 59

My ideas are coming together, and I must say that they are just ideas today, nothing has yet been made. Other shields considered are a GPS and an Auto ATU. Still its good to go on thinking and studying how to achieve the result. We are considering to make this a club kit project at the Banbury Amateur Radio Society.

By the way, a simple CW TXRX could be made by omitting the Universal TX and driving the PA directly from the Universal VFO. I am including a physical switching link for this on the PA board.

Note

The RF BUS of the system has been increased to 8 pins, giving

- 4 outputs VFO, BFO, I & Q from the Universal VFO

- 2 for RX ground and input

- 2 for TX ground and output

The Arduino UNO connections planned are:

Screen Shot 2015 03 22 at 10 21 55

Where you can see the RFbus signals, and the use of the Ardubi signals D0-D13 and A4, A5 (I2C bus). D2, 4 are used as Interrupt inputs from the tuning rotary encoder, D5 is the band change button, D6, 7 are inputs from a GPS board planned to calibrate the VFO and give timing for WSPR use. D9 is the key or PTT, D10, 11 and for band switching and D12, 13 are for enabling TX or RX.