Raspberry Pig ("Raspberry Pi hf-rig")

Picture: Pig uses internals of "tv-dongle" for receiving and transmitting.
PIG.png
Summary: Concept is to use tv-receiver dongle for both receiving AND for filtering dirty tx-signal from Raspberry Pi to
be acceptable for real use.
Preliminary tests seems to suggest that it is possible to use tuner chip of dongle for filtering tx-signal.
Pig is currently on early stage.

Aim is to create minimal (at hardware side) hf-transceiver with Raspberry Pi and cheap tv-dongle (well known "RTL-SDR").
I will be using Thumbnet dongle for this project. (It seems to be out of store, other quite similar products are avail
able at cheap price.)

Receiver


Receiver side should be relatively easy, it is work allready done by much more clever programmers. I have shortly tested Rtl-fm with pi and it simply works, and receives also ssb. I have not much experience of how good (bad) receiver tv-dongle is on hf. On receiver side, PIG-software is mostly GUI-frontend for command line programs like Rtl_fm.

PIG-software uses a slightly modified versions of librtlsdr, rtl_power and rtl_fm.Like librtlsdr have to mod to allow tuner run while direct conversion mode, to check tx-signal.Here 100 Mhz from Pi is fed to dongle and down-converted to 8 Mhz signal. Result looks fine here.Tx-signal quality depends very much of dongle settings, gain, filters etc....Good news is, Pig can be used to confirm its own tx-signal, by "listening" IF from tuner.

Pig_rtl_power_try.png

Transmitter



Main trouble is of course transmitter. And trouble-lovers we are.

Now how to use Pi's well known capability to produce some very rough (squarewawe) rf-transmission throw pin 4, general purpose clock.
Experiments have been made to produce FM and SSB-modulated transmissions with Pi, also it seems AM-modulation should be possible. But first I want to consider transmission chain without modulation, to produce decent transmission, like simple carrier wave. This is hardware side of transmitter, modulation is made at software so let it wait.
We can filter square wave to quite clean rf-transmission. But it is troubled way if frequency is altered. And at hf-rig it is very much altered so filtersection of rig would be something else than minimal hardware.

BUT if we think about tv-dongle, it consist two main parts: tuner chip and receiver which is in our perspective A/D-converter. On well-known direct sampling mod tuner chip of dongle is bypassed and signal to be received is feed directly to A/D-converter.
Tuner chip is basicly downconverter and consist also automatic front filter and IF-fiter. And it have no use when direct sampling mod is used...dear sirs and ladies, this sounds awful but I think I will feed transmissions from Pig first to tv-dongle.

Let me think. We produce transmission on Pi. We want it to be finally on, say 10 Mhz. But first we produce transmission on 100 Mhz frequency, at awful square wave. We will feed this 100 Mhz to tunerchip (yes, I really mean to antenna connector on dongle). Now we put tunerchip to downconvert it to 10 Mhz and take our transmission out from the point (pin) where signal normally would go to A/D-chip. Because:

1. Original harmonics (mostly odd frequencies) are now at high frequencies compared to 10 Mhz transmission. I think the strongest harmonic will be at 300 Mhz. And IF-filter at tunerchip is about 10 Mhz wide. How can you filter 300 Mhz harmonic away from 10 Mhz signal? Easily!
2. Also front filter (tracking filter) will be tuned to 100 Mhz. It will cut high harmonics effectively.
3.We use tunerchip to alter final tx-frequency. This means original 100 Mhz is always 100 Mhz, or what ever frequency we choose it to be. Therefore we can easily add filtering before tuner chip. Because this prefilter have only work at one fixed frequency.

Mixer of tuning chip will produce, say, 100 Mhz - 90 Mhz = 10 Mhz, and 100Mhz + 90 Mhz = 190 Mhz. And this 190 Mhz will be effectively filtered by IF-filter, I hope. Strongest harmonic will be 300 Mhz - 90 Mhz = 210 Mhz.

One trouble is, when tx-frequency goes up, it will be cut by IF-filter. It seems, at chip I am going to use (Thumbnet dongle with R820T2), IF-filter is max 10 Mhz wide, and IF-frequency is about 3-5 Mhz. Anyway we can expect it to work at somewhere up to 15Mhz, IF-filter might not be razor-sharp in such a cheap device and it does not matter so much if we only get 0.2 mW out instead of 0.5 mW.

Prefilter


Actually "prefilter" which I am planning of can be considered more like "smoothing capacitor".
I get this idea from pages of Harry Lythall. Check the "5-WATT CW HF TX", which uses square wave oscillator, smoothed with capacitor.

So far this circuit have gave best results in simulations at 100Mhz. It is meant to be between Rasperry Pis pin4 and antenna connector of tv-dongle, which should have input impedance of 75 ohm. (Final waveform depends a lot of loads impedance, so this is NOT suitable to use with PiFm-based transmitter and some random wire antenna)

First and last resistors are not real, but presents of in/out impedance.
First capasitor, 1 nf, is not critical.
C1 and C2 are smoothing capasitors. These have to be trimmers etc, and to be adjusted for good performance, I presume.
Voltage divider resistors R3 and R4 have to be low value, 100 ohm seems to be low enough for Pi's pin 4.
Well, this simulations at square wave 100 Mhz. How square is wave from pin4 at 100 Mhz at reality...who knows...

PigFilter2.png

Tuner chip have automatic gain control, it should then output our signal with 1 volt swing and 2000 ohm impedance. We just have to capture it at point where it should normally enter to A/D-chip. I think it is "differential"- signal (some sources says it is I/Q-signal. This maybe because it seems RTL2832U have both kind of input pairs, but datasheet of R820T looks like it have differential output, not I/Q), so this calls for some kind of rf-transformer, perhaps to transform it to 50-ohm signal to simple transistor driver. (On other hand, perhaps voltage driven MOSFET-amplifier would be simple?)

