how to calculate 1khz frequency to pulse

Status
Not open for further replies.
hi,
If I understand your question correctly, there are 1000 pulses/sec in 1Sec of 1kHz.

E
 

If it is 1 KHz AC signal like sine wave or saw tooth then if you represent +ve half cycles by pulses then freq will be 1KHz. You can use ZCD. When signal first crosses zero then a pulse is formed that is goes high and at the next zero cross it goes low. This way freq will be 1 KHz only. On every zero cross you toggle between 0 and 5V.
 

I use the formula to generate the desired frequency:
F=(1/T)
And result divide by 2 for time ON and time OFF for 50% duty cycle.

Ex: 1.000Hz = (1/1000)/2 = 0.000.5s

Time = 500us

In pic CCS is:

Code:
void main(void) {
    while(TRUE) {           // Produces a 1khz square wave on pin B0
        output_high(PIN_B0);
        delay_us(500);
        output_low(PIN_B0);
        delay_us(500);
    }
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…