VNH2SP30 with continuous rotation servos

Hi,

I’m using the “Dual High-Current Motor Driver Carrier” (VNH2SP30 version) attached to the Orangutan X2. Although I’ve played around with serial servo controllers, this is my first experience with motor controllers. My goal is to hook up two servos that have been modified for continuous rotation and drive them from the Orangutan. I have the following questions:

  1. It’s called a “dual” motor driver, but it seems to be capable of driving up to four motors. At least, that would explain why there are four of each type of port (for example, 1INA, 1INB, 2INA, and 2INB). Does “dual” simply refer to the two chips, not the number of possible motors? If not, what’s the meaning of 1A, 2A, 1B, and 2B?

  2. Where would I make the connections for a servo modified for continuous rotation? For example, let’s say I’m hooking it up to 1A. My guess is that servo power should go to 1OUTA, servo ground should go in GND, and servo control should go in 1INA. Does that sound right?

Thanks for any clarification on these points.

Welcome to the world of DC motor control!

To answer your first question, the motor driver is only able to control two DC motors, and the various inputs are used to control the behavior of the motors like speed, direction (forward/reverse) and coasting or electronic braking. I could go very deeply into DC motor control here (and I just might later) but I don’t think it’s necessary just yet because I’m not sure you actually need a DC motor controller to run your modified servos.

To answer your second question, the only place you connect motors to the Dual High-Current Motor Driver Carrier is to the screw terminals labeled M1 Outputs or M2 outputs. The two poles of a DC motor go to the two terminals of either M1 or M2. The rest of the motor driver connections are made to the X2’s main microcontroller through the 20 pin connector, so you don’t need to (and shouldn’t) hook anything up to them. How you control a servo that has been modified for continuous rotation depends on exactly how it has been modified. Did you perform the modification, and if so what did you do, or did you purchase a modified servo?

There are two main ways to modify a servo for continuous rotation. In both cases you remove the potentiometer from the servo and cut off the mechanical stop so it can rotate freely.

If you then remove the rest of the servos electronics, and power the DC motor inside the servo case directly, what you need is what you’ve got, a DC motor controller. Your “servo” at this point is actually just a DC motor with a gearhead in a nice little package, which you speed control by applying different voltages (or PWM voltages with various duty-cycles) to the two motor wires. To drive such a motor from the Dual High-Current Motor Driver Carrier, you would hook up the two motor wires to either the M1 or M2 outputs. The fact that your modified servo still has a third signal wire makes me suspect that this is not what you have.

If, on the other hand, the servo electronics are still in place, but the potentiometer has been replaced with fixed resistors, then you are still using the servo control system as a rudimentary speed control (more like just forward or reverse). In effect, the servo electronics are (still) acting as a DC motor controller, so you don’t need a separate one. To drive this kind of servo, you would still use a servo controller (not a DC motor controller). The commands that used to control position would now control rotational speed and direction. It is possible to generate servo control signals from the IO pins of the X2, but it isn’t necessary (or even useful for that matter) to use the motor controller board.

So, sorry to answer a question with another question, but do you know what type of modified servo you have? I guess that’s the real question to answer first.

-Adam

This is the part that confuses me. What exactly are all those pins for? The web page for the controller and the data sheet on the VNH2SP30 make it seem like they should be used. Can you elaborate on this point please?

I’m in the process of modifying two GWS S03T servos using these instructions.

Hmm… According to the instructions above, no modifications to the electronics are necessary. I thought it was just a matter of removing the rods and things that prevent full rotation, and also disconnecting the potentiometer so that it always thinks the servo is in the neutral position. Are the instructions wrong?

Thanks for your help!

Since we’re talking about two very different things, lets split them up:

DC Motor Controllers
Each VNH2SP30 chip controls one DC motor. Each chip has several inputs and outputs, and even more confusingly, the high current IO lines are spread out over multiple physical pins. Lets just look at the most important ones:

The OutA pin(s) connect to one pole of a DC motor, and the OutB pin(s) connect to the other.

The high/low (1/0) setting of pins InA and InB control the operational mode of the chip, according to the truth table in the middle of page 7 of the VNH2SP30 data sheet. For example, setting InA high and InB low sets the chip up to rotate the motor clockwise.

Pin 8 is the PWM input, which is the Pulse Width Modulated signal (in this case produced by the auxiliary microcontroller on the X2) which controls the motor’s speed. Basically it’s a 0V-5V square wave with some high frequency (the chip supports up to 20KhZ) which is high for some portion of the period, and low for the rest. The “duty cycle” is the percent of the time the signal is high. When the signal is high, battery voltage is applied to one of the motor output pins, while the other is grounded (depending on the settings of InA and InB). When the signal is low, the motor output pins are left floating.

Since this switching happens at such a high frequency, the motor’s rotational inertia smooths out the motion. Effectively, the motor sees an average voltage, in this case equal to the duty cycle times the battery voltage. If you have a 10V battery and you’re running the motor at a 50% duty cycle, the motor behaves as if it has 5V applied to it. Even though it’s actually being switched between zero and ten volts very quickly, it sees each for half the time, and behaves as if it were seeing the average of the two.

The other inputs/outputs are for things like monitoring the current drawn by the motor, and fault conditions of the chip like the overheat/emergency shutdown. It’s all very confusing, and to do it right you do need to read the datasheet cover to cover. What’s very nice about the X2/Carrier combo is that all the connections are taken care of for you, and all the operational protocols are implemented in the auxiliary microcontroller firmware. You just send simple speed commands, as outlined in the X2 command documentation. Easy as pie!

Continuous Rotation Modified Servos
I haven’t modified a GWS servo for continuous rotation, but I have taken a few apart, and those instructions make perfect sense. The little white clip you remove is what couples the potentiometer and the output shaft, so without it, the POT stays put.

This is convenient, since by adjusting the potentiometer, you adjust the stop point of your modified servo (as opposed to adjusting your servo control code for each servo). Instead of cutting the slit in the potentiometer shaft like in these instructions, you could also plug the servo into your controller (after taking off the white clip, before putting any gears back on) and send it a neutral position command. Odds are the motor will spin like crazy, but you can adjust the pot until you find the precise point where the motor stops turning. If you’re going to keep this servo paired with the controller, you might even put a very tiny drop of glue in the POT collar to lock it in place (only the tiniest bit of super-glue with the head of a pin, so it doesn’t wick down into the workings of the POT). Maybe you should use something weaker, like Elmers glue, that you could break if you decided you wanted to reset it. Anyway, you might also want to do the slit way so you can fine tune it whenever you want.

With this kind of modification to the servo you will still need a regular servo controller (not a DC motor controller) but what used to be position commands will now be speed commands. The neutral position command will make the servo stay put, while a position command a little bit to one side will drive the servo at a constant speed in one direction, and a command a little bit to the other side will drive the servo in the opposite direction. I think you’ll find that you reach a max speed after deviating only slightly from the neutral position command.

In most servos (the ones I’ve taken apart anyway) the potentiometer shaft fits into a slot molded into the output gear (no little removable clip) so to make it rotate continuously without crunching the POT (which isn’t meant to rotate all the way around) you actually have to remove the POT. You can replace it with well-matched pairs of static resistors, or even leave it hanging out for adjustment later. If you move the POT to a linkage driven by the modified servo, you have a new (slow) servo mechanism like this robot arm.

Anyway, does that answer your questions (and is that more than you ever wanted to know)?

-Adam

Right, that’s what I thought. So if I can twiddle all those pins programmatically via the Atmel controller, what’s the point of having them exposed as external connections also? I can’t see a situation where I’d need to hook something up to them.

A very good idea!

Hmm… I guess I’m using the wrong servo then… For my design, I really need the speed of a motor controller for fast response. That’s because I’m following the design for a balancing two-wheeled robot described in the December 2006 issue of Nuts and Volts. (They used standard RC servos modified for continuous rotation, which apparently involved removing all electronics and hooking up only two of the three servo wires.) The author of the article said specifically that a serial servo controller would not be a good idea in this design because of the latency it would add.

So maybe I should just ditch these GWS servos and get some actual DC motors instead. They need to be able to switch from forward to reverse quickly (a balancing bot has to make lots of quick adjustments) and have plenty of torque. What do you think?

You are helping a lot, thank you! All of the information you’re providing should have been in Pololu’s documentation; they should hire you as a tech writer or something.

Very cool! I’m always glad to hear about people making balancing bots, especially since BalBots HQ caught fire and they stopped selling the kits.

I agree that a serial servo controller will not respond quickly enough to balance a balancing bot, but you can certainly use the GWS servos you have now as straight DC gearmotors. You just need to rip out the electronics board (you could actually leave the POT, but do remove that white clip) and connect the DC motor leads to one set of the motor carrier board’s output terminals. As for whether they will cut it for your balancing bot I can’t say (I haven’t built my own balancing bot you see), but you might want to start with them for now since you have them. I would tend towards bigger, beefier DC gearhead motors. I don’t have any to recommend offhand, but more torque AND speed can’t hurt, and a bit more mass down low could be a big help in controlling the inverted pendulum system.

As to why the carrier board has the control pins brought out and labeled, and in the mini-header, that board is sold separately by Pololu as a standalone Dual High-Current Motor Driver Carrier, which you can use with your own microcontroller connected to those interface pins. It’s also bundled as part of the super-cool TReX Dual Motor Controller.

And thanks for the praise, I’m actually a fan of Pololu’s sparse but complete documentation style (there’s a little debate going on about it here). You do have to do more figuring for yourself, but I find that it makes it easier to find the information you want without having to dig around for it. For example, most electronics manufacturers wouldn’t dream of publishing complete schematics of their products. It can cause problems if something is counterintuitive and/or you miss it in the manual (I definitely spent about a day staring at my first Pololu motor controller for want of a pull-up resistor) but at the same time the manuals are short and well-written enough that it’s not a huge hassle to read through it again. And when all else fails, you go to the forums!

-Adam

P.S. The Electromechanical Systems class here at the University of Michigan is building full-size human-carrying balancing vehicles from scratch this semester, how cool is that!?! The Engineering Design Expo they’re supposed to be presenting them at is tomorrow in Lansing, Michigan. I haven’t checked up on the class recently, but I’m really hoping they got something to work! I talked to one student in the class about three months ago who said there was no way any of the teams would get anything working, and another student a couple of weeks ago who said they’d be totally ready, so here’s hoping!

And I would just leave the servo’s white control wire disconnected, right?

Hopefully they will work. The Nuts and Volts authors used the GWS S03N successfully, and my S03T have a gear ratio that provides double the torque (100 oz/in). So if raw torque and speed are key, I should be okay.

Actually, I’ve read that for a balancing bot, you want all the mass up top because that’s where the “unbalancing” happens. Having more inertia up there gives the controller more time to respond to changes.

The three wires coming out of the servo casing are all connected to the electronics board, not directly to the motor (the motor poles are probably soldered directly to the board). When you remove the board, the wires go with it, and the motor stays. It’s up to you what wires you connect to the motor poles but the leftover servo wires are conveniently at hand.

And yes, I can see why for a balancing bot you would need some mass up high to pump up the moment of inertia about the motor axis, otherwise any little torque at the motors will flip the bot around, rather than letting the wheels get out in front of the falling top.

It seems to me though that to be able to drive the bot around and not just balance in place, some portion of your mass has to be down at the wheels, but the motors alone might be more than enough for that. Anyway, I would be very interested to hear about your results.

-Adam

Okay, I think I get it now. I cut out the electronics from the servo and hooked up the motor wires directly to the Orangutan. I was then able to control the motor’s speed and direction using the Orangutan’s test program. So it all looks good so far!

By the way, does it matter which motor wire goes to which port on the Orangutan? I guess it’s not important because it can always be fixed in software, but is there a color code convention? The poles of this motor are red and white.

Also, in the process of modifying the servo, I probably got some dust and dirt in the metal gears, and some of the grease from the gears came off on my hands. Is there an easy way to clean and regrease the gears, or should I not bother?

Thanks!

In reality, brushed DC motors have slightly different characteristics in each direction, but they’re close enough that you shouldn’t worry about it, just wire it up in whichever direction you like. You can reverse the motor direction in software, or just swap the motor wires at the screw terminals.

I wouldn’t worry about a little dust in the gears (I might if it were a high-performance, very high speed gearmotor), and you probably didn’t take off any important grease. They squirt a big glob in, and it gets churned around into another glob that’s easy to get on your fingers, but the grease that matters is the thin film in the mesh of the tiny gear teeth, and on the gear shafts and I doubt you took all that off.

-Adam