Category Archives: Uncategorized

Wideband transformers I (magnetic core theory)

I write a series of articles about transmission-line transformers with the intention to eventually build a UnUn and current choke for a whip antenna.

The first article will present the theory of magnetic core used in transmission-line transformers, the second article will present transmission-line transformer types together with their characteristics while the third article will present practical calculation of the UnUn and current choke using easy to find materials.

Transmission-line transformers theory:

A transmission-line transformer aims at adapting from a transmission line with one impedance to a transmission line with another impedance.

Generally there are two types of materials that are largely used for constructing transmission-line transformers:

-ferrite (MnZn composition, NiZn composition)

– iron-powder (electrolytic powder-iron, carbonyl powder-iron)

Each of the materials presented above have different proprieties that will recommend it for a specific type of application. I will present the differences when this is necessary. Magnetic materials have couple of parameters among which some of interest are:

\mu – permitivity

A_l – inductance factor

f_r – resonance frequency

T_{co} – temperature coeficient

T_{max} – maximum temperature

B_{sat} – saturation induction (flux density)

A_e – effective area

Permeability, magnetic field, magnetic induction:

Magnetic field

The ampere law says:

H=\frac{ni}{l} where

n – number of turns

i – current [A]

l – current path[m]

Magnetic induction (flux density)

B=\mu H where:

H – magnetic field [A/m]

\mu – permeability [Henry/m]

B – induction (flux density) [Tesla, Gauss]

The dependency B=B(H) is usually plotted like in the following image:

B_r – remanent induction (induction in the material at zero magnetic field).

