PIC programming help

Discussion in 'Programmer's Corner' started by bathini, Feb 1, 2009.

  1. bathini

    Thread Starter New Member

    Jan 25, 2009
    8
    0
    Hello

    I am having issues programming my PIC16F627. The deal is its a 4 bit PWM which needs to be simulated on a mplab simulator(will build later the circuit). I am simply getting a 50% duty cycle. I want to vary the duty cycle either through the simulator or maybe changing the values of the switch input.I have attached the code. Thanks

    Bathini
     
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    If you read the datasheet of the PIC at the part about PWM it says exactly you do you need to vary to set the PWM duty cycle.
     
  3. bathini

    Thread Starter New Member

    Jan 25, 2009
    8
    0
  4. bathini

    Thread Starter New Member

    Jan 25, 2009
    8
    0
    Alberto
    Thanks for your reply. My pic is running at 50KHz. I will revise your code and include it to see whether it will work for me.

    Bathini
     
  5. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    50KHz is too slow for the PIC!
    What is your application?
     
  6. bathini

    Thread Starter New Member

    Jan 25, 2009
    8
    0
    Hi Mik3

    Well, my application is decoder controller. The motor I am trying to control is a model train control which is a small control. Here is the circuit I have built http://home.cogeco.ca/~rpaisley4/HBridge.html - The last comparator circuit Motor/Decoder

    It works but now I have to control it with 4 digital input for speed and probably also direction.That will be the 5th bit and later.

    Thanks

    Bathini
     
Loading...