Shop OBEX P1 Docs P2 Docs Learn Events
DC Motor control — Parallax Forums

DC Motor control

I am trying to control 2 dc motors (KEDA 1000 v brushless ) using an H-Bridge Dual motor drive MC 33926 but can't figure out the wiring. There are 3 leads from the motor so not sure where they go, the Parallax tutorial just seems to cover the Arduino board examples. I also bought a Parallax X Rotor 20 A Electronic Speed Controller but again can't find any wiring or code examples. Any help would be appreciated, thanks.
«1

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2018-02-18 20:47
    The H-bridge drive is designed for brushed DC motors or steppers and won't work with your motor. The Parallax ESC is the one you want to use. The red and black wires go to your battery. The three sockets at the end go to your motor. You will need to crimp bullet connectors onto your motor leads to make the connections. The black/white twisted cable goes to your servo output (either an RC receiver or your microcontroller): black to ground, white to the control output. If, when you control the motor, it turns in the opposite direction of the one you want, swap any two of the motor wires connected to the ESC.

    -Phil
  • Thanks Phil, I will give it a shot.
  • I plugged the motor to the Parallax ESC and ran the red and black leads to a 9 volt battery and the black and white leads to my Board Of Education (Rev D). Next I ran the following program but all I got was a musical tone and a slight movement of the motor. I then replaced the motor and ESC with a Parallax Standard Servo and the motor responded properly. I think I am on the right path but have hit a roadblock here, any help would be appreciated.
    Here is the program:
    'Program Name ServoTest.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    counter VAR Word
    DEBUG "Counterclockwise 10 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 1000
    PAUSE 20
    NEXT
    DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 500
    PAUSE 20
    NEXT
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 750
    PAUSE 20
    NEXT
    DEBUG "All done."
    END
  • A 9 volt battery probably will not cut it. The is very little current to move the motor. You need a 2 cell or better yet a 3 cell Li-Po battery.

    Also see this:
    Eureka!!! With some tests I found out that the pulse width had to be above 800 for my ESC to recognize it. I tested from 800 to 1500. With 1500 not being a good idea because I drained the heck out of the battery. I am going to charge it for a few hours and run some other tests.

    Make sure your connections are like this, (Reciever is replaced by your BOE)


    ESC%20connection.JPG
    640 x 262 - 29K
  • Thanks!!
  • I am wanting to get a chassis with two 9v dc motors. Should I use this technique, or relays to provide and cut power?
    https://smile.amazon.com/Tracked-Platform-Aluminum-Chassis-Arduino/dp/B0746FYXYQ/ref=pd_rhf_dp_p_img_4?_encoding=UTF8&psc=1&refRID=W7EC75F1GS193HX8RV3P
  • kwinnkwinn Posts: 8,697
    The ESC gives you much finer control over the power going to the motors than the simple on/off a relay does.
  • Thanks!
  • GenetixGenetix Posts: 1,740
    edited 2018-04-13 20:05
    AwesomeCronk,

    An ESC is a lot more efficient than a relay especially when you are using batteries that have a limited energy capacity.
  • Here is a good ESC for a good price. Remember to purchase an ESC for Brushed motor, not Brushless

    https://hobbyking.com/en_us/turnigy-20a-brushed-esc.html
  • You could also use the Parallax dc motor controller as well. It works up to 3 amps: Dual Motor Driver MC33926

    I have used it on 6 volt tank I had laying around. Worked great.

    Mike
  • Alright, then.
  • Snagged a sweet pack of DC motors on Amazon. 1.5-6v and 24,000 RPM! These could theoretically be driven directly from the IO pins on a Stamp or Propeller, right?
  • Mike GreenMike Green Posts: 23,101
    edited 2018-05-30 17:06
    Probably not. The issue is the amount of current drawn. Even though the motors are rated at the same voltage as used by the Stamps (5V) and the Propeller (3.3V), most logic gates, including the I/O pins of pretty much all microcontrollers, can only output 20-30mA. This is enough to light an LED or drive a low-current relay coil, but not much else. In addition, I/O pins are usually arranged in groups of 8 and there are separate maximum current limits for these groups and for the device as a whole.

    There are all sorts of buffers that can be driven by an I/O pin and can, in turn, handle currents on the order of 1A. Parallax sells the 2N3904 NPN transistor which can handle up to 200mA. Look at the Nuts & Volts Column #6 for examples. You'll also need what's called a flyback diode, something like a 1N4001. This prevents the collapsing magnetic field of the motor (when it's switched off) from frying the transistor and maybe the microcontroller too as a reverse voltage spike is produced by the motor windings.
  • AwesomeCronk,

    No, the I/O pin does not source enough current to drive a motor directly and since a motor is inductive the kickback voltage may damage the I/O pin transistors.

    An L293D can control 2 motors in both directions and protective "kickback" suppression diodes are built into it.
  • Thank you Mike and Genetix. I will look into both of these options, and find what works best. Looking at building a 6-engine model plane or a very small rc car.
  • AwesomeCronk,

    Most likely those are toys motors which are not as efficient or durable as an R/C motor.
  • With bottle-cap tires(with rubberbands and rubber cement for traction), est. 0.75 in. dia. That's about 2.4 in circumference, so you would travel about 2.4 in per rotation. I'm going to say 15,000 rpm(about 1,500 under max.), so that's 36,000 inches traveled in a minute. 6,000 in. per second. I'm thinking that there is better, safer work for these guys in r/c planes.:smile:
  • What sort of DC motor driver should I get for these? I would like to be able to run speed(to a degree) and direction.

    https://smile.amazon.com/Topoox-15000-16500RPM-Electric-Science-Experiments/dp/B073Q2Y3RC/ref=sr_1_5?ie=UTF8&qid=1527801381&sr=8-5&keywords=dc+motors
  • AwesomeCronk,

    According to the seller (Questions and Answers) the rated current is 0.2 A, the no-load current is about 67 mA, and the stall current is 0.4 A.

    The L293D is rated for 600 mA.
    You control the direction by reversing the polarity of the power source.
  • You reverse the polarity of the power source by using an H-Bridge driver. The L293D has 4 half bridges in it which you can use to control two separate reversible motors (see the link to the L293D datasheet on that page).
  • cavelambcavelamb Posts: 720
    edited 2018-09-17 18:28
    ...
  • cavelambcavelamb Posts: 720
    edited 2018-09-17 18:28
    ...
  • Sorry to be a pain here but still not getting results, I have increased the battery to 12volts with 4.5 amps (lead acid rechargeable) but still get a musical tone and the motor twitches slightly. The question I have is where the 2 leads ( black and white) go to. Most diagrams show 3 leads red, black and white which is the signal. If the white lead is signal then what does black connect to. I checked the Xrotor website but no wiring diagrams are shown.
  • Bob2bot wrote: »
    Sorry to be a pain here but still not getting results, I have increased the battery to 12volts with 4.5 amps (lead acid rechargeable) but still get a musical tone and the motor twitches slightly. The question I have is where the 2 leads ( black and white) go to. Most diagrams show 3 leads red, black and white which is the signal. If the white lead is signal then what does black connect to. I checked the Xrotor website but no wiring diagrams are shown.

    You need to share a lot more information.
    A link to the motor model.
    A link to the motor controller model.
    What micro controller are you using?
    What code are you using?
    A picture of the setup would help immensely.
  • I am using a KEDA 1000 kv brushless motor (Parallax # 750-90015) connected to a Xrotor ESC (Parallax # 750-90015) via a Board of Education Rev D. I plugged the ESC leads into the servo plug at the top but since there are only 2 leads on the ESC this is the part that is confusing since a standard servo has 3 leads. Please see code below, it works fine for a servo but not a brushless motor.

    'Program Name ServoTest.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    counter VAR Word
    DEBUG "Counterclockwise 10 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 1000
    PAUSE 20
    NEXT
    DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 500
    PAUSE 20
    NEXT
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 750
    PAUSE 20
    NEXT
    DEBUG "All done."
    END
  • PublisonPublison Posts: 12,366
    edited 2019-04-18 16:56
    Bob2bot wrote: »
    I am using a KEDA 1000 kv brushless motor (Parallax # 750-90015) connected to a Xrotor ESC (Parallax # 750-90015) via a Board of Education Rev D. I plugged the ESC leads into the servo plug at the top but since there are only 2 leads on the ESC this is the part that is confusing since a standard servo has 3 leads. Please see code below, it works fine for a servo but not a brushless motor.

    Firstly, I can see your confusion with the two wires on the ESC. That ESC does not have a BEC, (Battery Elimination Circuit), which normally feeds power to a Flight Controller through a Red wire. The Black is Ground, and the White is signal.

    Second, the components you have will only do continuous rotation. You can not command a rotation angle. The Pulse Out commands will determine the speed of rotation.

    Hope that helps.
  • See if this program produces continuous rotation at one speed.
    'Program Name ServoTest.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DO
      DEBUG "Continuous", CR
      PULSOUT 14, 1000
      PAUSE 20
    LOOP
    
  • I get a musical signal from the motor and can see the word continuous repeated in the debug terminal window but no rotation. I have a connection from the white wire to pin 14 and the black is connected to ground (VSS).
Sign In or Register to comment.