CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

how to interface DC motor with PIC16f877a?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
KATHISAIPRATHAPREDDY



Joined: 04 Nov 2014
Posts: 3
Location: india

View user's profile Send private message

how to interface DC motor with PIC16f877a?
PostPosted: Tue Nov 04, 2014 10:07 am     Reply with quote

Is there any special .c file for motor interface. Can we write our own .h file to compile the motor programs?
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Nov 04, 2014 12:32 pm     Reply with quote

You need to provide more information:
Do you want to control just run/stop or variable speed?
Do you want forward and reverse?
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



Joined: 01 Jul 2010
Posts: 9101
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 04, 2014 1:31 pm     Reply with quote

What kind of motor?
AC
DC
VFD
1PH
3PH

What kind of 'control'
feedback ?
encoder?
RC servo?
protection?
over V, over I, etc.


There's probably 3 or 4 dozen answers needed before a real answer can be acquired.


Jay
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Nov 04, 2014 7:41 pm     Reply with quote

Why does this sound like a homework assignment?

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 04, 2014 9:47 pm     Reply with quote

Use the LMD18200 H-Bridge chip. Use PWM from the 16F877A to drive it.
Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=40467&start=1

Buy or build a board with the LMD18200 chip on it:
http://www.electrokit.com/en/dc-motor-control-based-on-lmd18200.47375
Use the 16F877A to control it.
KATHISAIPRATHAPREDDY



Joined: 04 Nov 2014
Posts: 3
Location: india

View user's profile Send private message

i used 16f877a MC to control the DC motor with motor drivers
PostPosted: Thu Nov 06, 2014 6:42 am     Reply with quote

I failed to write a program to control the dc motor to move forward, backward, left, and right. Also i want to control the speed of motor.
My project need to detect the object, and it will act on the object. My program follows like this:
Code:

#include <16f877a.h>
#use delay(clock=20M)
#fuses NOWDT,PROTECT,HS
#include <motor.c>


Void main()
{
unsigned int i, value, temp,gas;
output_high(pin_d2);
output_high(pin_d3);
delay_ms(500);
output_low(pin_d2);
output_low(pin_d3);
delay_ms(500);
output_high(pin_d2);
output_high(pin_d3);
delay_ms(500);
output_low(pin_d2);
output_low(pin_d3);

   
while(1)
{

      for(i=0;i<=10;i++)
      {
       set_adc_channel( 0 );
       
      delay_ms(50);
     
      value = read_adc();
     
      temp = value*2.5;
     
     

      motor_forward();
      output_high(pin_d3);
      output_low(pin_d2);
      output_low(pin_d7);
      delay_ms(500);
      if(input(pin_b0))
      {
      motor_right();
      output_high(pin_d2);
      output_low(pin_d3);
      output_low(pin_d7);
      }
      else if (temp > 50 )
      {
      output_high(pin_d7);
      output_high(pin_d2);
      }     
      else
      {
      output_low(pin_d2);
      output_low(pin_d7);
      }
}
}


But i have problem while compiling the code in pic c compiler. Can anyone help me? Basically the problem is with motor.c file. Can we write motor.c by our own or somewhere else ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19218

View user's profile Send private message

PostPosted: Thu Nov 06, 2014 7:12 am     Reply with quote

Controlling a motor depends totally on _your_ hardware. Nothing else.

Motor.c, is nothing but functions to turn on the bits needed to control the motor hardware, which depends totally on _your_ design. So if (for instance), you have an H bridge driver as already described, you need to turn on the top FET on one side, and the bottom FET on the other to feed power 'forwards', for 'motor_forwards', and if speed control is wanted feed a suitable signal out of the PWM. The reverse code requires the opposite pattern. This is all 100%, down to _you_, and _your_ hardware. There is no universal solution to motor control, and yes 'of course' you can write the code yourself, but you need to have worked out what you actually need out of the pins, and what dangers there are (remember your driver will also need to handle things like the inductive nature of the motor, and generation when it is spinning, and you turn off). These are all electronic _hardware_ questions, and nothing to do with code. You need to get your hardware working _first_, and then work out what is needed from the PIC to control this.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group