Pages: [1] 2   Go Down
Author Topic: Wanting to build a frequency generator.  (Read 1940 times)
0 Members and 1 Guest are viewing this topic.
Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 703
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This will be a temporary job but I was wanting to use the Arduino only because it MAY allow easier adjustments when build.

I have seen a clip on the web where you get a speaker and pump 24 Hz into it.
In front of that you have water falling - small stream - and the water is deformed by the "sound" coming out of the speaker.


Now, although I don't have a 24 Hz camera, I still would like to see it myself and maybe take a piccie anyway.

For the hassle of making it with discreet electronics an Arduino may be better for frequency adjustment and range.

I have the PWM.library and shall look into using it, but would like a bit of help in how to get it going - the bigger picture that is.

Thanks.

Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26331
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

PWM does not change frequency.
You probably want Tone instead, to play back different frequencies.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Denmark
Offline Offline
God Member
*****
Karma: 14
Posts: 650
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you don't have a camera that can shoot 24 FPS it won't work. If you camera shoots at 30 FPS, you need to feed a 30 Hz tone to the speaker instead.

It works because the camera and the movement of the water is synced.

// Per.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool! especially the 23Hz backwards part!
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5296
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now, although I don't have a 24 Hz camera, I still would like to see it myself and maybe take a piccie anyway.

You can't see the effect yourself, you can only see it through a 24Hz camera.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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

I would also like to know how to generate specific frequencies using the arduino.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26331
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check out Tone.
http://arduino.cc/en/Tutorial/Tone4
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I would also like to know how to generate specific frequencies using the arduino.
specify specific.. which range?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

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

Whatever the Arduino is capable of producing.
Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 703
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Drats!

So if I don't have a camera at 25 hz, it won't work.

What about the 24 and 23 Hz shots?

But tone( ) makes a square wave output, the youtube says sinewave.   smiley-sad

Will it still work?

Sorry, I know it is kinda off topic, but this just looks so neat and I would love to build it and have it "demonstratable" for someone to see with their eyes and not needing a 25hz camera.

BTW, 25 Hz:  That's PAL format - right?  I have an old video camera.  So that would work?   :-)

P.S.
Weird thing:  I have not been getting many update posts via e-mail.
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2451
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect you just need to match the camera shutter frequency (or a multiple of it) so if your using a PAL camera it's 25Hz (or maybe 50Hz if using interlace) and if your using NTSC than make it 29.97Hz
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 703
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is my effort at making a sketch.

The idea is that it will be controlled from the PC.

I send it commands and it changes the frequency.

Ok, re-think.  Instead of sending it up/down commands to change the frequency, I just send it the actual frequency.

Either way I am stuck.

This is the sketch so far:

Code:
void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop()
{
  // put your main code here, to run repeatedly:
  int tone_frequency;
  if (Serial.available() > 0)
  {
      char dir = Serial.read();
      char num1 = Serial.read();
      char num2 = Serial.read();
      Serial.print ("Dir ");
      Serial.println (dir);
      Serial.print("Num1 ");
      Serial.println (num1);
      Serial.print("Num2 ");
      Serial.println (num2);
  }
      
}

I am getting this when I run it and send a command:  (which is +.1)

Dir +
Num1 ÿ
Num2 ÿ
Dir .
Num1 ÿ
Num2 ÿ
Dir 0
Num1 ÿ
Num2 ÿ
Dir 1
Num1 ÿ
Num2 ÿ


As you can see there are "dummy" lines between them.

Dunno why.

I have used this sort of stuff in another sketch and it seems to work.

Anyone - please.


Ok, I learned something:
I need to see the "delimiter".  I was always getting a "7" at the end.

So I made is to this sketch:
Code:
int frequency1;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop()
{
  // put your main code here, to run repeatedly:
  int tone_frequency;
  if (Serial.available() > 0)
  {
      //
      frequency1  = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
      //run_time_hr  = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
      if(Serial.read() == ';')
      {
          Serial.print ("The frequency you entered is ");
          Serial.println (frequency1);
      }
  }
     
}

But now it doesn't accept anything or echo anything back.

Say I enter 22;
I don't get anything back.


Stuck but trying.
« Last Edit: May 17, 2013, 10:02:08 pm by lost_and_confused » Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

why not slowly increase/decrease the frequency until you see the desired results on camera with a potentiometer?
Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 703
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

CJ',

I don't get you.

If I am using an Adruino, use of a potentiometer is.....   Confusing.

The sketch (original) was going to start at a frequency and I send commands like +1, +15, -2, -2.4 etc.

But then I realised that was complicated.

I could just send the frequency I want.

But I am having trouble with "parsing" the serial data.

:-/
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thing is... using an arduino will give you what you need for example, your using a sledge hammer (arduino being the sledge hammer) to crack a nut open with...

eg a 555 timer and few components for less than a dollar will give you the same results...

a pot can be hooked up to the arduino easy enough via a0 5v out > pot > analog in... as you adjust the pot you can increase / decrease the frequency without relying in a computer to feed the data to it..

look up 555 circuits, or even a gate oscillator (fewer components)

failing that go and buy a 1 or 10k pot and feed into to an analog port
Logged

Pages: [1] 2   Go Up
Jump to: