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

Thread Starter

Gtofig

Joined Jan 4, 2008
14
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
 

Thread Starter

Gtofig

Joined Jan 4, 2008
14
Note: Is it necessary to add some additional analog circuits between the PIC and the motor?
 

h.d

Joined Oct 22, 2007
150
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
 

Thread Starter

Gtofig

Joined Jan 4, 2008
14
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.
 
Top