PDA

View Full Version : external oscillation



lerameur
- 9th October 2006, 01:00
Hello,

I would like to know if it possible to create 20KhZ external frequency with Pic chips, lets say the pic16f88. I did not find anything on google on such a thing.

thank you

ken

sayzer
- 9th October 2006, 02:55
If what you want is to generate 20Khz frequency using 16F88, then sure you can do it by using PWM feature of this PIC.

For 20Khz at 4Mhz, using 1:1 prescaler, PR2 should be 49.
At 20Mhz, 1:1, PR=249.



mister_e, pls correct me if I am wrong :D

mister_e
- 9th October 2006, 03:39
Yup PWM is the way to go. You can use the PBP HPWM or setting the PIC register as Sayzer said.


mister_e, pls correct me if I am wrong :D
I got the same results ;)

lerameur
- 9th October 2006, 16:16
I got it going with a 4Mhz oscillator. Here is the program.
I wanetd to use the 20Mhz oscillator. and it do not work. I change the 4 to a 20 in the program and changes the crystal and the capacitor to 22pF and it is not oscillating, anybody knows why. is there a command I nee to do ?


Define LOADER_USED 1
DEFINE OSC 4 'Using 4MHz oscillator
TRISB = 0

loop: FREQOUT PORTB.1,10000,20000 ' Turn on PORTB for 1- sec at20Khz
Pause 100 ' Delay for .5 seconds

Goto loop ' Go back to loop and blink LED forever

lerameur
- 9th October 2006, 16:54
ok added this line :

@ DEVICE HS_OSC

and now it works :)

lerameur
- 9th October 2006, 19:51
I am trying ot get a sin wave at the output. From the manuals of picbasic pro, they say to add a low pass filter, I did this, it dos remove the extra noise, but it does not make it a sinwave. Anybody know how to make it a sin wave ?

ken

sayzer
- 9th October 2006, 20:47
Did you check this post?

http://www.picbasic.co.uk/forum/showthread.php?t=718



-------------

mister_e
- 9th October 2006, 21:26
If it's for a single frequency with a 50% duty cycle you could still use a pair of integrator made with Op-Amp.

lerameur
- 11th October 2006, 00:49
I need 6 frequencies.
maybe using an analog circuit using amplifiers to make the oscillation and the pic to control + / - a few kilohertz to get lets say between 20 to 30 khz ??
The goal of this is to create an ultrasonic bird repeller, maybe the square waves (although noisy) can scare them off.

k

sayzer
- 11th October 2006, 03:48
... maybe the square waves (although noisy) can scare them off.
k


Make sure it won't attract the big insects if not small birds!

Archangel
- 11th October 2006, 03:58
Hi lerameur,
I need one of those too, to repel pidgeons, and neighbors with BIG STEREOS!;)
About 300 watts ought to do it! Someone on eBay is already selling PICs programmed to do this and he sells tranducers too!
Good luck with the birds, let us know how it works.
Joe

mister_e
- 11th October 2006, 05:16
Some DDS synth may do the job.

some DACs to control some VCOs too.

Tons of different way. A single PIC.. maybe good for low frequency.

Do you have all frequency values? It could be possible with some effort...

EDIT: you said 6 frequency... All together or what?

Be carefull some birds are much intelligent than others...
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1119&stc=1&d=1160540502">

lerameur
- 11th October 2006, 13:26
well I thought this thing could be battery operated, at 300watt forget that..

here is the code I would like to use:
Also, one freqnecy the output looks good, but more then one the frequency varies from 11k to 31khz and very unstable.

@ DEVICE HS_OSC
TRISB = 0

loop: FREQOUT PORTB.1,10000,20000
' Pause 100 ' Delay for .5 seconds

FREQOUT PORTB.1,10000,26000 ' Turn on PORTB for 1- sec at 26Khz
Pause 100 ' Delay for .5 seconds

FREQOUT PORTB.1,10000,21000 ' Turn on PORTB for 1- sec at 21Khz
Pause 100 ' Delay for .5 seconds

FREQOUT PORTB.1,10000,27000
Pause 100

FREQOUT PORTB.1,10000,22000
Pause 100

FREQOUT PORTB.1,10000,28000
Pause 100

FREQOUT PORTB.1,10000,23000
Pause 100

FREQOUT PORTB.1,10000,29000
Pause 100

Goto loop ' Go back to loop

Acetronics2
- 11th October 2006, 14:21
A look here ???

http://shop.elv.de/output/controller.aspx?cid=74&detail=10&detail2=10617

...

no comment !!!

mister_e
- 11th October 2006, 15:05
Depending your osc frequency (wich you should define at the top of your code) this shoud produce the freq sweep from 11 to 41KHz


Freq var Byte
Duration var Word

Start:
For Freq=45 to 16 step -1
For duration = 0 to 10000
High PORTB.1
PAUSEUS Freq
LOW PORTB.1
PAUSEUS Freq
NEXT
NEXT
GOTO Start

lerameur
- 14th October 2006, 00:49
hello Steve,

tu dois parler francais ?
J,ai regardé ton site l'autre jour
moi je suis de ste-julie.
le monde est petit

ken

mister_e
- 14th October 2006, 16:33
Effectivement le monde est TRES petit. Ici on a donc
1. Ste-Julie
1. Saint-Hubert
1. Saint-Amable

Pas de quoi faire un gros G.T. encore mais bon :)