# Analyzing osc frequency

Discussion in 'General Electronics Chat' started by threepwood, Apr 7, 2016.

1. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
Hi Guys,
i need some help here.
I am studying the following police siren: http://www.simonthenerd.com/files/policesiren/PA300.pdf

At page 16 there is the schematic. VERY old school electronics. In the specific i was focusing my attention on the LM556 part (top left corner, ICI2) which is the part that makes the air horn possible.

All i'm trying to do is to recreate that sound using a PIC (12F675). I'm really guessing the frequency used for this tone but i can't and i don't have an oscilloscope to recreate that circuit and analyze the frequency. Could anybody please give me a hint on what frequency to try and what speed?

At the moment my best attempt was to use 2 alternate frequencies (2000hz and 0hz) both at 3ms but somehow it doesn't sound how it is supposed to.

2. ### wayneh Expert

Sep 9, 2010
11,891
2,845
I didn't look at the circuit but there are tons of 555 timer calculators online that will tell you the frequency based on the values of the timing components, the R and C values.

3. ### SLK001 Active Member

Nov 29, 2011
746
197
Zero Hertz isn't a frequency - it is the absence of frequency, or DC.

4. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
All i was able to do is to analyze the sound with audacity and reduce the speed and all i could see was exactly sound-pause-sound-pause-sound-pause...... and that's why i opted for the 0hz.

Apr 5, 2008
15,529
2,301
Hello,

If you want a tone to go on and off , you can use OOK (on-off-keying).

Bertus

6. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
I would love to know what tone tho

7. ### wayneh Expert

Sep 9, 2010
11,891
2,845
I bet you do! Any computer or smartphone can run free oscilloscope software that can analyze signals from the microphone or from a line-in port. Your signal is obviously in the audio range, so the limitations of this approach - being limited to the audible frequency range - are not a problem for you.

Oops, just saw your post #4.

8. ### dannyf Well-Known Member

Sep 13, 2015
1,602
314
2000hz is doable on a mcu. 500us is plenty of time for the mcu. I think you can have a timer to generate an interrupt every 500us and flip a pin, based on a counter that accumulates at 2000hz. How fast you accumulate the counter determines the speed of modulation.

9. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
The little frequency analyzer app that i have on my phone detects a frequency of 1280hz and 4033 pulses per 3 seconds. Is it even possible?. It seems the more i dig the bigger the trouble i get into.

Last edited: Apr 7, 2016
10. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
i downloaded another software that analyzes sounds and it tells me that the peak is 1453hz. I still don't know the spacing

11. ### dannyf Well-Known Member

Sep 13, 2015
1,602
314
I did a little experiment. The following code, running at 1500Hz carrier signal, consumes about 10% of the 12f675's processing power.

Code (C):
1.
2.     TMR0 +=-(F_CPU / 4 / F_CARRIER / 2);    //load the offset
3.     //_mod_cnt--;                                //decrement counter
4.     if (--_mod_cnt==0) {                        //sufficient time has elapsed
5.         _mod_cnt=F_CARRIER / F_MOD;            //initialize the counter
6.         IO_FLP(SIREN_DDR, SIREN_MOD);        //flip the modulating pin to alternate between run and not run
7.     }
8.     IO_FLP(sGPIO, SIREN_OUT);                //flip the output pin to generate the carrier signal
9.     SIREN_PORT = sGPIO;                        //output the shadow variable to port
10.

Last edited by a moderator: Apr 8, 2016
12. ### dannyf Well-Known Member

Sep 13, 2015
1,602
314
The whole thing takes 83 bytes and fits nicely into the limited flash,

It actually can be arranged to run on just one pin, but I decided to use a modulating pin to make it more generic: you can easily port the code to AVR where you can use the output compare functions to generate much faster square wave, well into the RF range, making this a simple radio transmitter, with practically no other parts.

13. ### AnalogKid Distinguished Member

Aug 1, 2013
4,283
1,172
The 555 circuit calculates out to 312 Hz and a 52% duty cycle. But the control pin is tied to Vcc through a diode, so that shifts the internal comparator trip points and affects the frequency and duty cycle. Also, note that the output is the sawtooth wave across the timing capacitor.

That waveform modulates the VCO (voltage controlled oscillator) in a CD4046 PLL (phase locked loop). My guess is that the 4046 output varies between 725 Hz and 1575 Hz because those are the frequencies for the other audio patterns, and the4046 output is the only thing driving the output amplifier. This is why the specifications page does not mention the air horn frequency - it looks like the same frequency modulation as the "wail" signal, except the modulation signal is so fast that it sounds like a chord. You can confirm this by calculating the oscillator center frequency using the 4046 datasheet.

ak

14. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0

I tried to compile that code with mplab xc but it gives me a hundreds of errors when i hit the program button. Is it because it's a partial code maybe?

For the one i'm working on i'm using mikrobasic.

Last edited by a moderator: Apr 8, 2016
15. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
Even if your explaination was a little too technical for my knowledge i can tell you that i always had this doubt in my head drilling like a hummer bird.
Because the YELP siren is simply a faster WAIL... and the PRIORITY (or PIERCE) is a faster YELP.... so it doesn't surprise me that the AIR HORN is nothing but a superfast WAIL.

The real big problem is that i will never be able to replicate it on a 12F675

Thank you

16. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0
Since it's SO fast i decided to try and program the pic with the two border frequencies (725hz and 1575hz) both at 2ms and it sounds more like the pierce tone (especially the 1575hz tone is very persistent). If i go lower than 2ms the tone stops playing.

17. ### dannyf Well-Known Member

Sep 13, 2015
1,602
314
To generate two tones alternately, it is even simpler:

Code (C):
1.
2.         TMR0 +=-(_pr_cnt&0x01)?(F_CPU / 4 / F_CARRIER0 / 2):(F_CPU / 4 / F_CARRIER1 / 2);    //load the offset
3.         IO_FLP(SIREN_PORT, SIREN_OUT);        //flip the output pin to generate the carrier signal
4.
Every 0.5 second (=1Mhz / 64K / 8), _pr_cnt is incremented by 1, which decides which offset to load in order to generate either F_CARRIER0 (1500Hz) or F_CARRIER1 (750Hz).

If you need a different frequency, just redefine the two macros and recompile.

It can also be used to generate "variable" / sweeping tones too.

The code compiles to about 100 bytes, 10% of the flash on this tiny chip.

Last edited by a moderator: Apr 8, 2016
18. ### dannyf Well-Known Member

Sep 13, 2015
1,602
314
Basically, the functionality of that big circuit board can be done by a tiny 8pdip mcu.

19. ### threepwood Thread Starter New Member

Jun 4, 2015
20
0

Mmmm do you feel like you can do that??