H_c – coercitive magnetic field (magnetic field at zero induction.

B_s saturation induction (maximum induction in the material).

Inductance

L=\frac{\mu n^2 A_e}{l} where

A_e – area of a turn

Ferrite producers offer the inductance coefficient A_L which could be used to calculate inductance L:

L=n^2 A_L where A_l is in H/sp^2

From this formula one could calculate the number of turns given the inductance L and A_L:

n=\sqrt\frac{L}{A_L}

One important note regarding the A_L is that it is normally calculated at low frequency but since it is dependent of permeability \mu we should not expect it to be constant at all frequencies. I will discuss dependency of \mu versus frequency in more details later in this post.

Calculation of maximum inductance in the core

From Faraday law of EMF:

e=n\frac{d\phi}{dt}=nA_e\frac{dB}{dt} therefore integrating on both sides for half period:

B_{max}=\frac{E_{med}}{4nA_ef }

We see that this depends on the frequency, number of turns, effective area of core.

We can derive the formula for couple of signal types:

Sinusoidal signal:

B_{max}=\frac{E_{RMS}10^8}{2\pi\sqrt{2}nA_ef}=\frac{E_{RMS}10^8}{4.44nA_ef}

Square signal with D duty cycle:

B_{max}=\frac{DE_{pk}10^8}{nA_ef} therefore for 50% duty cycle:

B_{max}=\frac{E_{pk}10^8}{nA_ef}

Pulse signal with T_{on} and frequency f:

B_{max}=B_r+\frac{T_{on}E_{pk}10^8}{nA_ef} where

B_r – remanent induction in Gauss

A_e – effective area in cm^2

f – frequency in Hz

B_{max} – induction in Gauss

If the signal has a DC component then another component is added to B_{max}:

B_{max}=B_{AC}+B_{DC} with B_{AC} from the above formula and

B_{DC}=\frac{Li}{nA_e}

Some ferrite vendors offer a plot or a table of maximum inductance versus frequency. In order to verify that core is suitable for the application, one should calculate B_{max} at minimum frequency and compare with the value in the table offered by the vendor.  If B_{max} is larger than the value in the table then a core with a larger A_e should be chosen or the number of turns should be increased.

Permeability at higher frequencies

A_l is offered normally at lower frequency and is supposed to not be dependent of the frequency. However, at higher frequencies the \mu is frequency dependent and has a complex form like this:

\mu=\mu'-j\mu''

therefore we  could calculate the impedance:

Z_L=j\omega L=\frac{\omega n^2A_e\mu''\mu_0}{l}+j\frac{\omega n^2\mu'\mu_0A_e}{l}=r_f+jX_L where

r_f=\frac{\omega n^2A_e\mu''\mu_0}{l} is called inductor loss

X_L=\frac{\omega n^2\mu'\mu_0A_e}{l} is the core reactance

Here we will define:

tg\delta=\frac{\mu''}{\mu'} – tangent of loss angle

Q=\frac{X_L}{r_f}=\frac{\mu'}{\mu''}=\frac{1}{tg\delta} – quality factor of the core

We could now define the impedance taking in consideration the complex permeability:

Z_c=\sqrt{r_f^2+X_L^2}=\omega n^2 \mu_0\frac{A_e}{l}\sqrt{\mu'^2+\mu''^2}=\omega n^2 \mu_0\frac{A_e}{l}\mu_c

where \mu_c=\sqrt{\mu'^2+\mu''^2}            (1)

Some ferrite vendors offer graphics for \mu' and \mu'' versus frequency. From these tables one could calculate \mu_c and Z_c.

Inductance at higher frequencies

We could now derive the inductance and impedance of a core using the complex permeability and see how this could be calculated using the information that is usually provided by the core vendors. We will try to obtain another factor that is not dependent of frequency.

L=\frac{\mu n^2 A_e}{l}=\mu_0\mu_c \frac{n^2 A_e}{l}=\mu_c n^2 F where F=\mu_0\frac{A_e}{l} is a form factor not frequency dependent.

F=\frac{A_L}{\mu_i} – F could be calculated from A_L and initial permeability \mu_i (usually offered by yhe vendor) or

F=\mu_0\frac{A_e}{l} – directly from the dimensions of the core.

Now we could calculate magnitude of complex impedance of the winding:

X_L=\omega n^2 \mu' F r_f=\omega n^2 \mu'' F Z_c=|r_f+jX_L|=\omega n^2 \mu_c F

Power loss in ferrite

Thermal resistance:

Increase in temperature can be calculated as follows \Delta T=P*R_{th} where R_{th} is thermal resistance of the core.

R_{th}=\frac{1}{a\sqrt{volume}} with an scaling factor. Therefore we could calculate maximum power dissipation if we know scalling factor ‘a’:

P_{max}=\Delta T*a*\sqrt{V}. In this formula V is the volume of the core.

Some ferrite and iron powder vendors offer a formula to calculate temperature raise from max power dissipation and input power . We’ll use that in the last article when practically calculating a UnUn transformer.

Power dissipation:

We determined maximum dissipated power for a specific raise in temperature. Now we can calculate the maximum allowed voltage to produce the maximum power dissipation.

P_{max}=\frac{U_L^2}{Z_c^2} r_f=\frac{U_L^2 r_f}{r_f^2+X_L^2}=\frac{U_L^2}{(Q+1/Q)X_L} therefore:

U_{Ldisippation}=\sqrt{P_{max}(Q+1/Q)X_L}

We have now two constrains for the maximum allowed voltage, one from maximum dissipated power and the other from maximum allowed induction:

U_{Linduction}=4.44B_{max}nA_ef

Which one to choose between U_{Ldissipation} and U_{Linduction}? The smallest one in order to be on the safe side.

Radio Amateur and Asterisk (chan_alsaradio.c part 3)

Practical details:

There are some things you need to tweak in order to make app_rpt and alsaradio working as a repeater and Echolink node.

Hardware:

I’m using FT-857D to build the repeater. The connection between PC and radio station is signaling and audio. For signaling I’m using the DATA connector on the back which is a mini DIN 6 pin:


The PTT is activated low and needs very low current to be activated. I measured about 140uA needed current for activating PTT.

The SQL signal (which sometimes is called CORCarrier Operated Relay or COSCarrier Operated Squelch) is activated high but it can only drive small current (uA) and therefore a transistor needs to be used to drive the serial line. That is why one will need an additional power supply if driving optocoupler is needed in an isolated interface (I’ll present it later on).

You could see that the DATA connector has DATA IN, DATA OUT 1200 and DATA OUT 9600 pins which could be used to input/output audio when no digital modes are used. However, DATA OUT pins do not output squelched audio. Hence I used only DATA IN for audio input and oudio output has been taken from oudio output jack in the back of the rig.

Audio adjustments:

A good level meter for ALSA is ameter. It is an ALSA plugin that will get the PCM level to from sound card and display it in a graphical environment. Download, build and install it as per given instructions.  The following is an screenshot of ameter GUI:

To adjust input level just use arecord with the following command:

arecord -D ameter -c 2 -f S16_LE test.waw

It will record the input level while showing ameter levels. You should adjust input level either from your card controls or from your rig’s volume level to see a 3/4 from your maximum ameter level.

To adjust output level you need to set your rig to display modulation level. Then adjust your card output level so that the modulation level is what your rig’s manual says (On FT-857 you should see couple of bars at maximum).

Testing the system:

If you start asterisk and signaling and media path are connected then you should be able to do the following from another radio station with a DTMF pad:

– activate parrot mode (simplex repeater functionality): *94 – now all you speak is sent back to you

– deactivate parrot mode: *95

– get system time: *81

– get version of the system: *82

– *3 – conects to an internet node (needs parrot mode disabled)

– *1 – disconnects from an internet node

All of the above DTMF sequences are configured in the rpt.conf and you coud add more, see app_rpt documentation.

Connecting to Echolink:

The Echolink numbers are prefixed with digit 3 and padded with 0 until 7 digits.

– *33009999 – this will conect to *ECHOTEST* node

– *13009999 – will disconnect from *ECHOTEST* node

Connecting to Allstarlink:

The Allstarlink numbers are starting by default with digit 2 and there is no need to prefix anything:

– *31234 conencts to Allstarlink number 1234

– *11234 disconnects from the Allstarlink number 1234

Connecting to IRLP:

The IRLP node numbers are prefixed with digit 4 and no padding.

– *349500 – connects to IRLP node 9500

– *149500 – disconnects from IRLP node 9500

Testing from Asterisk’s CLI:

DTMF commands could also be sent from the asterisk’s console. Start asterisk CLI with “asterisk -r” and then you should be able to do the same, for example:

rpt fun *94 – activate parrot mode

rpt fun *95 – deactivate parrot mode

Other commands useful for testing from CLI:

database show – shows database with Echolink nodes

aradio key – keys the transmitter

aradio unkey – unkeys the transmitter

aradio rkey – simulates COR present

aradio runkey – seize COR present

Sourcecode released as Open Source under GNU GPL license:

example of alsaradio.conf: alsaradio.conf.tar.gz

example of rpt.conf: rpt.conf.tar.gz

chan alsaradio (v01): chan_alsaradio.c_01.tar.gz

chan alsaradio (v02): chan_alsaradio.c_02.tar.gz

To correctly build the chan_alsaradio driver, the following line needs to be added in channels/Makefile:

chan_alsaradio.so: LIBS+=-lasound

Radio amateur and Asterisk (chan_alsaradio.c part 2)

In the previous article I explained just few bits about Asterisk and app_rpt and how I came to the conclusion to build another channel driver for app_rpt.

The idea behind is that I wanted to make a channel driver that uses a general purpose sound card for media path and serial port for signaling. If the card has a driver for Linux then ALSA (Advanced Linux Sound Architecture) will provide an abstraction of it so that the channel driver will not depend on the specific sound card type.

On the signaling side, the serial port is used to send PTT signal and receive COR (or COS) and CTCSS from an external decoder (if needed only). The simplest serial interface to the radio station is presented bellow:

It does not use the right levels for RS232 interface but it will work with the serial ports of modern computers as long as the PTT and COR are not stressed with high data rate (this is unlikely anyway). I will provide later on an interface that will make use of optocouplers for isolation of signals and audio transformers for isolation of media path.

Audio signals (media path) are connected form the audio output of the rig to soundcard input and from soundcard output to rig microphone input.

The new channel driver is called alsaradio and corresponding module is named chan_alsaradio.so. Like all the other channel drivers it has a configuration file in which one could give various options. Here is a typical alsaradio.conf file which should be placed where all asterisk config files are: /etc/asterisk/

alsaradio.conf

[ard0]

input_device=plughw:0,0

output_device=plughw:0,0

serial_device=/dev/ttyS0

[general]

carrierfrom=serialdsr

You should use appropriate values for your input_device and output_device parameters according to configuration of your sound card.

Here is a relevant portion from rpt.conf that uses the alsaradio channel driver:

rpt.conf

[xxxxxx – here is your node number]

rxchannel=alsaradio/ard0

Here is a echolink.conf that will make app_rpt communicate with Echolink servers:

echolink.conf

[el0]

confmode=no

call=YO3IIU

pwd=your Echolink password

name=your name

qth=your qth

email=your e-mail

maxstns=20

rtcptimeout=10

node=your node number

context=radio-secure

server1=server1.echolink.org

server2=server2.echolink.org

server3=server3.echolink.org

If you’ve proper configured the app_rpt, alsaradio and echolink and connected the radio to the PC then you should be able to key in and dial using DTMF a number from another radio tuned to the frequency of your main radio. Alsaradio is able to decode the DTMF and send them to app_rpt. For example if you want to connect to *ECHOTEST* (node number 9999) you should dial:

*33009999

I will explain later about how various nod numbers could be dialed using DTMF commands.

irlp.conf

node =stn5667  #the IRLP node number you will obtain during installation

call=yo3iiu

rtcptimeout=10

localispeakerport=2174

radmod=no

audioport=2074

context=radio-secure

astnode=27235 #your Allstarlink node number

Dialing an IRLP number like 9500:

*349500

if you obtained an Allstarlink node number too, you would be able to dial for example number 27235 with the following command:

*327235

Radio Amateur and Asterisk (chan_alsaradio.c part 1)

Couple of months ago I’ve been looking for open source software that a radio amateur could use. I came across app_rpt that is an application for Asterisk with many many interesting features. What is Asterisk then? Asterisk is an open source telephony software that knows many telecom protocols, SIP, MEGACO, IAX (Asterisk own VoIP protocol) just to name a few.

In Asterisk one can distinguish applications and channels although from programmer point of view there is no difference, both being shared libraries.

Channels are the ones used to get or to send calls to/from Asterisk although Asterisk does not distinguish between FXO (Foreign eXchange office) and FXS (Foreign eXchange Station). Applications could do whatever they want with data gotten from the channels it connected to.

Looking at the features Asterisk provides one could imagine at least couple of use cases for Asterisk and its usage in ham radio. Basically the Asterisk could be seen as a PBX able to communicate with other exchanges via various physical links and protocols while locally it can be connected to a radio station.

Now speaking about app_rpt application, it is initiated by Jim Dixon WB6NIL and its intention is to supply a full software repeater package with all modern repeater and remote base functionality included. It’s home with full details and options is here:

http://app-rpt.qrvc.com/

How app_rpt works: the communication with radio station is through a channel driver that uses specific hardware:

– Quad PCI adapter

or

–  CM108 chip USB soundcard with some GPIO pins for signalling like PTT, COR, CTCSS decoding.

App_rpt does not provide only standalone repeater controller functionality but also is able to be integrated into networks like Echolink and IRLP through corresponding channel drivers (chan_echolink.so and chan_irlp.so)

My situation is that I do not own any of the hardware that app_rpt is able to work with nor able to buy them easily. Therefore I decided to implement a simpler interface for my radio station based on ALSA and use serial port for signalling.

Simple RLC meter (Fourier transform part 3)

As an application of the FFT algorithms I present here a simple RLC meter that is able to measure resistors, inductors, capacitors with a reasonable precision. It uses a simple circuit in which a known frequency is sent to a R+Z circuit (where Z could be R, L, C) and then the current and voltage on the Z are measured. The current is indirectly measured by actually measuring the voltage on R.

A PC sound card is used to output the test signal on line-out and also to do acquisition of the measurement signals through line-in.

Two frequencies are used, a low one and a high one for cases where Z is too low or to high.

A calibration is performed with DUT (Device Under Test) unplugged. It will measure the impedance of the circuit and use it subsequently to adjust the DUT measurement.

The time domain signals acquired from the sound card are transformed into frequency domain using FFT and so they become complex signals. Then you could do calculus using DC current methods.

Impedance calculation:

u_L[N] – time domain channel left

u_R[N] – time domain channel right

U_L[N] – frequency domain channel left

U_R[N] – frequency domain channel right

Z = R\frac{U_L}{U_R - U_L}

During calibration the program stores Z_{calib} and then on the DUT measurement it will calculate correct impedance with:

Z_{DUT} = \frac{Z_{mes}Z_{calib}}{Z_{calib} - Z_{mes}}

Note on frequency domain:

FFT will use a number of N points for its calculation which corresponds to maximum frequency of the signal, N/2 corresponds to Nyquist frequency. Therefore if the signal has frequency f you could calculate which point corresponds to this frequency:

k = f \frac{N}{r}, where r is the sampling rate.

Going from complex to real:

\mid Z \mid = \sqrt{Re(Z(k))^2 + Im(Z(k))^2} and

tg(\phi) = \frac{Im(Z(k))}{Re(Z(k))}

Now you could determine whether the DUT is R, L, C based on tg(\phi).

The program runs on Linux with ALSA, alsa-utils, fftw installed.

Source code is distributed under GNU GPL public license and can be downloaded from RLC meter source code.

Fourier transform and signal processing (part 2)

As I told last time, I’m going to present a small project I’ve done to exercise sound card use on Linux,  sound processing with Fourier transform, Discrete Fourier Transform(DFT) and Fast Fourier Transform (FFT). All of these are used to make a practical LRC-meter able to measure inductors, resistors, capacitors.

The math behind:

It is not the idea of this article to present the full math theory behind Fourier transform but only to present the application of the theory. Good books that present theory in detail are on the market, e.g. “Discrete-time signal processing” by Oppenheim and Schafer.

Suppose we have a discrete signal represented as x[n] for -\infty < n  < \infty

The Fourier representation of the x[n] is a function of the form:

X(e^{j\omega})=\sum_{n=-\infty}^{n=\infty}x[n]e^{-j\omega n}

The above formula is an analysis formula.

The inverse Fourier transform (which is an synthesis formula) is like this:

x[n] = \frac{1}{2\pi}X(e^{j\omega})e^{j\omega n}d\omega

A Fourier transform translates the signal from time domain to frequency domain in which it represents the signal as a superposition of sine waves each having a coeficient given by the Fourier transform.

Now to make a long story short, a LTI (Linear  Time Invariant) system could be analised by using the Fourier transform. The relationship between the Fourier transform of a signal and the characteristics of the system could be explained as follows:

For LTI system: y[n] = \sum_{k=-\infty}^{\infty}h[n-k]x[k] where h[k] is the impulse response of the system to unit step.

If we choose x[n] = e^{j\omega n} then y[n] = e^{j\omega n}(\sum_{k=-\infty}^{\infty}h[k]e^{-j\omega k})

If we define: H(e^{j\omega}) = \sum_{k=-\infty}^{\infty}h[k]e^{-j\omega k}

then we have y[n] = H(e^{j\omega})e^{j\omega n}

H(e^{j\omega}) – frequency response of the system

Comparing the latest formula with the Fourier transform formula we could see that:

X(e^{j\omega}) = H(e^{j\omega}) meaning that the frequency response of a LTI system is the Fourier transform of impulse response.

The above equality is very important to practical needs just because if you have the frequency response of a LTI system then you could calculate the response to unit step by using the inverse Fourier transform:

h[n] = \frac{1}{2\pi}\int_{-\pi}^{\pi}X(e^{j\omega})e^{j\omega n}d\omega

Discrete Fourier Transform (DCT):

The Fourier transform formula of a discrete signal gives a continue function. Depending on the signal, the sum could be calculated easily or not because of the infinite number of harmonics taken into consideration.

If we consider the signal is periodic with period N so that x[n] = x[n + rN] then we could take into consideration a finite number of samples for X(e^{j\omega})

The Fourier representation in this case is a superposition of complex exponentials with frequencies that are multiple of fundamental frequency \frac{2\pi}{N}.

Therefore DFT will use two formulas:

Analysis equation: X[k] = \sum_{n=0}^{N-1}x[n]W_N^{kn}

Synthesis equation: x[n] = \frac{1}{N}\sum_{k=0}^{N-1}X[k]W_N^{-kn}

whre W_N = e^{-j(2\pi/N)}

Therefore, one could calculate direct/inverse DFT series easily by using a finite length N vector of x[n] respective X[k].

Fast Fourier Transform (FFT):

To calculate DFT with equations above you’ll have complexity O(N^2). It is called FFT, the algorithms that strives to calculate DFT efficiently other than doing the sums above. There are couple such algorithms variations that goes to a complexity of O(Nlog(N)).

Fourier transform and signal processing (part 1)

As a radioamateur I am interested in SDR which stands for Software Defined Radio. While SDR as a term seems to be pretty self explanatory, my interest is to make a radio with as less hardware as possible and in the same time provide most of the radio functions in software. This will allow an easily customization of the supported waveforms, demodulation types, etc while also providing a low cost solution that can be improved step by step to beat the existing classic solutions.

Since discussing about SDR and even making progress in this domain is quite a challenge, some knowledge about signal processing needs to be gathered in order to be able to pursue such a great domain. Therefore I thought making small projects having clear goals and objectives will lead step by step to define a good architecture of my SDR.

SDR uses a lot of computational effort to modulate/demodulate radio signal in the digital domain and for that reason an ADC/DAC is the first hardware one should have for that job. There are many constraints about the perfect suitable ADC/DAC but I will be discussing it later in a chapter devoted to SDR types. However, what I want to bring into discussion is the sound card available in every PC nowadays, a piece of hardware that has ADC and DACs ready to be used at moderate sample rate.

Therefore, the first accommodation project would be one to understand how to access the sound card to record/play audio samples and control the various available configuration parameters.

Since I’m a big fan of Linux, open source and especially Linux kernel, all the work I’ve done is on Linux OS. This will allow a great level of customization for my projects and also will speed-up development by using various tools ready available and provided by the OSS community.

What could be a starting project involving sound processing and audio card as ADC/DAC? Remember it should be something usable and with clear goals. So it is a RLC meter.