Skip to main content

I'm headed into uncharted territory and need some help with using Arduino to control two DC motors.

I think my components include:

  • Arduino Uno or Nano with an L298 and two axis resistive joystick controller
  • Pololu #1595 1000:1 ratio micro metal gearbox HP 6V



My main question is whether or not I can use the L298 to make two motors spin at the same speed at exactly the same time. Can I use the L298 and Arduino Uno to spin each motor at the same speed at the same time? Each motor would be driving a wheel in this application and they have to move in perfect unison so the vehicle doesn't bind on its rails. I'm sure this question is an obvious yes but I'm in the beginning stages of this project and don't want to start by assuming instead of confirming.

My second question is what benefit do I get some using the Pololu 3081 encoder? As I understand it, I can read the pulses (steps?) with my Arduino to detect my position along the path. Does this mean I can set a range for how many revolutions the motor can make (and therefore how far the vehicle can travel)?

I have not looked at or figured out if an Arduino Uno/Nano with an L298 can drive one or two Pololu 1595's or understand input from the 3081 encoder. I'll figure that out once I know if I can control two motors in sync.   

Last edited by BillYo414
Original Post

Replies sorted oldest to newest

I am interested in following your progress with this project.

This reply has to do with the use of an encoder with an Arduino Uno.

I have written code to test the Arduino reading an encoder and have found that the Arduino isn't fast enough if the encoder is turning fast, It only worked if the encoder was turning very slow.

I found a solution using an encoder library that uses interrupts on the encoder inputs. This library and information is available at https://www.arduinolibraries.i...aries/rotary-encoder.

My test project used an encoder to generate speed commands to a TPC module via a software serial port to control track power. A block diagram of this project is attached.

A sketch for the Arduino to test the encoder library code is also attached. This sketch prints test results to the Serial Monitor using the hardware serial output.

Speed Encoder Diagram

Attachments

Images (1)
  • Speed Encoder Diagram
Files (1)

@David Nissen I'm embarrassed to say I don't know what my speed will be. I was thinking about it on a long car ride home today and realized I could just calculate it! I don't know why it hadn't occurred to me before So I will do that hopefully tomorrow. On a separate note, I never thought to wonder if the Arduino can read fast enough. Hopefully my speeds will be low enough since this is for runway travel on an overhead crane model. Am I correct to understand you were trying to run locomotives with this?

@gunrunnerjohn that's kind of a bummer. I suspect it means I'll be back to a dual shaft but a lot of the dual shaft motors seems to be high speed applications. Hopefully I can slow the RPMs down enough for direct drive.

I'm still working out the CAD model. I'll post that once the dimensions are worked out a bit better.

Can I suggest stepper motors? If only you could find a small one that is inexpensive,
and had a planetary gear reducer on the shaft. And, if you could control it easily.
I ran across a Gearhead Stepper Motor - NEMA 8 - 8.75V  at MPJA part # 38019 MS for  $23.95
that has a 4mm  flatted output shaft, 45.2:1 planetary gear ratio, and is a 4-wire,
200 steps per revolution stepper motor. MPJA also has a Multifunctional Stepper
Motor Driver Control Board   MPJA part #  36820MS   $9.95.  These two items will get your
feet wet with steppers. Two motors in parallel will each follow the steps perfectly.
Of course, you can program your favorite uProc for whatever you want.
Th 36820MS driver board will drive the motors directly. A uProc will need external driver transistors.
The motor is a MS08HG1P4025-01G and a search turned up another supplier with a cost of only $4.00 each, but they also have a minimum order $$ and you'll have to buy a short cable with the JST ZH 1.5mm 6 pin connector
(Amazon LATTECH  43219-100854) to plug onto the motor.
I couldn't find the exact model number in the MOONS' motor catalog, but
here is my calculation for the output torque:
I think the gearbox is 2 stages, so 70% efficient, motor torque @ 1000 steps / second (300RPM)
is 2.4 oz-in.   So 2.4 oz-in * 45.2 ratio * 70% eff = 75.94 oz-in or 4.75 lb-in. A 1" diameter wheel could pull 9.5 pounds.

Crane1

Here's what we're working with. Roughly 8 inches across the bridge. Four wheels in the scheme of things. A dual axle motor would be ideal but two synchronized motors would suffice. The new full scale cranes at work have two motors (and fancy VFDs I think). The crane from the 60s has one motor driving a shaft via a gear box.

