Jack Sparrow's compass -powering a nano + micro servo using limited space

Hey there,

I'm Greg, a software developer, and I've recently started to work with Arduinos. One small project I'm working on is recreating Jack Sparrow's compass from the Pirates of the Caribbean movies. It's part of a larger scavenger hunt project I'm working on.

This famous compass doesn't point north, but rather "to the thing you want most in this world" - and for my project, it will be using a specific coordinate to point to.

I'm using the following hardware for this:

  • Arduino Nano v3 clone
  • an MPU-9250 nine-axis Inertial Measurement Unit
  • GY-NEO-6M v2 GPS module
  • Feetec FS90R (continuous rotation) micro servo
  • An Infra Red Obstacle Detection sensor

The general idea is that the Arduino initiates the servo to a starting position using the IR obstacle detection sensor, then, it will determine the location via GPS, measure the direction it needs to point based on the IMU's magnetometer that tells us where north is, and rotate the compass dial attached to the servo.

The software part of this is largely done - although determining the position of the servo was a bit of a last-minute thing so I still need to account for that.

Right now, my question is: how to supply power to both the Arduino and the servo, preferably so that I could also include a power switch to switch these on and off at the same time.

My biggest issue is that I have a very limited space to place my hardware in. The original compass looks like this:

My design will replicate this form, and my base is a 10x10 cm octagon-shape that I can work with, with approximately 4cm for the height of the lower part, because that's as high as the servo with the attached compass dial will be. This can be more if needed, but to be honest, the lower part seems quite tall already.

I will attempt to "hide" the GPS module to the upper, folding cover part of the compass, so let's say that only the cables for it would need to go down to the lower part where the rest of the hardware will be.

Obviously, the servo goes to the dead center of the base, and the Arduino nano as well as the IR sensor can go somewhere next to it. Cable management aside, this leaves me with not a lot of space for the power supplies:

Notes:

  • Obviously, it would be nice if the device could be re-chargeable / the power supply could be switched out in an easy manner

  • I understand from reading various posts on this forum that powering the micro servo using the nano's 5V pin is NOT recommended, so I guess this would mean two different power supplies

  • I've looked at mini power banks, but most of what I can buy online would be at least 9cm long, and with the added length of the USB, that would be too long for my base

So, do you have any suggestions for a requirement like this?

3xAA or 4xAA or 1x18650 Li-Ion?

How about a small LiPo battery?
1200mAh capacity, 34mm x 62mm x 5mm .
Don't forget a charge control card.
"The included protection circuitry keeps the battery voltage from going too high (over-charging) or low (over-use) which means that the battery will cut-out when completely dead at 3.0V. It will also protect against output shorts. However, even with this protection it is very important that you only use a LiIon/LiPoly constant-voltage/constant-current charger to recharge them and at a rate of 500mA or less."

