# Driver for half-speed rotation of gear completes two half rotations

I am trying to animate this set of planetary gears. The sun gear (blue) is driven by a crankshaft which drives other parts of the animation not shown here.

I have drivers set up for the planetary gears (twice the speed of the sun gear), and the ring gear (half the speed of the sun gear). My animation takes the sun gear through two whole rotations.

The problem is that instead of completing one whole rotation, the ring gear completes two half-rotations:

What I want is for the sun gear to rotate from 0 to 720, and the ring gear to rotate from 0 to 360.

Instead, my sun gear is rotating from 0 to 360 twice (which looks fine), while the ring gear is rotating from 0 to 180 twice (which does not).

Does this problem have to do with me using Quaternian rotation for the crankshaft? How could I go about fixing this? (Additional testing suggests not. The problem continues using XYZ Euler rotation)

So when you use a driver from a transform, there's two different ways to do it. One is to drive from a transform channel, which is what you're doing currently. The other way to do it is to drive directly from a single property (in this case, a rotation channel.)

The difference between these two things is that a single property is basically your fcurve value-- more or less, the raw number that's being animated-- while a transform channel has constraints run on it, and is "cleaned up". By cleaned up, one of the things that I mean is that any rotation is remapped to the -180, 180 range. So 380 degrees of rotation turns into 20 degrees of rotation, which is the same ransform, right? Well, it is, unless you're doing math on it, which you are.

In order to get what we want from gears, we can't use the transform channel. We have to use the raw, "single property" value. Unfortunately, that means that a few other things in your rig have to be changed. Yes, one of those things is the rotation mode of the bone that is ultimately driving this. (But you don't want a quaternion for this anyways-- Blender's quaternion implementation makes it impossible to get flat rotational velocity from quaternion rotation, and that's usually something people want out of the gears.)

Let's start by fixing up the bone. Clear rotation, delete all keyframes. Change rotation mode to ZYX Euler (because we're only ever going to rotate this in the Z axis, we want the Z rotation to come first.) Keyframe its rotation at 0 degrees on frame 1, then advance to some future frame, give it a Z rotation of 360 degrees, and keyframe that new rotation. Or, 720, or 1440, for good numbers to test the replacement driver.

Now let's fix up that driver. Because we're going to be using raw values rather than world space transforms, we can't drive from a child of the bone. That child never has any raw numbers other than zero for its rotation. We need to drive from the bone directly. So delete your driver on gear_ring. Then select your bone in pose mode and right click in its Z rotation field (in properties, or in the sidebar) and select "Copy as new driver." Then select your gear_ring object and right click in its Y rotation field and "Paste as new driver."

Test it out real quick. Not quite right. Select the driver ("Y Euler Rotation") on the left margin of the driver editor. Then open a driver editor sidebar and switch to its "Drivers" tab. Change the type of driver to a Scripted Expression, then change the expression to rotation_euler/2 . Now, instead of being equal to your keyframed rotation, it's only half of your keyframed rotation.

Repeat with the inner gears. They get the same kinds of drivers, but their expression should be rotation_euler * 2 instead.