Analyzing osc frequency

Thread Starter

threepwood

Joined Jun 4, 2015
20
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.

Thank you in advance
 

wayneh

Joined Sep 9, 2010
17,496
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.
 

Thread Starter

threepwood

Joined Jun 4, 2015
20
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.
 

wayneh

Joined Sep 9, 2010
17,496
... and i don't have an oscilloscope...
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.
 

dannyf

Joined Sep 13, 2015
2,197
At the moment my best attempt was to use 2 alternate frequencies (2000hz and 0hz)
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.
 

Thread Starter

threepwood

Joined Jun 4, 2015
20
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:

dannyf

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

C:
    TMR0 +=-(F_CPU / 4 / F_CARRIER / 2);    //load the offset
    //_mod_cnt--;                                //decrement counter
    if (--_mod_cnt==0) {                        //sufficient time has elapsed
        _mod_cnt=F_CARRIER / F_MOD;            //initialize the counter
        IO_FLP(SIREN_DDR, SIREN_MOD);        //flip the modulating pin to alternate between run and not run
    }
    IO_FLP(sGPIO, SIREN_OUT);                //flip the output pin to generate the carrier signal
    SIREN_PORT = sGPIO;                        //output the shadow variable to port
So the answer to your question is, yes.
 
Last edited by a moderator:

dannyf

Joined Sep 13, 2015
2,197
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.
 

AnalogKid

Joined Aug 1, 2013
10,987
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
 

Thread Starter

threepwood

Joined Jun 4, 2015
20
I did a little experiment. The following code, running at 1500Hz carrier signal, consumes about 10% of the 12f675's processing power.

C:
    TMR0 +=-(F_CPU / 4 / F_CARRIER / 2);    //load the offset
    //_mod_cnt--;                                //decrement counter
    if (--_mod_cnt==0) {                        //sufficient time has elapsed
        _mod_cnt=F_CARRIER / F_MOD;            //initialize the counter
        IO_FLP(SIREN_DDR, SIREN_MOD);        //flip the modulating pin to alternate between run and not run
    }
    IO_FLP(sGPIO, SIREN_OUT);                //flip the output pin to generate the carrier signal
    SIREN_PORT = sGPIO;                        //output the shadow variable to port
So the answer to your question is, yes.

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:

Thread Starter

threepwood

Joined Jun 4, 2015
20
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
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 :(

But i appreciated your explaination.
Thank you
 

Thread Starter

threepwood

Joined Jun 4, 2015
20
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.
 

dannyf

Joined Sep 13, 2015
2,197
To generate two tones alternately, it is even simpler:

C:
        TMR0 +=-(_pr_cnt&0x01)?(F_CPU / 4 / F_CARRIER0 / 2):(F_CPU / 4 / F_CARRIER1 / 2);    //load the offset
        IO_FLP(SIREN_PORT, SIREN_OUT);        //flip the output pin to generate the carrier signal
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:
Top