@RogerofSandwich You most definitely can suggest stepper motors. I was thinking stepper motors would be better since I can tell them how many steps to make. Did I incorrectly assume I can tell them how fast to move through those steps? On a side note, nine pounds should be ample I imagine. I do intend to lift cargo with this crane to and from flat cars, hot metal cars, and slag cars but I wasn't planning on anything weighing that much. I was going to add enough weight for it to move nicely during the lift and not slide off the cars. I appreciate the suggestions and will look them up. I want to get some more CAD work done on the crane. I'm hoping to hide my wiring/PCBs in the cab and I need to find wheels for this.

I did order several different motors since they're all cheap. The shipping was different on them so I'm expecting arrivals on Wednesday, Thursday, and May 19th. I have a little PWM 12V 2A motor controller that I used to test my Tamiya gearboxes. I don't think I can drive the stepper motors with that but I think I can test the DC motor gearboxes I bought.

Attachments

Images (1)
  • Crane1
@G3750 posted:

The crane looks great, Bill.

I understand what David Nissen is saying.  Basically, if the Arduino has to spend its time polling vs the reacting to interrupts, it will no cycles for doing anything else.  That's true of any computer.

The more I think about your problem, the more I like the 1 motor driving 2 axles.

Truthfully, the Arduino is going to be loafing to process a couple of motors, I can't imagine this could be a problem with even semi-decent code.  Given the fact that it's driving this bridge, the speed I was initially considering probably isn't a factor, so I like the stepper motor idea as well.

@BillYo414 posted:

Thanks @G3750. I understood what he meant. I wonder if the new models are faster. I think the Megas have faster chips.

I dig the dual axle experience as well. It would simplify a lot.

I will point out one issue.  Even though you're driving two stepper motors, the one issue you will certainly want to consider is initial indexing.  You have to make sure the two sides are in sync mechanically when you power up.  I used to build aircraft cockpit instrumentation using steppers, whenever the instrument powered up, we'd have to slew to one end and find our index point first so we knew were the pointer was.

Truthfully, the Arduino is going to be loafing to process a couple of motors, I can't imagine this could be a problem with even semi-decent code.  Given the fact that it's driving this bridge, the speed I was initially considering probably isn't a factor, so I like the stepper motor idea as well.

I will point out one issue.  Even though you're driving two stepper motors, the one issue you will certainly want to consider is initial indexing.  You have to make sure the two sides are in sync mechanically when you power up.  I used to build aircraft cockpit instrumentation using steppers, whenever the instrument powered up, we'd have to slew to one end and find our index point first so we knew were the pointer was.

John,

Yeah, it did seem odd to me that the Arduino could be overwhelmed this way, but I have seen some pretty inefficient code in my day - stuff with built-in delays and wait states.

George

@G3750 posted:

Yeah, it did seem odd to me that the Arduino could be overwhelmed this way, but I have seen some pretty inefficient code in my day - stuff with built-in delays and wait states.

Clearly, you can code it so that a Cray computer couldn't do the job, but with even reasonably coding practices, the typical Arduino processor should be able to run a dozen of these projects.

@G3750 posted:

God, I've seen some bad practices by both students and so-called professionals. 

I wrote some terrible code when I first started in VBA...and that's a super simple language. I suspect I'll produce a real masterpiece on my first try with Arduino

I have the CAD finished for the bridge of the crane. I'll start on the cat walk and cab. Hopefully that'll give me enough real estate for the electronics. I think the electronics will include a wireless receiver board, a Nano/Uno, a speaker, and a few boards to drive the motors. I'm considering just popping my Menards wheels off their axles and trying to reuse them.

@BillYo414 posted:

Nah @gunrunnerjohn I have zero familiarity with C/C++ or Python. I have the public library and Youtube though so I'm sure I'll make it.

I have watched a number of tutorials and I get the concept of turning pins on and off based on input from other pins. I would just feel a lot more confident with a book and some practice.

Over the course of my career, I've learned a host of computer languages, not to mention the assembler language for a bunch of different microprocessors and several mainframes.  For all of these, I found the most progress in actually mastering the language was to do a project that required me to actually make something work, not just read about it in a book.

Over the course of my career, I've learned a host of computer languages, not to mention the assembler language for a bunch of different microprocessors and several mainframes.  For all of these, I found the most progress in actually mastering the language was to do a project that required me to actually make something work, not just read about it in a book.

I strongly second this viewpoint.  Having to make something actually work really brings home the learning.

George

Add Reply

Post

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
Link copied to your clipboard.
×
×