This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).
This is my 3-planet planetarium/orrery. It started out as just a semester-long project for the Makecourse, but by the time the end of the semester rolled around, it turned into an extremely valuable learning experience. Not only did I learn the basics of microcontrollers, but it also taught me many interesting things about C and C++, the Android platform, soldering, and electronics work in general.
The basic function of the Planetarium is this: open an app on your phone, connect to the Planetarium, select a date, hit send, and watch the Planetarium move Mercury, Venus, and Earth to their relative heliocentric longitudes at that date. You can go as far back as 1 AD/CE, and as far forward as 5000 AD/CE, though accuracy may decline slightly as you go forward or backward over 100 years or so.
In this Instructable, I will explain how to assemble the planets, the gear system that drives them, the circuit board that connects everything together, and the Android and C++ (Arduino) code that controls the planets.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts and Tools
- 1 DC-47P DC Series Heavy Duty Electronics Enclosure - $ 9.58
- 0.08" (2mm) Acrylic/PMMA sheet, at least 6" x 6" (15cm x 15cm) - $2.97
- 3 28BYJ-48 Unipolar Stepper Motors - $6.24
- Glow in the Dark Planets - $8.27 (See note 1)
- Glow in the Dark Stars - $5.95 (Optional)
- 3 ULN2003 Stepper Motor Drivers - $2.97
- 1 Atmel ATMega328(P) - $1.64 (See note 2)
- 1 HC-05 Bluetooth to Serial Module - $3.40
- 1 16MHz Crystal Oscillator - $0.78 for 10
- 1 DIP-28 IC Socket $0.99 for 10
- 1 piece of Stripboard (pitch = 0.1", size = 20 rows of length 3.5") - $2.48 for 2
- 1 Panel Mount DC Supply Jack, Female (5.5mm OD, 2.1mm ID) - $1.44 for 10
- 2 22pF 5V capacitors - $3.00 for 100 (see note 3)
- 2 1.0 μF capacitor - $0.99 for 50
- 1 10kΩ resistor - $0.99 for 50
- Spare Arduino or AVR ISP - You'll need this to program the ATMega chip
- Screwdrivers - for removing the stock ATMega from the Arduino
- Multimeter - or at least a continuity meter
- Hammer - for fixing anything that isn't done The Right Way™
- Drill with 5/16", 7/16" and 1 3/8" drill bits
- Small snips - for trimming component leads
- 22 AWG stranded copper wire (Great price and lots of options here)
- Solder - I use 60/40 with rosin core. I've found that thin (<0.6mm) solder makes things a lot easier. You can really find solder anywhere, but this is one that I've had success with.
- Flux - I really like these flux pens, but you can really use any form of flux, as long as it's acid-free.
- Soldering Iron/Station - You can get these for pretty cheap on eBay and Amazon, although be warned: frustration varies inversely with price. My cheap ($25) Stahl SSVT takes absolutely forever to heat up, has almost no thermal capacity, and there's an audible 60 Hz buzz that emanates from the heating element. Not sure how I feel about that.
- Helping hand - These are invaluable tools that are almost necessary for soldering, and they help when it comes to gluing the planets to the acrylic bars.
- Epoxy - I used Loctite Epoxy for Plastics, which worked pretty well. When I dropped one of the planet arms (attached to a planet) on concrete by mistake, the epoxy didn't hold the two parts together. But then again, I had only given it about 15 of the recommended 24 hours to fully cure. So maybe it wouldn't have come apart otherwise, but I can't say. Regardless, you can use just about any adhesive or glue that takes longer than a few minutes to cure, since you may need to make fine adjustments for a little bit after you apply the adhesive.
- Toothpicks - You'll need these (or any disposable stirrer) for epoxy or any 2-part adhesive, unless it comes with an applicator that mixes the two parts for you.
- 3D Printer - I used these to print out some of the parts for the gear system (files included), but if you can fabricate those parts using other (perhaps less lazy) methods, then this isn't necessary.
- Laser Cutter - I used this to make the clear arms that hold the planets up. Like the previous point, if you can make the parts using another method (they can easily be cut using other methods), then this isn't necessary.
- You'll need either the Arduino IDE, or standalone versions of AVR-GCC and AVRDude
- Android Studio, or Android Tools for Eclipse (which has been deprecated). This might be optional soon, since I might upload a compiled APK to the Play Store
The total cost of all parts (minus tools) is about $50. However, many of the listed prices are for more than 1 item each. If you only count how much of each item is used for this project, the effective total cost is about $35. The most expensive item is the enclosure, at almost a third of the total cost. For the MAKE Course, we were required to incorporate the box into our project designs, so it was a necessity. But if you're looking for an easy way to cut costs on this project, then check out your local big box retailer; they'll likely have a good selection of boxes that are cheaper than your typical "electronics enclosure". You can also make your own planets (wooden spheres are a dime a dozen) and paint on the stars instead of using pre-made plastic ones. You could complete this project with less than $25!
- You can also use whatever you'd like as "planets". You could even paint your own!
- I'm fairly certain that either these chips didn't come preloaded with the Arduino R3 bootloader like they said they did, or there must have been some programming error. Regardless, we'll be burning a new bootloader in a later step.
- I would highly recommend stocking up on variety packs/assortments of resistors and capacitors (ceramic and electrolytic). It's much cheaper this way, and you can also quickly begin a project without having to wait for a specific value to arrive.
Step 2: Fabricating the Gear System
Essentially, all of the hollow columns nest inside each other and expose their gears at different heights. Then each of the stepper motors are placed at a different height, each one driving a different column. The gearing ration is 2:1, meaning each stepper motor needs to make two full rotations before its column makes one.
For all of the 3D models, I've included STL files (for printing) as well as Inventor part and assembly files (so you can freely modify them). From the exports folder, you'll need to print 3 stepper gears, and 1 of everything else. The parts don't need a super fine z-axis resolution, though a level bed is important so that the stepper gears make a snug press fit, but not so tight that it's impossible to get on and off. Infill around 10%-15% seemed to work just fine.
Once everything is printed, it's time to assemble the parts. First, install the stepper gears onto the stepper motors. If they're a bit tight, I found that lightly tapping them with a hammer worked much better than pushing with my thumbs. Once that's done, push the motors into the three holes in the base. Don't push them all the way down, because you might need to adjust their heights.
Once they're secure in their holders, drop the Mercury column (the tallest and thinnest one) onto the base column, followed by Venus and Earth. Adjust the steppers so they mate well with each of the three larger gears, and so that they only contact the appropriate gear.
Step 3: Laser Cutting and Gluing the Acrylic Bars
Since I wanted my planetarium to look good in light or in dark, I decided to go with clear acrylic bars to hold the planets up. This way, they wouldn't detract from the planets and stars by obstructing your view.
Thanks to an awesome makerspace at my school, the DfX Lab, I was able to use their 80W CO2 laser cutter to cut out the acrylic bars. It was a fairly straightforward process. I exported the Inventor drawing as a pdf, and then opened and "printed" the pdf to the Retina Engrave printer driver. From there, I adjusted the size and height of the model (TODO), set the power settings (2 passes @ 40% power did the job) and let the laser cutter do the rest.
After you have your acrylic bars cut out, they'll probably need some polishing. You can polish them with glass cleaner (just make sure it doesn't have any of the chemicals listed with an "N" here) or soap and water.
Once that's done, you'll need to glue the bars to each one of the planets. I did this with Loctite Epoxy for Plastics. It's a 2-part epoxy that sets in around 5 minutes, mostly cures after an hour, and fully cures after 24 hours. It was the perfect timeline, since I knew I would need to adjust the positions of the parts for a little bit after I had applied the epoxy. Also, it was specifically recommended for acrylic substrates.
This step was fairly. The instructions on the package were more than sufficient. Simply extrude equal parts of the resin and hardener onto some newspaper or a paper plate, and mix thoroughly with a wooden toothpick. Then apply a small dab to the short end of the acrylic bar (making sure to coat a small distance up the bar) and a small dab to the underside of the planet.
Then hold the two together and adjust both until you're comfortable with how they're lined up. For this, I used a helping hand to hold the acrylic bar in place (I put a piece of sandpaper between the two, abrasive side out, to prevent the alligator clip from scratching the bar) and a spool of solder to hold the planet still.
Once the epoxy has fully cured (I only had time to give it about 15 hours to cure, but 24 hours is what was recommended) you can remove the assembly from the helping hand and test the fit in the planet columns. The thickness of the acrylic sheets that I used was 2.0mm, so I made equally sized holes in the planet columns. It was an extremely tight fit, but fortunately, with a little bit of sanding, I was able to slide the columns in.
Step 4: Using AT Commands to Change Bluetooth Module Settings
This step might seem a little out of order, but it's much easier if you do this before soldering the HC-05 bluetooth module onto the board.
When you get your HC-05, you will likely want to change some factory settings, such as device name (typically "HC-05"), password (typically "1234"), and baud rate (mine came programmed at 9600 baud).
The easiest way to change these settings is to interface directly with the module from your computer. For this, you'll need a USB to TTL UART converter. If you have one lying around, you can use that. You can also use the one that comes with non-USB Arduino boards (Uno, Mega, Diecimila, etc). Carefully insert a small flat head screwdriver between the ATMega chip and its socket on the Arduino board, and then insert the flat head from the other side. Carefully lift up the chip a little bit from each side until it's loose and can be pulled off the socket.
Now the bluetooth module goes in its place. With the arduino disconnected from your computer, connect Arduino RX to HC-05 RX and TX to TX. Connect Vcc on the HC-05 to 5V on the Arduino, and GND to GND. Now connect the State/Key pin on the HC-05 through a 10k resistor to Arduino 5V. Pulling the Key pin high is what allows you to issue AT commands to change settings on the bluetooth module.
Now, connect the arduino to your computer, and pull up the Serial Monitor from the Arduino IDE, or a TTY from the command line, or a terminal emulator program like TeraTerm. Change your baud rate to 38400 (the default for AT communications). Turn on CRLF (in the serial monitor this is the "Both CR and LF" option, if you're using the command line or another program, look up how to do this). The module communicates with 8 data bits, 1 stop bit, no parity bit, and no flow control (if you're using the Arduino IDE you don't need to worry about this).
Now type "AT" followed by a carriage return and a newline. You should get back the response "OK". If you don't, check your wiring and try different baud rates.
To change the name of the device type "AT+NAME=", where is the name you want the HC-05 to broadcast when other devices are trying to pair with it.
To change the password, type "AT+PSWD= ".
To change the baud rate, type "AT+UART=".
For the full list of AT commands, see this data sheet.
Step 5: Designing the Circuit
The circuit design was fairly simple. Since an Arduino Uno wasn't going to fit in the box with the gear system, I decided to solder everything onto one board, and only use an ATMega328 without the ATMega16U2 usb-to-uart converter that's on Uno boards.
There are four main parts to the schematic (other than the obvious microcontroller): the power supply, the crystal oscillator, the stepper motors drivers, and the bluetooth module.
The power supply comes from a 3A 5V power supply I bought off eBay. It terminates with a 5.5mm OD, 2.1mm ID barrel plug, with positive tip. So the tip connects to the 5V supply, and ring to ground. There's also a 1uF decoupling capacitor to smooth out any noise from the power supply. Notice that the 5V supply is connected to both VCC and AVCC, and ground is connected to both GND and AGND.
I used a 16MHz crystal oscillator, and 2 22 pF capacitors as per the datasheet for the ATMegaXX8 family. This is connected to the XTAL1 and XTAL2 pins on the microcontroller.
Stepper Motor Drivers
Really, these can be connected to any pins. I chose these because it makes for the most compact and straightforward layout when it comes time to put everything on a circuit board.
The HC-05's TX is connected to the microcontroller's RX, and RX to TX. This is so that anything sent to the bluetooth module from a remote device will be passed onto the microcontroller, and vice verse. The KEY pin is left disconnected so that there can't be any accidental reconfiguration of settings on the module.
I placed a 10k pull-up resistor on the reset pin. This shouldn't be necessary, but I figured it might prevent the off-chance that the reset pin goes low for longer than 2.5us. Not likely, but it's there anyway.
Step 6: Planning the Stripboard Layout
The stripboard layout isn't too complex either. The ATMega lies in the middle, with the stepper motor drivers and bluetooth module lined up with the pins that they need to be connected to. The crystal oscillator and its capacitors sit in between Stepper3 and the HC-05. One decoupling capacitor lies right where the power supply comes into the board, and one lies between Steppers 1 and 2.
The X's mark a spot where you need to drill a shallow hole to break a connection. I used a 7/64" drill bit and drilled only until the hole was as wide as the bit diameter. This ensures that the copper trace is fully divided, but it avoids unnecessary drilling and makes sure that the board stays strong.
Short connections can be made using a solder bridge, or by soldering a small, uninsulated piece of copper wire to each row. Larger jumps should be made using insulated wire either on the bottom or top of the board.
Step 7: Soldering
Note: This won't be a tutorial on soldering. If you've never soldered before, YouTube and Instructables are your best friends here. There are countless excellent tutorials out there that teach the basics and the finer points (I'm not claiming to know the finer points; up until a few weeks ago, I sucked at soldering).
The first thing I did with the stepper motor drivers and bluetooth module was desolder the bent male headers and solder on straight male headers to the back side of the board. This will allow them to be flat on the stripboard.
The next step is to drill out all the holes that need to break connections if you haven't already.
After that's done, add any uninsulated jumper wires to the top of the board. If you prefer to have them on the bottom, you can do this later.
I soldered on the IC socket first to give a reference point for the rest of the components. Make sure you note the direction of the socket! The semicircular indentation should be closest to the 10k resistor. Since it doesn't like to stay in place before it's soldered, you can (apply flux first of course) tin two opposite corner pads, and while holding the socket in place from the underside, reflow the tinning. Now the socket should stay in place so you can solder the rest of the pins.
For the parts with leads (capacitors and resistors in this case), inserting the parts and then bending the leads slightly should keep them in place while soldering.
After everything is soldered in place, you can use small snips (or since I didn't have any around, old nail clippers) to trim down the leads.
Now, this is the important part. Check, double check, and triple check all the connections. Go around the board with a continuity meter to make sure everything's connected that should be connected, and nothing's connected that shouldn't be.
Insert the chip in the socket, making sure the semicircle indentations are on the same side. Now plug in the power supply to the wall, and then to the the dc power jack. If lights on the stepper drivers light up, unplug the power supply and check all connections. If the ATMega (or any part of the board, even the power supply wire) gets extremely hot, unplug the power supply and check all connections.
Soldering flux should be re-branded as "Literally Magic". Seriously, flux makes things magical. Apply it generously anytime before you solder.
Step 8: Burning the Bootloader on the ATMega
When I got my ATMegas, for some reason they wouldn't allow any sketches to be uploaded to them, so I had to re-burn the bootloader. It's a fairly easy process. If you're certain that you already have an Arduino/optiboot bootloader on your chip, you can skip this step.
The following instructions were taken from a tutorial on arduino.cc:
- Upload the ArduinoISP sketch onto your Arduino board. (You'll need to select the board and serial port from the Tools menu that correspond to your board)
- Wire up the Arduino board and microcontroller as shown in the diagram to the right.
- Select "Arduino Duemilanove or Nano w/ ATmega328" from the Tools > Board menu. (Or "ATmega328 on a breadboard (8 MHz internal clock)" if using the minimal configuration described below.)
- Run Tools > Burn Bootloader > w/ Arduino as ISP. You should only need to burn the bootloader once. After you've done so, you can remove the jumper wires connected to pins 10, 11, 12, and 13 of the Arduino board.
Step 9: The Arduino Sketch
All of my code is available on GitHub. Here's the Arduino sketch on GitHub. Everything is self documented, and it should be relatively simple to understand if you've worked with the Arduino libraries before.
Essentially, it accepts a line of input over the UART interface which contains the target positions for each of the planets, in degrees. It the takes these degree positions, and actuates the stepper motors to move each planet to its target position.
Step 10: Uploading the Arduino Sketch
The following is mostly copied from ArduinoToBreadboard on the arduino.cc site:
Once your ATmega328p has the Arduino bootloader on it, you can upload programs to it using the USB-to-serial convertor (FTDI chip) on an Arduino board. To do, you remove the microcontroller from the Arduino board so the FTDI chip can talk to the microcontroller on the breadboard instead. The diagram above shows how to connect the RX and TX lines from the Arduino board to the ATmega on the breadboard. To program the microcontroller, select "Arduino Duemilanove or Nano w/ ATmega328" from the the Tools > Board menu. Then upload as usual.
If this proves to be too much of a chore, then what I did is just insert the ATMega into the DIP28 socket every time I needed to program it, and take it out afterwards. As long as you're careful and gentle with the pins, it should be alright.
Step 11: The Android App Code
Just like the Arduino code, my Android code is here. Again, it's self documented, but here's a brief overview.
It takes a date from the user and calculates where Mercury, Venus, and Earth were/are/will be at that date. It assumes midnight to make it simpler, but maybe I'll add in time support soon. It makes these calculations using an awesome Java library by the name of AstroLib, which can do way more than what I'm using it for. Once it has these coordinates, it sends just the longitude (the "position" you typically think of when referring to planetary orbits) to the bluetoooth module for each of the planets. It's that simple!
If you would like to build the project yourself, you'll first need to put your phone into developer mode. The instructions for this may depend on your phone's manufacturer, the device model itself, if you're running a custom mod, etc.; but typically, going to Settings -> About Phone and tapping on "Build Number" 7 times should do it. You should get a toast notification saying that you've enabled developer mode. Now go to Settings -> Developer Options and turn on USB Debugging. Now plug in your phone to your computer using a charge + data USB cable.
Now download or clone the project from GitHub. Once you have it locally, open up the it in Android Studio, and hit Run (the green play button on the top toolbar). Select your phone from the list and hit OK. On your phone, it will ask if you trust the computer you are connected to. Hit "yes" (or "always trust this computer" if it's your own, secure machine). The app should compile, install on your phone, and open up.
Step 12: Using the App
Usage of the app is fairly simple.
- If you haven't paired the HC-05 with your phone already, do so in Settings -> Bluetooth.
- Hit "connect" from the options menu in the top right corner.
- Choose your device from the list
- After a couple seconds, you should get a notification that it has connected. If not, check that the Planetarium is powered on, and not on fire.
- Choose a date. Scroll up and down on the month, day, and year combo pickers, and use the arrow buttons to jump backward or forward by 100 years at a time.
- Hit send!
You should see the Planetarium begin to move its planets at this point. If not, make sure it's powered on.
Step 13: Final Remarks
Being my first tangible project, it is an understatement to say that I learned a lot. Seriously, it taught me tons about everything from code revision maintenance, to soldering, to project planning, to video editing, to 3D modeling, to microcontrollers, to... Well,I could go on.
Point is, if you go to USF (Go Bulls!), and are interested in this type of stuff, take the MAKE Course. If your school offers something similar, take it. If you aren't in school or don't have a similar class, just make something! Seriously, this is the hardest step. Getting ideas is hard. But once you have an idea, run with it. Don't say "oh, that's stupid" or "oh I don't have time". Just keep thinking about what would make that idea awesome and do it.
Also, google around to see if there's a hackerspace near you. If you're interested in making hardware and software projects, but don't know where to start, this would be a great place to start.
I hope you enjoyed this Instructable!