Continue to Site

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.

DC Motor control using PIC16F877 & L298 (Motor driver)

Status
Not open for further replies.

sk.shawn

Junior Member level 3
Junior Member level 3
Joined
May 4, 2008
Messages
30
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,689
l298 motor driver

Hi all,

I'm trying to control a simple DC motor using a motor driver chip (L298) through programming the PIC16F877 microcontroller.

I'm trying to come out with a simple code which will move the motor by a quarter with respect to its initial position and then stops. I need this motor movement to be implemented on my carpark barrier prototype where the barrier will open (through the motor's quarter movement) upon receiving an input activation through a push button.

The difficulty lies in the part of controlling the motor to just move by a quarter. No matter what I do, the motor still moves more than a quarter. However, I noticed a change in the speed though.

I have attached by code. Hope you guys will take a little of your time to help me with this and advise me on how I should go about achieveing this motor control.

Really thanks for the help and apologies for the long text!

Regards
Shawn
 

dc motor controller using pic16f877

You forgot to post your code in your thread. Please do it,
I would suggest you to go for stepper motor, which can be used with L293D, or ULN 2803 easily. Why are you specific with dc motors. You always face the problem with DC motors.
 
l298n control dc_motor

Need to know:
Voltage of motor
Interfacing
Feed Back etc ...
In all a drawing of the installation that has to be commanded
You need STOPPING and CLOSE to STOPPING PLACE sensors to reduce the speed at approach to allow a near instantaneous stop at STOPPING sensor and this on EACH SIDE of the travel

Otherwise a stepper motor would be adequate as they stop directly

1/sensors stopping
As you would only start stop signalling without counting the steps no need to check acceleration
2/counts travel
If you use steps (amont of travel limiting)counting,
you must be carefull to startslowly to avoid missing moves at the start ...:D
 

l298 motor controller

Thanks guys for the reply. Sorry for the miss out on the attachment. I cant seem to attach the file properly into the thread. So here's the code in raw below. My apologies for the inconvenience.

With regards as to why a DC motor was chosen, and that would be due to cost. I'm doing a project now and we have limited money to spend on. So, I kinda wanna implement this using a DC motor. It's a 12V DC motor.

Please feel free to let me know if you guys require more information. I really hope to acquire a solution to this. Been trying for the past 3 days with no success.

Thanks again for the help guys!

Regards
Shawn

/*****************************
Description:
It's a simple program attempting to move the motor by a quarter
through controlling the for loop count. However, it doesnt work.
Even after reducing the count value to 3 which is the lowest to achieve a minimum
possible motor movement. The motor still makes more than a quarter turn. So I'm stuck!
****************************/
#include "io16f877.h"
void main(void)
{

long int i=0;

ADCON1=0x07;
TRISA = 0xff;
TRISB = 0x00;


PORTB = 0x00;


RB0 = 1; //Enable The Motor
RB1 = 0; // Logic needed for no motor movement
RB2 = 0;

while(1) //Main Infinite While Loop
{


if(RA0==1) //button press detected
{
for(i=0;i<3;i++)
{

RB1 = 1; // Motor moves in one direction. The key is here. Tried reducing the for loop count to achieve less motor movement. But it still cant do it.
RB2 = 0; // The motor still moves more than a quarter
}



RB1 = 0; // Motor should stop moving if it makes a quarter of revolution
RB2 = 0;
}

}

}
 

l298 dc motor control

yOUR CODE CANNOT DO THE JOB AT ALL !!
It relies only on a time ON to position the ARM
The final position will be depending on the power supply,
the outside temperature, the dirt on the system the lubrication of the system, the time the button is pushed ...

As I explained in the first part,if the motor is a free running DC motor You must have TWO switches sensing the position of the arm against the end of travel,one Close to the end slowing down the motor the other one at the end.
That implies a speed control with PWM or other way.

To use only one switch to sense the arrival at the end one possible way of "braking"is by shorting the armature or using a windscreen motor that locks itself as soon as it is stopped.

Symbolic code:

OPENING
If pushbutton_open then//open
direction_open =1//relay forward
If stop_open then
direction_open=0
//the motor stops dead as it is a wind screen wiper motor

CLOSING
If pushbutton_close then //close
direction_close=1//relay reverse
if stop_closed=1 then
DIRECTION_CLOSE=0

tHIS IS THE SIMPLEST WAY WITH A DC MOTOR

The really good way is using a stepper motor
COUNTING THE NUMBER OF STEPS FORWARD OR REVERSE
 

l298 motor

Thanks gebepic!

It seems quite hard for me as I really have no experience in motor handling. I understand your point about the issue of introducing sense control and everything. However, I really need extra support in terms of knowing the hardware needed to hook up this and perhaps any sample codes if possible.

I'm just thinking if you do have any recommended sites which I can visit and read up more on. Really appreciate it!

In addition, I would like to show you my hardware setup. It's a simple hardware which I have no clue about including the sensing feature. Hope you can advise me further.

If all else fails, I guess I would have to turn to using a stepper motor which I'm trying to avoid due to budget constrains.

Anyway, thanks a million for your support again!

Regards
Shawn
 
  • Like
Reactions: xiexin

    xiexin

    Points: 2
    Helpful Answer Positive Rating
l298 dc motor

Hi,
With open loop control it is difficult, but however, you can try with a voltage less than 12V to get better control at low speed.

Regards,
Laktronics
 

l298 motor control

Here is the tentative "drawing" and the Picsimulator ide basic code .for 16F 676 adapt it to the 877
 

dc motor control using l298 with pic16f628

**broken link removed**
http://matthieu.benoit.free.fr/moteur2.htm
**broken link removed**

the 3rd will will give you complete solution I hope. Do come back after this, with the result and share it with everyone
 

    sk.shawn

    Points: 2
    Helpful Answer Positive Rating
start button stop button control motor 16f877

These are for sure very good links .
That beats my quick and dirty solution.
Although thanks are frowned upon ,this time calls for an exception

A BIG THANKS.:D

gebe
 

    sk.shawn

    Points: 2
    Helpful Answer Positive Rating
l298 motor driver

Guys,

Really thanks. I'm working on it currently. If I do get it working, will definitely post and share with all of you.

It's great to have you guys helping others!

Regards
Shawn
 

motor control using l298

A better one Working and tested on simulator modules as per enclosed pictures Comprehensively commented source in Basic is enclosed in folder.

gebe

Source was the old one will fix and put back here

Done
 

    sk.shawn

    Points: 2
    Helpful Answer Positive Rating
pic16f877a motor controller codes

heY dearz!!

i wanna control 4 Dc motors by using Pic 16f877 in a quad rotor helicopter..what will be the schematic for dat Morever if code is available then write there...

usman .A. Khan
 
pic16f877a motor control

D.C. motors:
**broken link removed**
or
Steppers:
**broken link removed**

<als>
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top