Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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.

PIC16f877 programming code for motor driver circuit

Status
Not open for further replies.

rajamana85

Newbie level 3
Joined
Sep 15, 2007
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,315
pic16f877 digital to analog

hello,
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.
 

jamshid.dastur

Member level 4
Joined
Sep 14, 2007
Messages
77
Helped
15
Reputation
30
Reaction score
5
Trophy points
1,288
Activity points
1,829
programming pic16f877

Well PIC is quite a broad functionality chip...and its quite easy...
to program it you can even use BASIC to program...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
loop:
if PORTA.0 = 1 then
PORTB.0 = 1
PORTB.1 = 0
endif
if PORTA.1 = 1 then
PORTB.1 = 1
PORTB.0 = 0
endif
goto loop
end
 

rajamana85

Newbie level 3
Joined
Sep 15, 2007
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,315
well jamishid thnx a lot bro...really appreciate ur help...believe me the simple code u provided did help me a lot....
I have another small problem on the same thing...I want to control the speed of the motor and also want to stop it after it malkes certain number of cycles...Can u provide me with the sode of how to control the speed and the number of cycles if you have time? thnx alot once again man.
 

jamshid.dastur

Member level 4
Joined
Sep 14, 2007
Messages
77
Helped
15
Reputation
30
Reaction score
5
Trophy points
1,288
Activity points
1,829
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 start...so 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
 

srinu249

Member level 1
Joined
Apr 10, 2010
Messages
34
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Location
Hyderabad,INDIA
Activity points
1,495
OK Using PIC and L293 driver.. u can build a ciruit.
If u able to develop a circuit for that ... just send ur circuit....

other wise u get it from through net. so decide on whch ckt ur implementing the code...

so that i can help u...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top