Pages: [1]   Go Down
Author Topic: Re: radio frequency broadcasting  (Read 1101 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 20
If you can't open it, you don't own it.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Doh, I meant to click preview. I meant 3 things I would recommend (:

"There are 3 types of people : those who can count and those who can't"
Logged

Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not near my Arduino (acutally, it's an Olimex board with an Atmega168 in a ZIF) right now but I did try ints instead of longs and saw no performance increase.  Given that millis() looks to be expensive, I will rewrite the code when I get a chance, and have it do a skad of operations and check the millis() after it and divide by the time (instead of calling millis() several times for EVERY loop).  Thanks both of you for your help.

In the end I'll probably end up using a 555 timer for my 100 KHz application, since it won't actually need any configuration.  But my first thought had been "I'll bet I can get an Atmega8 to serve as a cheap, precise arbitrary square wave generator."
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hey it is quite the party in here!

Quote
But my first thought had been "I'll bet I can get an Atmega8 to serve as a cheap, precise arbitrary square wave generator."

Instead of direct synthesis, what about an XTAL osc, fed into a high-frequency divider controlled by the Arduino? It's basically what they would call a VFO or Variable Frequency Oscillator' in ham radio. That way the Arudino's pins could be taken up by I/o for displays and button for setting the frequency.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"I'll bet I can get an Atmega8 to serve as a cheap, precise arbitrary square wave generator."

"An extremely simple and low cost Sine/Square wave generator based on the Analog Devices AD9835 Direct Digital Synthesis (DDS) Generator chip. The frequency can be set for any frequency from 1Hz to 10MHz in 1Hz resolution steps."

http://www.makezine.com/blog/archive/2007/01/another_diy_fun.html
Logged

Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

All kinds of good ideas.  I ran an experiment with a new test algorithm that still uses longs but doesn't do anything inside the loop except toggle a digital output line.  I saved millis, went into a million-iteration loop, and then checked millis again, and had only used 644 of them.  That's a ceiling of 1.54 MHz for square waves, well within my desired range (and good enough for AM radio!).

Here's the code:

long millisAtStart=0;
long millisAtEnd=0;
long i=0;
 
 
#define BINARY(a,b,c,d,e,f,g,h) ((a)<<7|(b)<<6|(c)<<5|(d)<<4|(e)<<3|(f)<<2|(g)<<1|(h))

void setup()
{
 
  Serial.begin(9600);        
 
}

void loop()
{
    millisAtStart=millis();
    for(i=0; i<1000000; i++)
    {
      PORTD ^= BINARY(1,0,0,0,0,0,0,0);  
    }

     millisAtEnd=millis();
 
     Serial.print(millisAtStart);
     Serial.print(" ");
     Serial.print(millisAtEnd);    
     Serial.print(" ");
     Serial.print(millisAtEnd-millisAtStart);
     Serial.println();
}
Logged

Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 20
If you can't open it, you don't own it.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Montréal, Qc
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 13, 2007, 03:09:02 pm by CosineKitty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used your work to make a Morse code beacon broadcasting at 1337 kHz. Details at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1170901754.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah omg, can someone show me the partof the code that actually, sets up, and broadcasts the frequency!?!?!?!??! and would it be possible to add an audio input signal to that frequency and broadcats that too!?!:?!?
come on people i need some help!

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

illuminati,

Check this out. This is probably close to what you want to do.

http://hackedgadgets.com/2010/06/21/diy-am-transmitter-from-a-555-timer-or-picaxe-microcontroller/

Pretty much the MC is used to generate an AM carrier signal but some more external components are needed to modify the carrier so it can generate sound. AM is a very simple for of transmission and can be done with a few external components.

I'm a radio operator so i <3 this kind of stuff.
« Last Edit: June 25, 2010, 07:56:54 am by sp00nix » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33408
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm a radio operator so i <3 this kind of stuff.

So you also know that it is illegal to do this without a licence.
« Last Edit: June 25, 2010, 08:29:43 am by Grumpy_Mike » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

actually broadcasting in the so called american broadcast band is not actually illegal so long as you dont exceed 100mw and keep the antenna less than 10 ft.  Look up Part 15 of the communications rules
Logged

Pages: [1]   Go Up
Jump to: