Transmitting and receiving square waves


20 posts
by FLCat » Fri Jan 31, 2014 6:06 pm
I was thinking that creating square wave rf using the GPIO could be relatively easy. How can I make the transmission powerful enough to be received easily? And is there some way of getting more range?
And how would I go about receiving the signal? I assume I would need some external hardware for that and i'm not exactly sure how the signal is picked up by another piece of metal (aka the antenna) and how can I read it? I've been looking on google but there's not much stuff about square waves probably because using them is a terrible thing to do.
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by gordon77 » Fri Jan 31, 2014 7:33 pm
Square waves are full of harmonics so not much use for transmitting as you may interfere with many things
Posts: 2886
Joined: Sun Aug 05, 2012 3:12 pm
by joan » Fri Jan 31, 2014 7:49 pm
User avatar
Posts: 12687
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by DougieLawson » Fri Jan 31, 2014 8:19 pm
joan wrote:http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter


Which is all good fun until the folks from OfCom knock on your front door.
http://stakeholders.ofcom.org.uk/enforc ... broadcast/
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28145
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by gordon77 » Fri Jan 31, 2014 8:48 pm
I don't know the power of the fm transmitter but you can have low power short range devices
http://stakeholders.ofcom.org.uk/enforc ... cement/law
Posts: 2886
Joined: Sun Aug 05, 2012 3:12 pm
by DougieLawson » Fri Jan 31, 2014 9:02 pm
gordon77 wrote:I don't know the power of the fm transmitter but you can have low power short range devices
http://stakeholders.ofcom.org.uk/enforc ... cement/law


But we don't know what power we're transmitting, we don't know the range and we don't know the harmonics that we're causing interference on.

Two years in gaol and an unlimited fine isn't an attractive proposition.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28145
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by FLCat » Fri Jan 31, 2014 9:17 pm
joan wrote:http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter


There's a single antenna wire connected to a pin outputting a binary clock signal? Can someone explain how this works? From what I know electricity wont even enter the wire because its not connected to a negative pin. Does this mean I can just flick a random pin on and off example 100hz with a antenna hooked and it will transmit a 3.3v 100hz square wave?

gordon77 wrote:Square waves are full of harmonics so not much use for transmitting as you may interfere with many things


I know square waves are a horrible thing. But I was planning to get the range to around 1 meter so noone will find out.
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by redhawk » Fri Jan 31, 2014 9:31 pm
Radio waves don't require a return path a simple 1/4 wave dipole (aka piece of wire) can work quire nicely when floating in the air. :)
Image

Richard S.
User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by FLCat » Fri Jan 31, 2014 9:35 pm
redhawk wrote:Radio waves don't require a return path a simple 1/4 wave dipole (aka piece of wire) can work quire nicely when floating in the air. :)
Image

Richard S.


Ok, so how can I receive the transmission? If I have a receiving antenna next to the transmitting one, can I just read a voltage from the receiving antenna? I think radio transmissions are different from induction though. Or do I do pretty much the same thing as with the transmitting one, hook a receiving one to a single input pin?
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by redhawk » Fri Jan 31, 2014 9:53 pm
You'll need a radio receiver to pick up radio broadcasts or make one yourself.
Have a look on eBay you can buy ready made TX/RX modules most of which operate on the license free 493.92MHz frequency.

What exactly do you need to transmit and what equipment shall be receiving this signal??

Richard S.
User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by FLCat » Fri Jan 31, 2014 10:23 pm
redhawk wrote:You'll need a radio receiver to pick up radio broadcasts or make one yourself.
Have a look on eBay you can buy ready made TX/RX modules most of which operate on the license free 493.92MHz frequency.

What exactly do you need to transmit and what equipment shall be receiving this signal??

Richard S.


So its not possible to use the Pi for receiving? I would need to detect the "high" states of the square wave with the receiver. Im looking for the easiest (and cheapest) possible way of getting this to work.
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by redhawk » Fri Jan 31, 2014 11:04 pm
The Pi has no radio receiver capability you'll need to build a radio reciever with Schmitt trigger TTL or use one of these eBay RX boards - http://www.ebay.co.uk/itm/433.92MHz_mod ... 0928401303
Just be aware that most RX boards have a 5v TTL output, this would require converting to 3.3v to be safe for the Pi's GPIO input pin.

Richard S.
User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by Burngate » Sat Feb 01, 2014 3:26 pm
redhawk wrote:Radio waves don't require a return path a simple 1/4 wave dipole (aka piece of wire) can work quire nicely when floating in the air. :)