In reality, for testing tx-signal from tuner chip, this about 0.5 mW is enough so really no need to think about amplifiers yet. It sounds I can just connect it to antenna and use another dongle to check that signal have no mean harmonics. Looks simple...


Picture: I would like to thank Glaudio Giuliani for this software, RTL_SDR_Wide_Spectrum_Analyzer.It is written with Gambas. It was indeed first time I have ever heard of Gambas when installing this.Now Pig is also written with it...it seems to be easy tool for quick prototyping.piFm100MShort.png

Initial look for harmonics


Here 100 Mhz carrier from Pi is fed through simple attenuator to dongle. It seems strongest harmonic is really 300 Mhz.

Attenuator is designed to get power level to same magnitude as it would be with prefilter. This is just rough prework, to compare later to prefilter. (and 60 ohm resistor is quite random choice). This 5pf capacitor is not real component, but estimated capacitance of wires...
atten100M5pf.png





PiFMAtten100M.png
...I first connected Pi with 0.5 meter of rg58-coaxial, attenuator was after that.
Signal here was same 100 Mhz. It did not make sense, strongest harmonic was 400 Mhz. It seems not to be square wave. So I realized capacitance of coaxial, which would make attenuator to act like circuit in below:atten100M40pf.png


So the first version of attenuator was not usable. But lesson learned, and it seems General Learning Machine is working as expected.

Also I noticed, with 200 Mhz carrier, there was strong harmonics on 100, 300, 400 and 500 Mhz, but much weaker at 600 Mhz, indicating that waveform is losing its (square)shape. These is not necessarily problem to using higher freqs (because we do not want signal to be square wave), but it is problem when trying to simulate prefilter.


First try of prefilter



First try of prefilter was quite promising. As you can see the most troubled harmonic, at 200 Mhz, have almost vanished.

I currently do not know of if AGC is active with this software, so lets not look db-values too much. Also I dont know if dongle have bandstop filter for FM-band.

In circuit below first resistor is marked as 1270 ohm. In sweep (at right) it was actually about 8 kohm, otherwise signals hit the roof. In this circuit input impedance is not critical (therefore I believe it is possible to use Pi as AM-modulator without trouble), but loads impedance is very important. 60 ohm resistor is real, and actual load impedance is determined by this resistor and actual input impedance of dongle.
PiFmPreFilter1.png
R4 is 180 ohm instead of 100 because I did find only one 100 ohm resistor...
C1 is 90p capasitor + 8-40p trimmer. Tuning of trimmer affects very lot to harmonics, as simulations predicted. C2 here is plain 150 p capasitor.



PreFilter1.png



I think I will next examine how this signal looks after downconverting it to HF with R820T2. I gues HF-frequencies of signal can then be checked with dongle itself, with direct sampling, and higher harmonics with another dongle.


Picture: Stub-lovers we are.
100McoaxStub1.png

Coax stub

As mentioned, there was 0.5 meter coax which have to be removed, and art of home brewing is to use what you
have. I get an idea.

I made simply 16,5 cm long shorted stub from coax, and connected it to rf-in connector used with dongle. (It is qu
arter-wavelength stub for 300 Mhz.) I added 10000p capasitor to isolate it from prefilter. (Do not know if it is necessary.)
I then compared 100 Mhz and 300 Mhz levels on Gqrx-receiver with hardware AGC turned off. 300 Mhz harmonic is now about 15 db lower than 100 Mhz fundamental, says Gqrx.As you can see, 300 Mhz line looks same as in previous check, but fundamental 100 Mhz have hit the roof. (R2 was still 8 kohm, not 1270 ohm.) This suggest AGC is really working on dongle with RTL_SDR_Wide_Spectrum_Analyzer, I guess.


100McoaxStub.png
On circuit stub is drawed as funny wire near output.


Picture: Graph of IF-signal from dongle, measured with another similar dongle.Actual 3,9 Mhz signal is not visible here, this is for confirming that high harmonics arereally filtered off. Oh my KISS, It seems to work.
fromTrans100Min.png

Confirming Pig tx-concept


I take IF differential-signal from tuner chip out with 1:1 rf-transformer (made with some random ferrite core), and fed it through voltage divider (about 1:20) to another similar dongle. I did not find strong high-frequency harmonics from IF-signal. Actually high frequency signals did grow very much when disconnecting receiving dongle from IF-signal. Therefore I estimate high frequency signals in here are received throw air, not from IF-signal.

Then I connected IF-signal to "Antenna", actually it was wire dipole made for FM-broadcast band. I listened IF-signal with ordinary ham-rig which had half meter wire as antenna, placed on same desk as donglehack.
I did find signal at 3885 Khz, when inserting 100Mhz signal at dongle and Gqrs tuned to 100 Mhz. I could adjust signal stregth by changing LNA-gain from Gqrs.

I also did find 2X nd 3X harmonics of 3885 Khz. This suggest that we can really take tx-signal out throw IF, and have over 10 Mhz signals also. These harmonics did look as strong as 3885, this most likely because short antennas in both tx and rx-side act like high-pass filter. In Gqrx there is not possibility to adjust IF-filter of dongle. I suppose it is standard 5 Mhz (?). Therefore it is not surprise to find 2X and 3X harmonics.




Note these files are meant for sending versions of Pig-software between my laptop and Pi. This is not real software "release".

From laptop to Pi: