Driving a DC Motor with variable speed using PIC 16F877 (C language used)

Discussion in 'Embedded Systems and Microcontrollers' started by Gtofig, Feb 6, 2008.

  1. Gtofig

    Thread Starter Member

    Jan 4, 2008
    14
    0
    Hello.
    I need to programm a PIC to drive a DC Motor, using a C language (I use mikroC progamming environment). The speed will be constantly changing during the operation. Say I have a float variable X, which represents desired speed in cm/sec. I am using 2 PORTB pins as motor inputs (forward and backward motion inputs of DC motor).
    I know that this kind of things are done using Pulse Width Modulation Method (PWM), but I couldn't find any example in C language (I don't understand Basic well). Any suggestions will be appreciated.
    Thank you,
    Gtofig
     
  2. Gtofig

    Thread Starter Member

    Jan 4, 2008
    14
    0
    Note: Is it necessary to add some additional analog circuits between the PIC and the motor?
     
  3. h.d

    Active Member

    Oct 22, 2007
    150
    0
    whats your motor parameters(voltage,current,power)?
    if you work in power you need MOSFET or IGBT and trigger it by the PWM signal
    which come from thee PIC
     
  4. Gtofig

    Thread Starter Member

    Jan 4, 2008
    14
    0
    motor is weak,but exact specification are not known yet. does anyone has any examples of C code for this? Probably just writing PORTB.0 = X will not work,because X is real value, while output is just a bit. How do I do the pulse width modulation, and adjust duty cycle in the program? I know that motor speed is related to frequency of High signal of the output bit.
     
  5. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
Loading...