Change PIC frequency

Discussion in 'Embedded Systems and Microcontrollers' started by PIC GUY TREVOR, Aug 8, 2009.

  1. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    Hi All

    I have a question about a 12V Dc Motor project I am undertaking at school. I am using a PIC 16F84A and all I need to do is change the output frequency from the chip to 2kHz to the motor. I have looked in Microchip and searched the forum but I must be looking in the wrong places. Just need a little push in the right direction.

    Thanks
     
    Last edited: Aug 9, 2009
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Which programming language are you using?

    If you will control the speed of the motor with PWM I suggest you to use a frequency of 20 kHz instead of 2 kHz because with 2 kHz you will hear a buzzling sound from the motor.
     
  3. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    I am using MPLab as the assembler, Im just following the specs of the circuit re the frequency. If I adjust the duty cycle that will help solve my problem ?
     
  4. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,683
    900
    Since you are using the16F84A and MPLab, let's assume you are using assembly language. In the code somewhere, you will be generating a PWM signal. Basically, a pin will be made high, there will be a delay, the pin will be made low, there will be another delay, and so forth. The cycle will repeat endlessly.

    The ratio of the "on" delay to total delay will give you the duty cycle, and the total delays will give you the frequency of the PWM. Generally, you do not need to change the frequency of the microcontroller.

    If still confused, please post your code.

    John
     
  5. fanie

    Active Member

    Jan 20, 2007
    63
    0
    Though you may not hear the frequency at 20kHz, you may want to see how the motor react first, then maybe use a different frequency. If the inductance of the motor cause resonance you may want to change the frequency.
     
  6. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    What will be the effects of reasonance?
     
  7. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    Thanks I figured it out last night, I found some more tips at Microchip and experimented with my code a little.
     
Loading...