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 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