Differential Drive Programming


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shaiqbashir View Post
    Thanks a lot for all ur help!

    @skimask:

    Thanks for that idea ! Well! surely i have written up my own code as well, that dint work so i have asked on this forum to provide me some help. I do admit my mistake that i dint provide my own code here: Well! This is what i have tried to do:

    I have used PIC16F84A here. I havegot two motors. So two h-bridges surely.Now in each H-bridge, there are 4 inputs to be controlled logically:

    1) Left P-channel MOS
    2) Left N-channel MOS
    3) Right P-channel MOS
    4) Right N-channel MOS

    now u see, if i take one H-bridge into my consideration. I can ON the pin containing Left P-channel MOS using HIGH command. then i can OFF the pins containing Right P-channel and Left N-CHannel MOSFETs using LOW command. When i apply PWM command on the port containg Right N-channel MOS, the H-bridge works and the motor rotates in one direction. So i say that my H-bridge is controlled by PWM command now.

    Now comes the tricky part:

    Now i have to drive the second H-bridge simultaenously as well. In PIC16F84A, there is only one PWM present. So what i decided to do is simply this that i connect run the second H-bridge totally by HIGH and LOW commands. I dint give any PWM command in the second H-bridge at all. Like I ON the Left P-channel and Right N-channel using HIGH command. I OFF the Right P-channel and LEft N-channel using LOW command. The motor runs in one direction as well.

    What i had in my mind at that time, that i would first see that which of my motor is a faster one, Then i would use PWM command with the faster motor and will control the slower motor with HIGHs and LOWs only. So that i can reduce the speed of the faster motor through PWM command in order to make the speed of both motors equal so that my robot can go straight.

    This is what my logic was, but dont know what it doesnt work. That is the reason whay i have asked u guys! Do u guys see any major flaw in this logic?

    What are ur ideas to control this sort of mechanim?

    Mr. Skimask! once again thanks for providing this code, but i do require some more explaination in order to understand this code. Like plz tell me how can i vary duty cycles in this?

    I would be thankful to you if u plz provide some detailed explaination of this beautiful code.

    Thanks in advance!


    Read my post.......again.......slowly.......including the comments.......
    Almost everything you need is right there in my post; left and right drive pwm values and a loop to make the pwm, a method for channel specific complementary drive (for drive 2 sets of 2 MOSFETs connected to 2 different channels). There's nothing tricky about what you're trying to do. It's been done, a lot, a whole lot, since the beginning of time, if not before...

    And if you think you're going to find 2 perfectly matched motors that you can drive with an equal PWM signal/current, and get exactly the same RPM from both, under varying load conditions (floor surface, battery voltage, inclination, etc), well, I'm here to tell you, the world isn't that perfect.

    You'd better design some sort of optical input or something to detect wheel speed and modify your PWM to compensate, and even then, an optical input is going to be a reactive system (i.e. the wheels start turning at different speeds, you speed one or the other up to compensate, too late, the 'bot has already turned somewhat).

    What are YOUR ideas?

  2. #2
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    A bundle of thanks to u Mr. Skimask!

    Now i have understood your coding. Thank u very very much!

    As far as i have understood is this that let us suppose that the Left motor is having a speed that is double than the right motor, so we have given it more duty cycles i.e. 50 While the right one is giving a duty cycle i.e.25.

    Isnt that?

    That is really a very good idea to control the differential Mechanism.

    But one point that you made in your last post and that is that OpticaL Encoders sometimes donot prove to be enough faster in reacting than required. What if my robot speed is around 50RPM (i.e. quite slow) and i used a 10bit degree Optical Encoder, ?? I dont think it will be very slow in reacting? what do u say?
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

  3. #3
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default I do not fit here

    Hi All,

    I really do not fit in this thread cause I have no experience in robotics but perhaps can share some view.

    Creating a complementary output just by inverting the PWM out pin and feeding one part.

    1. If you are driving a H-bridge then applying a 50% duty doesn't move motor.

    2. Anything less than 50% or greater than 50% would result in motion in either directions. Speed prportional to duty cycle.

    3. Shutting down both half causes braking.

    Darrel has done a Multiple Soft PWM stuff. Find it here http://www.pbpgroup.com/modules/wfse...p?articleid=12 . It can be easily adopted to get complimentary outputs. Also possible to include dead times.

    Only the PWM freq cannot be high (if you have other tasks to do in between, you run out of cycles). However for a two channel version it should work with some audible noise from the motor. Don't blame me if you burn one.
    Regards

    Sougata

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi All,

    I really do not fit in this thread cause I have no experience in robotics but perhaps can share some view.

    Creating a complementary output just by inverting the PWM out pin and feeding one part.

    1. If you are driving a H-bridge then applying a 50% duty doesn't move motor.

    2. Anything less than 50% or greater than 50% would result in motion in either directions. Speed prportional to duty cycle.

    3. Shutting down both half causes braking.

    Darrel has done a Multiple Soft PWM stuff. Find it here http://www.pbpgroup.com/modules/wfse...p?articleid=12 . It can be easily adopted to get complimentary outputs. Also possible to include dead times.

    Only the PWM freq cannot be high (if you have other tasks to do in between, you run out of cycles). However for a two channel version it should work with some audible noise from the motor. Don't blame me if you burn one.
    Exactly...software pwm, run as many channels as you have cpu time to handle, at any rate.

    Complementary PWM - exactly! Easy to do with software PWM, one bit mirrors the other...

    Very easily done. Not hard to grasp...

  5. #5
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    That was just superb!

    I got it now how to deal with Software PWMs. Thanks a lot all of u!

    Now can anybody tell me that how would i determine that what frequency do i need to supply in order to run my motor correctly. I mean what is the effect of frequency on motor?

    e.g:

    if i apply a pWM of freq 100Hz to a motor

    and then apply a PWM of freq 1000Hz to the same motor.

    What will be the difference between the two?
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shaiqbashir View Post
    That was just superb!

    I got it now how to deal with Software PWMs. Thanks a lot all of u!

    Now can anybody tell me that how would i determine that what frequency do i need to supply in order to run my motor correctly. I mean what is the effect of frequency on motor?

    e.g:

    if i apply a pWM of freq 100Hz to a motor

    and then apply a PWM of freq 1000Hz to the same motor.

    What will be the difference between the two?



    900 Hz.....

  7. #7
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    haha Skimask!

    that was superb Intelligence.

    WEll! Im asking about the effect actually.

    I want to know what is the effect of frequency over the running of a DC motor.

    Does increase/decrease in frequency affects the Running of the motor?
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shaiqbashir View Post

    But one point that you made in your last post and that is that OpticaL Encoders sometimes donot prove to be enough faster in reacting than required. What if my robot speed is around 50RPM (i.e. quite slow) and i used a 10bit degree Optical Encoder, ?? I dont think it will be very slow in reacting? what do u say?
    Why would an optical encoder be slow? Does light travel slower through an optical encoder? Did I miss something in physics class?
    If you've got a slotted wheel, 1 inch in diamater with 10 slots in it and it rotates once per second, you'll get 10 pulses per second, or once pulse for every .31415926535897932384626433832795 inches travelled. If you get 90 pulses from the left wheel and 100 pulses from the right wheel, either you slow down the right, or speed up the left. Or you start driving both at the same time with the same pulse width, the left wheel gets 10 counts before the right wheel, so you slow down the left wheel a bit and speed up the right wheel until the counts are equal again, keep rechecking and rechecking...

Similar Threads

  1. Data Programming Error at 0000
    By cpatnoi in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd May 2009, 03:37
  2. Problems programming
    By Lionheart in forum General
    Replies: 4
    Last Post: - 7th December 2008, 16:51
  3. MPASM Path & File Name Length Limtation
    By Brian J Walsh in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th June 2008, 15:48
  4. Telescope drive motors that don't...
    By Dodgy Geezer in forum General
    Replies: 68
    Last Post: - 12th April 2008, 02:05
  5. Seeking Help With Programming PIC16F688
    By gzayzay in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th March 2006, 03:32

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts