Society of Robots - Robot Forum

Software => Software => Topic started by: Batienzaxcore on September 04, 2012, 03:56:59 AM

Title: PWM signal for L293D and motor
Post by: Batienzaxcore on September 04, 2012, 03:56:59 AM
Not really sure where to post this... Anyway, would varying the duty cycle of a PWM output of a PIC16F877A change the speed of a high-torque DC motor? The flow of the signal would be lime this:

16F877A uC ---> L293D H-bridge ---> High Torque DC Motor

Could you help me on the programming stuff? I' not really good at it.

And another question. Could you give me advice on how a potentiometer could vary the duty cycle of the PWM? I am planning to connect the potentiometer to the one of the ADC pins of the uC, and have a toggle switch with 3 choices (forward, stop, reverse), then the uC would program the PWM signal depending on the input (My plan is 5V for forward and ground for reverse). Is it possible?

Thank you for your replies.
Title: Re: PWM signal for L293D and motor
Post by: ankitbansal on September 04, 2012, 11:46:36 AM
To control the speed of dc motor using l293d, feed the pwm wave to enable pin of l293d. You can use the 8/16 bit timer on uC to generate pwm.

To control the direction of spin use any two port pins as output and connect them to  1a and 2a pins of l293d. 1,0 would turn motor in one direction and 0,1 in other.

Based on the adc value of the pin connected to potentiometer, you can vary the timer count so that duty cycle of pwm changes and thus the speed of motor.


Hth.

Ankit
Title: Re: PWM signal for L293D and motor
Post by: Batienzaxcore on September 04, 2012, 01:28:25 PM
Did you just say, feed the pwm signal to the enable pin? Not at the input pin of the l293d?
Title: Re: PWM signal for L293D and motor
Post by: waltr on September 04, 2012, 06:19:01 PM
Yes he did. The enable pin is an Input. Check the L293D data sheet for a description of its pins and the truth table for control.

ankit's description is right on.

Now, read the PICs data sheet and google for example projects. What you want to do is very common and there is lots of info on how.
Learn to use the SIMulator in MPLAB to check and debug your code. If you really get stuck post what you have done to get help.
Title: Re: PWM signal for L293D and motor
Post by: Batienzaxcore on September 05, 2012, 07:06:03 AM
Alright :D Thanks to the two of you, especially you, Mr. waltr, who has been very helpful in my posts. Currently, I am having problems with the selection of the right motor, so I would focus on that first. Since I had a lot of time a few days ago, I decided to post here about the PWM signal, which is a rather interesting topic for me that concerns the PIC16F877A. I'm getting excited at the thought of it!  ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D.