Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

dc motor driver circuit PIC programming code...urgent help!

Not open for further replies.


Newbie level 3
Sep 15, 2007
Reaction score
Trophy points
Activity points
dc motor driver circuit

I am making a motor driver circuit using PIC16f877 microchip, dual full bridge driver L298 and L6210(diode chip)...I have been able to form a circuit but dont know how to programme my PIC chip...what i want to do is that i want to move the motor in both dirrections, depending on the input....can any one please help in giving me the PIC code to make my motor run in both dirrections using the components i have mentioned above...i will be extremely gratefull...thnx.

dc motor speed with picbasic

Check out the application notes at Microchip. There is a section on motor control. Im sure you will find something that you can adapt to suit what you need.
Full source code is provided.

pic basic sample code, dc motor control

Hi. Look here:
\**broken link removed**
\**broken link removed**

Best Regards.

dc motor speed control picbasic pro

Well PIC is quite a broad functionality chip...and its quite easy...
to program it you can even use BASIC to learn about programming in basic search the net regarding PIC BASIC PRO and you'll get the compiler...
the simple forward reverse program for a PIC in basic is as below...when key is pressed at pin 1 of PortA then it will activate the Pin 1 of PortB on which the forward pin for motor is connected and when pin 2 of PortA then it will activate then Pin 2 of PortB on which the reverse pin for motor is connected

TRISA = %00000000
TRISB = %00000000
if PORTA.0 = 1 then
PORTB.0 = 1
PORTB.1 = 0
if PORTA.1 = 1 then
PORTB.1 = 1
PORTB.0 = 0
goto loop

forward and reverse of dc motor circuit

hey guys..thnx a lot...did not expect so many people would reply:) thnx all of you for ur help....just one more thing if any one of you has some time...can any of you provide the code for controlling the speed of the motor and also for stopping it after it makes certain number of cycles...thnx a lot once again :)

dc motor drive using pic

well as you said you're using a DC Motor so...for DC Motors there quite a number of defficiencies...
1. Speed is never constant as it depends on the current which you're providing...
2. Number of rotations is also never constant as it also depends on the current...
Note: DC motors draw a huge ammount of current during that causes the above 2 reasons to occur...

now as you need to control the speed of dc motor, its not impossible but not even easy...well to control the speed of DC motor you can use a variable resistor to control the input current, but as you need to do this automatically so you need to use a MOS as it can act as a variable resistor depending on the current being provided at the gate, so for this purpose you will also need a Digital to analog convertor which will convert the digital signals from the microcontroller to variable bit pattern which will be provided to the gate of the MOS which will then act as a variable resistor and in accordance to the channel being developed between the drain and source the current will pass, this will crete a variation of speed.
and as for the number of turns is concerened so thats completely impossible to take control of the rotations as the rotations of the dc motor vary from time to time depening of whats the load and what the current being provieded...

the best soulution for motor controlling is to use a STEPPER MOTOR instead of a DC Motor as stepper motors are completely under your control for each and every pulse and by the variation of pulse you can measure the turns and the number of ratations along with the speed.

warning: stepper motors can not sustain huge loads so if yo're using the motor to drive a heavy load then the best solution is to use DC Motor but if its for a small application or demonstration then Stepper Motor is the best solution
Not open for further replies.

Part and Inventory Search

Welcome to