Accelerometer Coding

Hi, I was wondering if anyone had any information on the vex accelerometer analog sensor. My team and I are currently trying to put two accelerometers on each side of our lift. I was wondering if anybody knew what units the accelerometers produce and how to get this to m/s^2. We are trying to use them to control the length the lift goes up during autonomous and macro functions in our driver control. I have been having a lot of trouble finding some useful information on this sensor. Any information would be helpful. Thank you so much!

A Gyro or potentiometer would probably work better for you. You might be able to get the accel working with lots of code, but a simple potentiometer would be ten times easier to code and work more consistently. If you can’t for some physical reason (no place to put it), I would go with the gyro because it is very commonly used and there’s already a lot of info in the forums, but no one really uses accels to my knowledge.

Here’s the data sheet for the chip that’s on the Accelerometer Sensor board that VEX produces. Its a 3.3v device that measures acceleration in g’s but outputs it as a voltage, which the Cortex reads in through its ADC and converts it into a 0-4095 value. If using ROBOTC and have the sensor port configured as an accelerometer, this 0-4095 value will either map to 0-6g’s or 0-2g’s depending on jumper configuration. If configured as a raw sensor, see the data sheet for the actual voltage range of the chip (be sure to scale for the 5v circuitry, I think the 3.3v signal is boosted like the gyro’s is).

The product page has some more useful info on this as well.

@Rod be aware that because of the specific effect that the VEX Yaw Rate Gyro uses to function, it can only be used to measure Yaw, hence the name.

Right. I meant that @Kselva20 should mount it on one of the lift bars so that it rotates as it lifts. Then again, a potentiometer would still be a cleaner solution if possible.

@Rod I’m aware of what you meant, it can’t work for that, as that means measuring pitch instead of yaw.

[Edit] I may be incorrect on this actually. The data sheet indicates this but empirical results suggest otherwise. https://vexforum.com/t/unofficial-gyro-sensor-rotation-types/42850/1

@jmmckinney
I assumed that yaw meant relative to the board itself. Is that not the case?

That may be the case but the manufacturer data sheet suggests otherwise. See this thread

Either way, the accelerometer is better than gyro for resolving absolute (well, relative to the earth’s gravitational field anyway) angle of things like arms.
When your robot is stable (doesn’t accelerate/decelerate, or is stationary at given moment), the accelerometer would “feel” just the gravity vector, always pointing down. Thus you can verify that your sqrt(x^2 + y^2 + z^2) is g (9.8m/s^2) and then you can compute the spatial angle of the (x,y,z) vector, resolving vertical direction relative to the sensor (or, in other words, roll and pitch of the sensor board and the thing the sensor board is attached to).

If you want to use it to stabilize a two-sided linear lift (two independent motors, each lifting one side of some kind of common platform/bridge), you can place single accelerometer on the bridge to measure whether and how much it is slanted.

I was the one pontificating in that thread that yaw means yaw. All the documentation I found makes it clear it’s laid out and etched like a yaw (Z axis) sensor.

However, empirically, it appears to function acceptably in other orientations. I have not done that myself, and I’ve not ever had much luck doing that with other MEMs sensors. But it is at least somewhat responsive mounted in other orientations, and people appear to use it that way occasionally.

@kypyro I think I’m still in your camp on that one. It’s important to use the right tool for the job even if another looks like it could work.

If you use a gyro, and mount it sideways, could you use it to make a passive antitip for auton?

I mean, that would require motors / pistons to work, but it has been done before (don’t know what you mean by passive anti-tips):

I’m not sure why you wouldn’t want anti-tips to just stay out. Tipping doesn’t seem like too big of an issue this year, since it seems like people have figured out anti-tips that don’t get in the way too much or that no anti-tips at all works well enough (or they learn some tricks with tipping).