Go Down

Topic: Re: radio frequency broadcasting (Read 1 time) previous topic - next topic

bigfun

By successive approximation, I found that a for loop that only toggles a port pin can do 1,552,450 square waves per second, which is 3.1236 (hmm, similar to pi) times 497 KHz, the radio frequency CosineKitty picked up this signal on.  I tuned in 1550 on the dial of an AM radio and held it nearby but got nothing that changed when I reset the Atmega.

Lionel Lemarie

Hi Bigfun,

Good stuff ! CosineKitty's discovery could be really useful. I wonder if it could be used to transmit data...

1,000,000 iterations / 644 milliseconds = 1,552 iterations per milliseconds.

Given that you need two iterations to make a square wave (first to set to 1, second to set back to 0, ^= is an XOR don't forget), the frequency is 776.397kHz, isn't it ?

Lionel.

bigfun

Good point, so yeah, 776 kHz is the ceiling. That would explain my problem with the AM radio.  Of course, it would be a square wave and not sine unless you ran it through some sort of filter.

xSmurf

I'll sound like a total newb, but what if you wanted to implement other frequencies? This could be useful as a quick frequency generator.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

CosineKitty

#9
Jan 13, 2007, 09:02 pm Last Edit: Jan 13, 2007, 09:09 pm by CosineKitty Reason: 1
Yes, I can confirm that the rate you get is highly dependent on the kind of code you have in your loop, and that timer interrupts will cause slight distortions in your exact frequency.  It is a toggle using XOR, so your square wave frequency will be half the number of iterations per second.  On the other hand, because it is a square wave and not a pure sine wave, you will get harmonics at every integer multiple of the base frequency, though the energy in each higher harmonic will become weak very quickly.

If you have an oscilloscope, it is very helpful to see exactly what the square wave looks like, and visually determine the amount of time it takes for each full wave.  I have a very old (vintage 1974) scope that still works great for this kind of thing.

One thing you can do is to make sure you put a long wire attached to the output pin you are toggling, as an antenna... with mine hooked up to a 8-meter long piece of wire that runs out my window, I was able to receive the signal all inside my house and around my yard outside.

Go Up