Actually there is a return path.
If you consider the whole circuit, as well as whatever's generating the signal and its ground connection, and the piece of wire, there's the capacitance between the wire and ground.
So the current flows from the generator, in this case the GPIO, through the wire, the capacitance and the ground back to the generator.

The wire-ground capacitance is lossy - energy is lost to the environment, as radio waves.

And you could pick up the radio waves on a wire connected to a GPIO, but the signal will be too small to change the GPIO input from 0 to 1.
If you put an amplifier in the circuit, you will get a string of 0's & 1's, but you might have difficulty keeping up with them in code. You could never-the-less detect their presence or absence.
User avatar
Posts: 4791
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by Richard-TX » Sat Feb 01, 2014 3:36 pm
Transmitting square waves is not advisable. Square waves by definition consist of a sine wave plus an infinite (in theory) number of harmonics.

Image

It is nasty stuff. If anything will get you unwanted attention, that will.

You have been warned.

Square waves are unnatural. They never occur in nature.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 1545
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by FLCat » Sun Feb 02, 2014 3:39 pm
joan wrote:http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter


Does FM work with square waves aswell? Like it can be picked up by normal FM radios? Or is the pin 4 clock somehow different?
Last edited by FLCat on Sun Feb 02, 2014 4:20 pm, edited 2 times in total.
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by redhawk » Sun Feb 02, 2014 4:19 pm
Does FM work with square waves aswell?

There's no such thing as square radio waves it's a mixture of multiple sinusoidal waves that make up the squares.
So your FM radio will work but it can only tune into the main sinusoidal component of your signal the rest are nasty harmonic distortions that pollute the entire FM band and beyond to Air Band.
Building a radio receiver is very easy with the right transistor like the BF199, however getting a circuit to operate at high frequencies with little or no tuning drift and good reception is difficult.
As I had said earlier the RX/TX boards from eBay have everything you need to broadcast and receive digital signals in one direction you just need to wire it up to the Pi.

Richard S.
User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by FLCat » Sun Feb 02, 2014 4:26 pm
redhawk wrote:There's no such thing as square radio waves it's a mixture of multiple sinusoidal waves that make up the squares.
So your FM radio will work but it can only tune into the main sinusoidal component of your signal the rest are nasty harmonic distortions that pollute the entire FM band and beyond to Air Band.


How do the harmonics pollute the FM band if FM only cares about frequency?

And does
http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
use square waves?
Posts: 8
Joined: Sat Nov 23, 2013 8:36 pm
by redhawk » Sun Feb 02, 2014 4:42 pm
Yes it generates square waves but the radio emissions are sinusoidal of different frequencies that make up the square waves.
For more information on square waves please read the wikipedia page - http://en.wikipedia.org/wiki/Square_wave

Richard S.
User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by techpaul » Sun Feb 02, 2014 5:37 pm
FLCat wrote:
redhawk wrote:There's no such thing as square radio waves it's a mixture of multiple sinusoidal waves that make up the squares.
So your FM radio will work but it can only tune into the main sinusoidal component of your signal the rest are nasty harmonic distortions that pollute the entire FM band and beyond to Air Band.


How do the harmonics pollute the FM band if FM only cares about frequency?
Others have given you pointers and many more folks with experience in these things tell you don't do it that way.

So why do you persist in trying to break many laws of most countries
And does
http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
use square waves?
No is the short answer.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Burngate » Sun Feb 02, 2014 6:14 pm
FLCat wrote:Does FM work with square waves aswell? Like it can be picked up by normal FM radios? Or is the pin 4 clock somehow different?

No, the Pin 4 clock isn't fundimentally different, it still starts off as a square-wave. So you're still going to be spraying radio waves at all and sundry, complete with all its nasty harmonics.

About the only saving grace is that the Pi's GPIO hardware can only work so fast. Stray capacitances in the chip and on the board mean that waveforms don't rise infinitely fast.
That means the "square-waves" aint square, so the harmonics don't stretch to infinity.
Just imagine, if they did. Every time a GPIO changed state,there'd be at least some energy in the visible spectrum, and you'd see the Pi flash.

Then again, the aerial has a large effect on what's radiated. If it's the right length, and there's a ground-plane nearby to balance it, you could get quite a lot of radiated energy, and annoy a lot of neighbours.
Or feed it into a decent amp then into a spark-gap, you could emulate the Titanic
User avatar
Posts: 4791
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK