DEMO, new FM broadcast code using Chip's Video mixer method + explanation
pedward
Posts: 1,642
I came across this post: http://forums.parallax.com/showthread.php?120170-AM-and-FM-Transmitters&p=884290&viewfull=1#post884290 and thought it was interesting enough to follow up.
I haven't seen anyone do what he suggested, so I modified my FM broadcaster demo to use the video modulator.
In Chip's post it suggests that you should not have 1's in more than 5 MSB positions. I'm operating the PLL outside of the specified range, generating a 140Mhz carrier (6 MSBs), plus a 6.550Mhz sub carrier.
The audio is very crisp and clear, and the jitter, birdies, and harmonics appear to be a lot better at first blush. I'm going to do some additional testing. I've got it attenuated into a 100 Ohm resistor on the breadboard right now.
Attached is the code.
Here's a video: http://youtu.be/pQlqV8Iyqfw
EDIT: I have revised the code so that PLLB is used for the broadcast generation and PLLA is used for sub-carrier modulation, only 1 COG is needed, not 2. I have also attached a nice WAV file for experimentation.
The way this works, the video generator is setup to only generate a broadcast aural sub-carrier, no video output. The PLL mode is set to 1, internal, with the output pin set to pin 7 for audio. Since the video generator expects PLLB to be setup at the proper broadcast frequency, that is used to generate a low-jitter carrier onto which the aural sub-carrier is modulated.
You can use the PLLA on the same COG to generate the aural sub-carrier since PLLA isn't used for generating baseband video. According to Chip's post above, the video generator XORs the sub-carrier onto the broadcast carrier, mixing the 2 values. This should generate a broadcast carrier of high stability and an upper image that is at frqPLLB + frqPLLA.
The attached sample has constants for several different frequencies, 80 + 6.5Mhz, 100 + 6.5Mhz, and 140 + 6.550Mhz. The lower 2 are broadcast FM frequencies which typically have a channel spacing of 200Khz and a bandwidth of 150Khz. To get a decent output volume the audio sample has to be shifted by 14 places, or 16384 to increase the deviation of the sub-carrier, that is a modulation of 8+14 bits, 22 bits. On the 2M band the channel spacing is much smaller and requires only 10 places of amplification, 1024, 8+10 bits, 18 bits. If you multiply the sample too much, you will overmodulate and get clipping, or worse, deviate outside your allotted channel width.
For the broadcast FM, 22 bits is a bandwidth of 40Khz, for 2M the 18 bits is 4.8Khz, so you can see, at 2M our deviation is within the recommended max 10Khz, and for broadcast FM, we can accommodate high quality audio, albeit monaural.
I'm a bit more confident in the quality of this modulation than the first try I did (directly modulating a single PLL). I haven't yet put this on a spectrum analyzer, but as soon as I can borrow one, I will (my father has a 1.2Ghz unit).
How is this demo useful? Well, there are several people that have been working on APRS, starting with the Bell 202 object. With this sample, you could direct modulate APRS or another low speed data protocol, allowing something like a quadcopter to send back telemetry for nearly free (Ken KI6HBT, are you reading this?).
Let's talk antennas. I tested this code with 2 antenna strategies, the first was just a 100 Ohm resistor, which limits the current output to 33ma, which is ~109 milliwatts. This was quite powerful, even without a proper antenna. My second test was with a 4.7k resistor, which limits the output to ~2.3 milliwatts. At 2mw, the PPDB board with resistor could broadcast over 80 feet before significant signal degradation.
The formula for antenna length is 468 / fMhz, this gives you a half wavelength antenna in feet, using a .97 free air velocity factor. It's unlikely that a 1/2 wavelength antenna would be used with this, so you will probably go shorter.
For the small data comms, they typically use either board traces or a wire antenna. A wire antenna is basically an isotropic unbalanced antenna that uses the PCB as the ground plane. The PCB ends up being the half of the antenna that isn't the wire, if you were looking at it like a dipole.
A good rule of thumb is to have a minimum antenna length of 1/8th wavelength, losses are so significant that it doesn't make sense to go shorter. As an example taken from here: http://www.kc7key.org/presentations/Vertical%20Antenna%20Myths%20final%20version.ppt A proper 1/4 wave antenna can have less than 3db loss, but a 1/8th wave antenna can have 12db of loss. To put that in perspective, a 3db loss means about 70% of the power you put into the antenna is radiated, at -12db you only get 25% of the power output -- that is 75% of the transmit power going into heating and losses.
At 1/8th wavelength, a 12db loss will mean that 108mw in translates to only 6.8mw output. A 1/4 wave antenna will radiate ~54mw for the same power input!
For a quadcopter that uses 144.390 Mhz (the standard 2M data channel), your half wavelength is 38.89 inches, 1/4 is 19.44, 1/8th is 9.72 inches, then you divide that by 2 if you are using a ground plane whip style, that's 4.86 inches.
A wire antenna that is just under 5 inches really isn't an imposition for a quadcopter. You can shorten the physical length by wrapping the antenna around a dielectric, which keeps the effective length the same. It's common to see mag mount antennas on cars that have coil loops at the base, this has the effect of shortening the physical length and creating a small air core loading coil at the base of the antenna. The loading coil causes the area below the coil to radiate the primary energy, as an inductor causes a phase shift and current lag in the RF signal. You will see some antenna manufacturers put the loading coil at the top of the antenna to increase the effective radiating element, this is mostly done on CB antennas and lower frequency HAM antennas (or center loading coils).
See:
http://hf-antenna.com/013/
http://www.qsl.net/g3pto/mobant.html
http://www.sstran.com/pages/sstran_buildant.html
http://www.amateur-radio-wiki.net/index.php?title=Antenna_loading
http://www.see.ed.ac.uk/~jwp/radio/software/loading.html
Hopefully this post is useful and opens up some applications for the Propeller. Oh, and please excuse any inaccuracies, I tried to explain things with references and from what I remember reading the HAM books. I'm sure any errors will be pointed out.
I haven't seen anyone do what he suggested, so I modified my FM broadcaster demo to use the video modulator.
In Chip's post it suggests that you should not have 1's in more than 5 MSB positions. I'm operating the PLL outside of the specified range, generating a 140Mhz carrier (6 MSBs), plus a 6.550Mhz sub carrier.
The audio is very crisp and clear, and the jitter, birdies, and harmonics appear to be a lot better at first blush. I'm going to do some additional testing. I've got it attenuated into a 100 Ohm resistor on the breadboard right now.
Attached is the code.
Here's a video: http://youtu.be/pQlqV8Iyqfw
EDIT: I have revised the code so that PLLB is used for the broadcast generation and PLLA is used for sub-carrier modulation, only 1 COG is needed, not 2. I have also attached a nice WAV file for experimentation.
The way this works, the video generator is setup to only generate a broadcast aural sub-carrier, no video output. The PLL mode is set to 1, internal, with the output pin set to pin 7 for audio. Since the video generator expects PLLB to be setup at the proper broadcast frequency, that is used to generate a low-jitter carrier onto which the aural sub-carrier is modulated.
You can use the PLLA on the same COG to generate the aural sub-carrier since PLLA isn't used for generating baseband video. According to Chip's post above, the video generator XORs the sub-carrier onto the broadcast carrier, mixing the 2 values. This should generate a broadcast carrier of high stability and an upper image that is at frqPLLB + frqPLLA.
The attached sample has constants for several different frequencies, 80 + 6.5Mhz, 100 + 6.5Mhz, and 140 + 6.550Mhz. The lower 2 are broadcast FM frequencies which typically have a channel spacing of 200Khz and a bandwidth of 150Khz. To get a decent output volume the audio sample has to be shifted by 14 places, or 16384 to increase the deviation of the sub-carrier, that is a modulation of 8+14 bits, 22 bits. On the 2M band the channel spacing is much smaller and requires only 10 places of amplification, 1024, 8+10 bits, 18 bits. If you multiply the sample too much, you will overmodulate and get clipping, or worse, deviate outside your allotted channel width.
For the broadcast FM, 22 bits is a bandwidth of 40Khz, for 2M the 18 bits is 4.8Khz, so you can see, at 2M our deviation is within the recommended max 10Khz, and for broadcast FM, we can accommodate high quality audio, albeit monaural.
I'm a bit more confident in the quality of this modulation than the first try I did (directly modulating a single PLL). I haven't yet put this on a spectrum analyzer, but as soon as I can borrow one, I will (my father has a 1.2Ghz unit).
How is this demo useful? Well, there are several people that have been working on APRS, starting with the Bell 202 object. With this sample, you could direct modulate APRS or another low speed data protocol, allowing something like a quadcopter to send back telemetry for nearly free (Ken KI6HBT, are you reading this?).
Let's talk antennas. I tested this code with 2 antenna strategies, the first was just a 100 Ohm resistor, which limits the current output to 33ma, which is ~109 milliwatts. This was quite powerful, even without a proper antenna. My second test was with a 4.7k resistor, which limits the output to ~2.3 milliwatts. At 2mw, the PPDB board with resistor could broadcast over 80 feet before significant signal degradation.
The formula for antenna length is 468 / fMhz, this gives you a half wavelength antenna in feet, using a .97 free air velocity factor. It's unlikely that a 1/2 wavelength antenna would be used with this, so you will probably go shorter.
For the small data comms, they typically use either board traces or a wire antenna. A wire antenna is basically an isotropic unbalanced antenna that uses the PCB as the ground plane. The PCB ends up being the half of the antenna that isn't the wire, if you were looking at it like a dipole.
A good rule of thumb is to have a minimum antenna length of 1/8th wavelength, losses are so significant that it doesn't make sense to go shorter. As an example taken from here: http://www.kc7key.org/presentations/Vertical%20Antenna%20Myths%20final%20version.ppt A proper 1/4 wave antenna can have less than 3db loss, but a 1/8th wave antenna can have 12db of loss. To put that in perspective, a 3db loss means about 70% of the power you put into the antenna is radiated, at -12db you only get 25% of the power output -- that is 75% of the transmit power going into heating and losses.
At 1/8th wavelength, a 12db loss will mean that 108mw in translates to only 6.8mw output. A 1/4 wave antenna will radiate ~54mw for the same power input!
For a quadcopter that uses 144.390 Mhz (the standard 2M data channel), your half wavelength is 38.89 inches, 1/4 is 19.44, 1/8th is 9.72 inches, then you divide that by 2 if you are using a ground plane whip style, that's 4.86 inches.
A wire antenna that is just under 5 inches really isn't an imposition for a quadcopter. You can shorten the physical length by wrapping the antenna around a dielectric, which keeps the effective length the same. It's common to see mag mount antennas on cars that have coil loops at the base, this has the effect of shortening the physical length and creating a small air core loading coil at the base of the antenna. The loading coil causes the area below the coil to radiate the primary energy, as an inductor causes a phase shift and current lag in the RF signal. You will see some antenna manufacturers put the loading coil at the top of the antenna to increase the effective radiating element, this is mostly done on CB antennas and lower frequency HAM antennas (or center loading coils).
See:
http://hf-antenna.com/013/
http://www.qsl.net/g3pto/mobant.html
http://www.sstran.com/pages/sstran_buildant.html
http://www.amateur-radio-wiki.net/index.php?title=Antenna_loading
http://www.see.ed.ac.uk/~jwp/radio/software/loading.html
Hopefully this post is useful and opens up some applications for the Propeller. Oh, and please excuse any inaccuracies, I tried to explain things with references and from what I remember reading the HAM books. I'm sure any errors will be pointed out.
zip
20K
Comments
Relating to a recent project.. Could 310Mhz be achieved this way?
OBC
You're also emitting an equal amount of energy at 140 MHz minus your 6.550 MHz subcarrier, not to mention odd harmonics of both frequencies.
-Phil
If the LS bits have to be kept zeros for the dreaded jitter did you choose the 6.55MHz so that by chance this allowed for 144MHz to be free of any "ones", or was it that it was just handy. I will have to try and work out what the stepping frequency interval could be so that those bottom bits were left low.
I thought that I had a 74HC4046 kicking around to try Phils slaved VCO idea. It would have to be down around 20-25MHz and multiplied back up. I have better access to a R&S FSH3 analyzer now so at least I could see some of the nasties that crop up. I am more interested in the 137MHz NOAA wx sats which do require a bit more Rx bandwidth, fortunately. I wonder if 2M with 12.5KHz channel spaced, 2.5KHz deviation would be a bit tight for any, significant, amount of jittering.
EDIT I have now realized that the 6.55 wasn't the Xtal freq. Hey-Ho.
Chips post recommended using a broadcast frequency with no more than 5 of the MSBs set. That will take you up to 120Mhz, but that would mean modulating a 26.55 Mhz sub-carrier to generate 146.550. I would expect a larger sub-carrier frequency would contribute to jitter and harmonics, so I tried to keep it small.
I have attached a spreadsheet I made that shows all of the possible single bit PLL frequencies. It is quite clear just where jitter comes from when looking at the spreadsheet. Looking at the data, I wonder if the jitter is caused more by odd frequencies (FRQ values that have a remainder) or simply the number of poles (number of frequency bins) the counter shifts through?
Based on this spreadsheet, I can actually adjust my PLL values to produce the broadcast frequency with only bits in the top nibble, but that would put the NCO outside of the 4-8Mhz. Ill try it anyway...
I'd like to try this demo, but radio is not my strong suit...could you elaborate on how to hook up a breadboard antenna? Is it literally as simple as a 4.7k resistor connected between a prop pin and ground (to make a very low gain antenna)? Or is a piece of wire of appropriate length a necessity? If yes, is it as simple as placing one end of the wire in electrical contact w/ the prop xmit pin and leaving the other end free?
Thanks for the demo, this should be interesting.
-Phil
AD7YF
But yes, you are 100% correct in pointing this out. The 2mw output is *MORE* than enough for testing and tinkering, 80ft+ radius line of sight without a tuned antenna.
--Perry
W0NKE
I have a couple of 74HC4046s on order so that I can try Phil's "flywheel" circuit down at 20MHz, or so, and use the Prop for the stepping, thinking and display bits.
Used to be G8LCU
Pride in the new project takes a knock, when you see that its output resemble the rear view of a frightened hedgehog :-)
Thanks for the link, and I'll heed your admonition. Rest assured I'm not planning on starting a pirate radio station, just wanted to try another interesting Propeller experiment.
[At the risk of incurring the wrath of a moderator]...now I have this mental image of Browser staring intently at a scope, looking for the faintest sign that "those Propeller hooligans" are causing trouble on the airwaves..."Fil! Fil! Dey're at it ugain! Call da FCC..."
-browz
'Finally got around to trying your transmitter code. Here's what I observed using a Yaesu VX-2 HT, with the Prop programmed for a fundamental at 100 MHz, and working upward:
100.0-100.3 MHz: quieting, no or little modulation.
100.4 MHz: maximum modulation.
Modulated birdies (strongest ones in boldface) at 102.1,103.9,104.2,105.2,106.5,107.7,108.7,109.3,110.7,...,118.4,119.6, and so on.
Here's what the spectrum looks like:
Lots of birdies, I'm afraid, clear up into the aviation band, the 2m ham band, and beyond.
-Phil
Here's the same spectrum, zoomed in to 5 MHz per major division:
-Phil
-Phil
Is its Chip's limitation of 5 ones in the MSB? (top word or byte?)
Can we generate a simple PLL signal at 88-160mHz, and if so, what would it look like?
For example, using a simple PLL counter with a /16 and a FREQx of 1CE13A92 would generate a 144.399 MHz signal, right? Could you run a spectrum analysis on that and see how bad the birdies are in-band (+/- 3MHz)?
If it is fairly clean (-20db), then I have an idea for generating an FM signal from an analog input. (I'm fairly new to the propeller, so please excuse my generic oversimplification).
Create a PASM cog to:
1. Look up a FREQx value from a 256 byte table, spanning from 144.38875 to 144.39125 (144.399MHz +/- 2.5kHz /2 deviation). Use an index value to load the correct value into the FREQx register. (256 to keep it local to the 512 word cog).
2. Use a sigma delta ADC on an input pin to increment or decrement the index. That way the analog signal picks the transmit frequency (FM modulation, right?). We would need to limit the index to between 0 and 255 (or perhaps -128 to +128).
By using a local sigma delta ADC, we don't have to pass data through the hub (to reduce cycle time and therefore jitter). The analog signal could be any source, but it could also be the filtered (300-3000Hz) result of another Cog generating an audio signal of a APRS packet, who's source is another Cog creating an AX.25 packet from another Cog, picking apart the GPS signal from a VPN1513 GPS Receiver Module (with propeller on board!).
(Okay, so pick it apart now!)
-Phil
-Phil
How about a simple transmitter, either a MAX2606 at 0.1 mW (http://www.maxim-ic.com/datasheet/index.mvp/id/2323 and http://electroschematics.com/83/mini-fm-transmitter-max2606/) or a AD7012 at 25mW (http://www.analog.com/en/rfif-components/rfif-transceivers/adf7012/products/product.html).
Now you say "yeah, go do it!". Wish I had the time.
-Phil