View previous topic :: View next topic |
Author |
Message |
KATHISAIPRATHAPREDDY
Joined: 04 Nov 2014 Posts: 3 Location: india
|
how to interface DC motor with PIC16f877a? |
Posted: Tue Nov 04, 2014 10:07 am |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Tue Nov 04, 2014 12:32 pm |
|
|
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: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Nov 04, 2014 1:31 pm |
|
|
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
|
|
Posted: Tue Nov 04, 2014 7:41 pm |
|
|
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
|
|
|
KATHISAIPRATHAPREDDY
Joined: 04 Nov 2014 Posts: 3 Location: india
|
i used 16f877a MC to control the DC motor with motor drivers |
Posted: Thu Nov 06, 2014 6:42 am |
|
|
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: 19545
|
|
Posted: Thu Nov 06, 2014 7:12 am |
|
|
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. |
|
|
|