Servo [https://media.digikey.com/pdf/Data%20Sheets/Adafruit%20PDFs/2442_Web.pdf](http://"https://media.digikey.com/pdf/Data Sheets/Adafruit PDFs/2442_Web.pdf")
needs 5V, 100mA, so that would use most of a typical Nano's 150mA regulator capability.
I'd add a small Step-up regulator to get 5V to power everything from the battery.
But you also need 3.3V for some items - does the MPU module have it's own 3.3V regulator?

gregbendes:
My design will replicate this form, and my base is a 10x10 cm octagon-shape that I can work with, with approximately 4cm for the height of the lower part,

That sounds to me like a lot of space :slight_smile:

...R

10x10x4cm, that makes for a nice hand-sized object.
I''d go with a Promini vs a Nano to be a little smaller and save on power draw, just plug on a FTDI Basic to program it, remove when done. Full-time USB interface is not needed.

CrossRoads:
Full-time USB interface is not needed.

Nor indeed, wanted - it wastes power!

Continuous rotation servo is the wrong approach. Unless you can find a servo with 360° range, you want a stepper and an opto-interrupter to determine the "zero" reference. In either case, servo or stepper you need to be able to disable the power to it when you do not need it to move.

PaulRB:
3xAA or 4xAA or 1x18650 Li-Ion?

AA batteries would work, sure, but I would have to have two cases for them to be able to safely power both the arduino and the servo, right? - provided that I won't be using the 5V pin from the Arduino Nano...

I think in this case, I guess I would need 4xAA + 3xAA batteries, and hook them up in a way so that a switch would turn both of them on or off. And also somehow solve replaceability, i.e. cut holes for the battery holders on both sides of the base or something.

CrossRoads:
How about a small LiPo battery?
1200mAh capacity, 34mm x 62mm x 5mm .
Don't forget a charge control card.
"The included protection circuitry keeps the battery voltage from going too high (over-charging) or low (over-use) which means that the battery will cut-out when completely dead at 3.0V. It will also protect against output shorts. However, even with this protection it is very important that you only use a LiIon/LiPoly constant-voltage/constant-current charger to recharge them and at a rate of 500mA or less."

Power, LiIon & LiPoly Products Category on Adafruit Industries

Servo [https://media.digikey.com/pdf/Data%20Sheets/Adafruit%20PDFs/2442_Web.pdf](http://"http://"https://media.digikey.com/pdf/Data Sheets/Adafruit PDFs/2442_Web.pdf"")
needs 5V, 100mA, so that would use most of a typical Nano's 150mA regulator capability.
I'd add a small Step-up regulator to get 5V to power everything from the battery.
But you also need 3.3V for some items - does the MPU module have it's own 3.3V regulator?

LiPo battery is another option I thought about, although I don't know much about them - thanks for the info, looks very useful! My concern would be safety, as well as recharging being a bit more problematic than hooking it up via USB, for instance, or replacing batteries. Still, for a size like this... I'm considering it.

And yeah, MPU has it's onboard 3.3V regulator, so it can be powered using the nano's 5V pin as well if needed.

CrossRoads:
10x10x4cm, that makes for a nice hand-sized object.
I''d go with a Promini vs a Nano to be a little smaller and save on power draw, just plug on a FTDI Basic to program it, remove when done. Full-time USB interface is not needed.

Cool idea, I actually also have a pro mini clone lying around - of course, the online store I bought it from left out the programmer so I'll have to buy one, but I'd need it anyway...

Paul__B:
Nor indeed, wanted - it wastes power!

Continuous rotation servo is the wrong approach. Unless you can find a servo with 360° range, you want a stepper and an opto-interrupter to determine the "zero" reference. In either case, servo or stepper you need to be able to disable the power to it when you do not need it to move.

I actually ordered a continuous rotation servo, so I'll have it -hopefully- in a couple of days. And yeah, I saw a similar project getting done with a stepper motor, so I might just order one, too - just in case.

If I use the continuous rotation servo, I imagine that sending the neutral position signal (1500 if I remember correctly) would stop the servo, right? Although I doubt it would reduce it's power consumption. At any rate, since it's a compass, I would imagine it rotating in a direction more or less constantly.

By the way, thanks a lot for the answers, guys, I'm just a beginner but I'm learning a lot and it's very exciting! :slight_smile:

Regarding the switch, is there a specific concern with just hooking up a switch like this to a power source to make it a power switch?

I've tried to look for answers regarding making a power switch for an Arduino, but didn't quite find anything specific. I guess I need to look for a switch that can handle the specific voltage that I would use, right?

No, that would be fine a for a power switch.
A small rocker switch would stick out less.
https://www.digikey.com/product-detail/en/e-switch/RR511D1121/EG4777-ND/2116256

How are going to know a continuous rotation ex-servo is pointing in the right direction?

The spec for the servo is 4.8 to 6V, so you can power both from a 5V source. Four coin cells should work for a few hours. Or,

This charger module is 77 X 20 X 30mm and it puts out a regulated 5V.
18650_charger.jpg

Stick one of these on the bottom of the box for wireless charging.
qi.jpg

qi.jpg

18650_charger.jpg

TheMemberFormerlyKnownAsAWOL:
How are going to know a continuous rotation ex-servo is pointing in the right direction?

Well, that was my point - it is impossible!

You might use a photo-interrupter to determine a "zero" position, but once you move the servo, even allowing you can stop it, you have no idea whatsoever how far it has moved, since this will depend not only on what signal you send it to determine how fast it moves, but on the battery voltage and ambient temperature.

I presume the suggestion here is that the "compass" is supposed to simply spin and stop in a quite random manner. Haven't seen the movie. :grinning:

CrossRoads:
No, that would be fine a for a power switch.
A small rocker switch would stick out less.
RR511D1121 E-Switch | Switches | DigiKey

Great, thanks! It's probably gonna be something smaller, like what you've suggested, next to the compass dial at the top of the thing.

Paul__B:
Well, that was my point - it is impossible!

You might use a photo-interrupter to determine a "zero" position, but once you move the servo, even allowing you can stop it, you have no idea whatsoever how far it has moved, since this will depend not only on what signal you send it to determine how fast it moves, but on the battery voltage and ambient temperature.

I presume the suggestion here is that the "compass" is supposed to simply spin and stop in a quite random manner. Haven't seen the movie. :grinning:

Uh oh, that's bad.

The compass should point to a specific lat/lon coordinate, and it should be able to determine the correct angle using the magnetometer on the IMU and the gps.

I thought I would use the IR Infrared Sensor upon the setup() part, and make the servo spin around until a small paper or wood blocks the light on the underside of the compass dial - that would be the zero position, a.k.a. north.

I presumed that depending on the speed / timing of the rotation, I would be able to calculate how much the continuous servo rotates and get it to a specific angle, since I can only send it write commands to rotate either clockwise or counterclockwise.

So I guess it's just not that simple, huh?

gregbendes:
I presumed that depending on the speed / timing of the rotation, I would be able to calculate how much the continuous servo rotates and get it to a specific angle, since I can only send it write commands to rotate either clockwise or counterclockwise.

I should be surprised if that did not prove to be highly erratic! :roll_eyes:

gregbendes:
So I guess it's just not that simple, huh?

No.

You clearly want a full 360° rotation. That is uncommon in hobby servos. That's why I suggested the micro steppers. Either you use a sensor such as a vane in an opto-interrupter

or "brute force" and just provide an end stop - which is essentially a blade since it must allow the full 360° of indication (even if it has to rotate the full circle to get there). The opto-interrupter does not inhibit rotation through either direction (and gives you two reference points; one either side of the vane whose width you can choose).

Compass displays - nowadays use the steppers but - used to use three coils to which you applied proportional voltages to cause the magnetic field to "point" in a certain direction for the needle to follow. I believe you can get such indicators now but frankly, the stepper is much easier to interface. :grinning:

I am not sure how many steps those micro steppers provide - this is probably not critical; visible steps might actually be advantageous.

Paul__B:
I should be surprised if that did not prove to be highly erratic! :roll_eyes:
No.

You clearly want a full 360° rotation. That is uncommon in hobby servos. That's why I suggested the micro steppers. Either you use a sensor such as a vane in an opto-interrupter

or "brute force" and just provide an end stop - which is essentially a blade since it must allow the full 360° of indication (even if it has to rotate the full circle to get there). The opto-interrupter does not inhibit rotation through either direction (and gives you two reference points; one either side of the vane whose width you can choose).

Compass displays - nowadays use the steppers but - used to use three coils to which you applied proportional voltages to cause the magnetic field to "point" in a certain direction for the needle to follow. I believe you can get such indicators now but frankly, the stepper is much easier to interface. :grinning:

I am not sure how many steps those micro steppers provide - this is probably not critical; visible steps might actually be advantageous.

Thanks for the explanation, this is very helpful.

Upon reading a bit about steppers, it's clear that it would do a much more predictable job for what I'm looking for, so I've ordered one as well as some other things - hopefully I can start working with it next week.

I already have an infrared obstacle avoidance sensor, like this one:

And I'm planning on using this one for detecting the position of the compass by attaching something on the underside of the dial, hopefully that works too.

No, that will not be accurate.

The sensor I cited sees the presence of a vane passing between. The vane could be the compass needle itself or an extension of it to pass under the bezel.

I see, in this case I'll order that as well. Thanks!

You might find the info on my site useful - about 4 pages. You COULD use a servo motor system which would give a more realistic effect with "hunting" - but for simplicity I'd go for a stepper motor. You can get resolutions down below 1 degree.

Interesting fun project

Great info!

I'm really thankful for this community, you guys are great and very helpful, I'm learning stuff every day! :slight_smile: