It's possible that your confusion stems from the fact that there are multiple solutions to the problem. While your accelerometer can tell you which way is up, it cannot distinguish between North and West. I.E. If you rotate the device about the vertical axis, the outputs of the accelerometers won't change.
How can you distinguish between North and West? The best way is probably to add a digital compass to the mix. Alternatively, you may not care to know the difference between real North and real West. You may only want two orthogonal horizontal axes. I'll assume the latter.
Define our frames first. The device's frame is (X, Y, Z). The earth's frame is (V, H1, H2).
Lets assume your accelerometer readings (Ax, Ay, Az) are in the range -1 .. +1, where +1 means straight up. Immediately you know which direction is up: it's simply (Ax, Ay, Az). But how do we obtain a horizontal axis? There's a function called the Cross Product, which takes any two vectors as inputs, and returns another vector at right angles to both. Therefore, we can easily find a vector at right angles to Up. In C:
Vector3D V = (Ax, Ay, Az);
Vector3D H1 = RANDOM_VECTOR;
Vector3D H2 = CrossProduct(V, H1);
H1 = CrossProduct(V, H2);
Normalise(H1);
Normalise(H2);
So, now we have a vertical vector V, and two horizontal vectors H1 and H2. Now we just need to rotate the gyroscope readings into the same frame.
Let's call the gyroscope readings (Gx, Gy, Gz). We're going to convert them into earth frame rotation coordinates (GV, GH1, GH2). All you have to do is to think about the gyro readings like a single 3D vector. Which way is it pointing in the device's frame. Which way is it pointing in the Earth's frame?
The answer is simply:
GV = (Gx*V.x) + (Gy*V.y) + (Gz*V.z);
GH1 = (Gx*H1.x) + (Gy*H1.y) + (Gz*H1.z);
GH2 = (Gx*H2.x) + (Gy*H2.y) + (Gz*H2.z);
(I hope that's right)...
Sadly, this may be a very difficult problem to solve. The problem is that you have almost nothing to use as a reference.
There's no magnetic field, and no suitable gravitational one. So compasses and accelerometers won't help you here. These are the options I can think of:
Gyro: You can measure the rate at which the object is rotating, but not its absolute orientation. By watching the rotation rate all the time, you can estimate your angle by 'dead reckoning' (integration). However, this is really not accurate over long periods of time because the gyro isn't a perfect sensor. More time = more error.
Optics 1: There are a huge number of options here which may be suitable depending on your particular circumstances. Firstly, you could use a camera to look at the inside of the duct. If it's featured enough, you could figure out your angle by looking at the features. If the duct is perfectly smooth on the inside, then perhaps you can shine a laser down the duct to spot on the inside for the prototype to use as a reference.
Optics 2: If the entrance of the duct is still visible from the prototype, then a camera on the prototype could look back up the duct and see the orientation of the outside world to get its bearings.
Acoustics: If you have access to the outside of the duct, then maybe you could repeatedly tap on the outside of the duct, and the prototype could get a sense of direction with a couple of microphones.
How is the prototype being lowered into the duct? On a piece of string? If so, then attach it to a pair of strings instead. That way it won't be able to rotate by itself. You'll do the rotating from the entrance of the duct.
So, basically, all of these options involve some complexity. You won't be able to get a simple analog direction signal from a simple sensor. Almost everything I can think of involves processing power to some degree.
If you can give more details of your problem, we may be able to think of better solutions.
Best Answer
The answers and comments you're getting are excellent of course, but I can add a little color.
For what its worth, our sensorineural system uses much the same tools, and doesn't always get the answer right! We have 3D accelerometers (the otolith organs) and 3D "gyros" (angular velocitomers, the semicircular canals), and yet we suffer from all sorts of illusions when the system is not able to get the right "answer", like the elevator illusion and the oculogravic illusion. Often these failures occur during low-frequency linear accelerations, which are difficult to distinguish from gravity. There was a time when pilots would nose-dive into the ocean during catapult takeoffs on aircraft carriers because of the strong perception of pitch resulting from the low frequency acceleration associated with the launch, until training protocols taught them to ignore those perceptions.
Granted, the physiological sensors have some different frequency cutoffs and noise floors than MEMS sensors, but we also have a huge neural net thrown at the problem -- though little in the way of evolutionary pressure to solve the problem correctly at these low frequency extremes, so long as catapult launches are fairly rare ;-).
Picture this common-sense "dead reckoning" problem that many have experienced, though, and I think you'll see how this carries over to the MEMS world. You get on a jet, take off in North America, accelerate to cruising speed, cross the ocean, decelerate and land in Europe. Even removing the tilt-translation ambiguities from the problem, and assuming zero rotation, there would be very little hope of a real implementation of a double integration of the acceleration profiles yielding a position profile anywhere nearly accurate enough to tell you you've reached Europe. Even if you had a very accurate 6 axis gyro/accelerometer package sitting in your lap during the trip, that would have its problems as well.
So that's one extreme. There's much evidence suggesting that for everyday behaviors animals use a simple assumption that low-frequency accelerations that are detected are probably caused by reorientations with respect to gravity. A combination of gyros and accelerometers that have broader frequency responses than our inner ear can solve the problem much better, of course, but will still have problems in the extreme due to noise floor, thresholds, and such.
So, for short epochs with non-trivial accelerations, dead reckoning with the right instrumentation is not so bad a problem. For long term, with small accelerations, and low-frequency accelerations, dead reckoning is a big problem. For any given situation, you need to figure out where on that spectrum your particular problem lies, and how accurate your dead reckoning needs are in order to determine whether the best you can do is good enough. We call that process engineering.