Simple Inclinometer Solution for Arduino Nano that uses no interrupts

I'm trying to instrument a gyroscope:

https://www.a3bs.com/gyroscope-u52006,p_853_1969.html

I've got some add ons to allow me to use Hall Switches for measuring the RPM of the flywheel and precession of the gyroscope. Each Hall Switch uses an interrupt leaving me with none. I'm using an SD card that works with the SD library as a data logger. It uses the SPI interface.

What I'm looking for is something to measure the inclination of the horizontal arm. Most searches on Amazon have lead me to accelerometers, mostly the MPU-6050. I'm hoping for a simpler (fewer wires and no interrupts needed) solution. I would like a resolution of better than one degree. Tilt sensors seem to be on off devices. I'm looking for an actual angle or value that can be turned into an angle.

As I'm already using SPI, I would greatly prefer using SPI over I2C.

Any ideas on this? The gyroscope will be precessing when I need to read the angle of the horizontal arm. It would be great if my sketch can have a single line of code in it to make the reading.

Thanks,
David

Each Hall Switch uses an interrupt leaving me with none.

The pin change interrupt allows any pin to be used as an interrupt.

You can have more than one device on the SPI bus.

You can get many gyroscope modules which have both i2c and SPI interfaces. You don't have to use interrupts to use them, even the one that offer that facility. I2c is generally slower, but that may not matter, and uses fewer wires.

You don't have to use interrupts for your hall sensors either. You may be able to use the gyroscope module to measure the precession.

I'm expecting the change in inclination to be slow, so I can sample it from my loop() function. The main reason for wanting an SPI device, or something that doesn't need more connections, is that I've already got the SD on SPI so, as I understand it, I would only need to use a single pin for Chip Select.

I was originally going to use a gyro to measure the precession rate. I still could, as a backup, if I use something like the MPU-6050. I've only found those with I2C. The MPU-6000 is supposed to have SPI, but I have not found one on Amazon. Searching for MPU-6000 brings up MPU-6050.

I'm doing something rather odd with this experiment. I'm trying to see how well I can measure the rotation of the earth with a relatively cheap mechanical gyroscope. Due to friction in the gimbal bearings, I plan to spin the flywheel in both directions and use a weight to make the gyroscope precess. The difference of the precession rates CW and CCW divided by two gets me earth's rotation over sin(latitude).

I was actually hoping for something simpler than the MPU-6050. I do have the I2CDev library for it though.

Leon Foucault had a remarkable setup for 1852. I wish I could find more technical details on that. Mind you, that would likely cost thousands these days, even with CNC.

Thanks,
David

Adxl345 has SPI interface. It appears to be accelerometer/inclinometer only, no gyro capability. Not sure about it's precision. Worth investigating?

Leon Foucault had a remarkable setup for 1852. I wish I could find more technical details on that.

There is lots of information on the web Foucault pendulum - Wikipedia

It is also a favorite museum exhibit. Here is a list of some that have them List of Foucault pendulums - Wikipedia

Not on the list is the one in Preston close to me. Foucault's Pendulum - Picture of Harris Museum and Art Gallery, Preston - Tripadvisor

Mind you, that would likely cost thousands these days

Nothing difficult about it, you just need the space for a long pendulum arm.

A gyroscope measures differences in inclination, not absolute values. With slow changes or low sampling rates the computed inclination will run away quite soon. IMO you are better off with measuring accelerations, which give a stable reading representing the current inclination.

DrDiettrich:
A gyroscope measures differences in inclination, not absolute values. With slow changes or low sampling rates the computed inclination will run away quite soon. IMO you are better off with measuring accelerations, which give a stable reading representing the current inclination.

The OP is not proposing to measure the inclination with a gyro. He was proposing, from the start, to use an accelerometer for that.

I suggested that if a combined accelerometer & gyro module was used, the gyro part might be considered for measuring the rate of precession. That might save some components/pins.

PaulRB:
Adxl345 has SPI interface. It appears to be accelerometer/inclinometer only, no gyro capability. Not sure about it's precision. Worth investigating?

Sounds worth it. Is there a library for the Arduino IDE for it? I looked and found reviews on a couple of those accelerometers. Data sheets are easy to find. I'm not so good with reading them. If there is a library that uses the SPI library, that would be very nice indeed. It appears to use 13 bit ADCs. That is sufficient for my needs.

Thanks,
David

I've found an I2CDev library for the ADXL345 by Jeff Rowberg. I can use it if I have to. As for SPI, I've found some threads on this forum for the ADXL345 using SPI with no success. I'll keep looking. Someone must have done it with the SPI library. Sparkfun has a code example, but it does not use the Arduino IDE or SPI library. It appears to be intended for direct use with the AVR compiler.

As they were cheap, I ordered a couple Sunfounder ADXL345 modules from Amazon

My primary reason for wanting to use SPI vs I2C is to reduce the total wiring I have to do.

Thanks,
David

Grumpy_Mike:
There is lots of information on the web Foucault pendulum - Wikipedia

It is also a favorite museum exhibit. Here is a list of some that have them List of Foucault pendulums - Wikipedia

Hi Grumpy,

I’m actually trying to do Foucault’s Gyro experiment, not the pendulum one. I have built a pendulum, but the 2.3 meters I have available to me is not really sufficient. I also don’t have a good way of measuring the precession on that as it comes to a stop fairly quickly.

As for the gyroscope, it has too much static friction in the gimbal to allow a direct demonstration of the earth’s rotation. However, I believe I can measure it by using CW and CCW precession by spinning up the rotor in each direction. The rotor slows down very quickly which messes up the results. So what I’m doing is going nuclear on this gyroscope by trying to measure every aspect of it using an Arduino Nano as that can be powered by a 9v battery so there would be no cables to mess things up (except for on the horizontal arm for the hall switch and an inclinometer of some sort.

I’ve put a lot of time into this. The nice thing about the Arduino Nano is it uses the same processor and pins as the Arduino Uno. So I’m doing my development on the Uno. The Nano will be attached to a breadboard, along with the other sensors and such which, in turn, will be affixed to the gimbal.

The Arduino IDE makes programming the instrument pack a lot easier than if I had to know actual electrical engineering and AVR code to make it all work. Hence my desire for a library that uses the bundled in SPI library to communicate with the breakout board for measuring inclination.

This is not a pendulum experiment. Foucault did a lot more than that! :slight_smile:

Thanks,
David

I found this on the Sparkfun site. I'll have to see if it translates to the Sunfounder module. If it does, I'm golden. It's a question of working out the wiring for SPI as the modules are labeled in favor of I2C.

https://learn.sparkfun.com/tutorials/adxl345-hookup-guide#sparkfun-adxl345-library