Bluetooth-controlled Car – Part 2

Now that the hardware was functional, I had to make it respond to input from the user. This had two parts: the Arduino software and the controller app on the phone.

Arduino Software

It took a bit of experimentation but I was finally able to run the motors at the correct speed. My aim was to create methods that moved the car front, back, left and right. And, of course, the all important stop command. To test it, I wrote a small program that invoked these methods and made the car go in all directions.

I then modified the loop to accept commands from the Bluetooth controller. Since all I read was bytes, I used the ASCII characters (‘f’, ‘b’, ‘l’, ‘r’, ‘s’) to denote the various commands that the car understood.

iOS App

For the app, I decided to use Swift. This was my first time writing an app and I ended up using the Internet as my guide! I learnt that iOS apps use the CoreBluetooth library. I ended up creating a BluetoothManager object that was responsible for detecting when peripherals were in range as well as connecting to them. Since I wanted the application to be seamless, I was going to have the app automatically detect when the car was in range and connect to it. The user could then send commands via the interface. I chose to use a Single View App as my base project. The app looked as follows:

Once the car was in range, the app would connect to it. The user could then use the buttons to send the car forward, back, left, right and stop the car if necessary. If for any reason, the connection to the car was lost, the user could force the connection by tapping on the Bluetooth icon. The app would only accept commands if the car was connected. You can see a video of the car working below:

 

View this post on Instagram

 

A post shared by 3D Printing/Making (@anmolmaker) on

This is part 2 of my bluetooth-controlled car. You can read Part 1 as well.

Marvel Science: If you were hit by Captain America’s shield, would it kill you?

I recently re-watched Captain America: The Winter Soldier, in which Steve Rogers spectacularly throws his shield at his enemies to incapacitate them. Action scenes like those left me wondering: would the thrown shield’s impact actually kill those soldiers in real life? In the MCU, Steve throws around his shield like it’s no big deal, hitting villains left, right and center, but it’s always left unclear whether the impact leaves the villains simply unconscious or actually dead. To find out what would happen if one were caught in the crossfire of Cap’s shield, I took to physics.

To calculate the famous vibranium shield’s impact, I needed to first determine the shield’s physical properties, such as its weight. According to the Marvel Database, Captain America’s shield weighs 12 pounds (5.44 kg) and is 2.5 feet in diameter (0.762 meters). Now, I know what you may be thinking, “Captain America’s shield is made of vibranium, so doesn’t that change the values?” But, the problem with taking this fact into account is that we don’t know much about vibranium as an element, so it’s impossible to replicate those results in real life.

The simplest way to account for vibranium is to take into account exactly what we see on film. Using the incredibly powerful Open Source Physics software, I took various trials of Steve throwing his shield and tracked it to get various velocities (the gif below shows one of those). I then took all the values and averaged them out (which gave surprisingly similar results) to get a velocity of 18.77 m/s (~42 mph).

So, abiding by the rules that the MCU gives us, we have a 5.44 kg disk of metal flying at someone at 42 mph (18.77 m/s). Sounds pretty dangerous, huh? So, what’s happening to the poor guy that’s getting a full serving of justice? Well, let’s first look into energy. The formula for kinetic energy is \(\frac{1}{2}mv^2\) and using the values we got before we can find the kinetic energy this shield has. This value turns out to be 961.9 J. This is the translational kinetic energy. But when Steve is throwing his shield, it’s not only moving linearly but also spinning. That means we need to calculate the rotational kinetic energy of the system using \(\frac{1}{2}Iw^2\). To calculate this, we would need to approximately figure out the moment of inertia (I) of the shield and the angular velocity (w) of the shield. First, let’s determine moment of inertia.

So, Cap’s shield kind of looks like the top part of a sphere, if you were to chop off a slice of it. We know the radius of this shield and the depth of the shield, so if we can find the radius of the sphere the shield came from we can determine the moment of inertia. Take a look at the picture below for clarification.

To find the radius of the bigger sphere, we would use the Sagitta Theorem. Using this theorem, we take the sagitta (or the length from the top of the shield to the ground if it is lying flat) and the half chord length (the radius of the shield) and use it to find the radius. We do this with the formula \(s=r\pm\sqrt{r^2+l^2}\). This gives us the sphere radius of 0.8609 meters.

Now that we have the radius of the sphere, calculating the moment of inertia is a simple integral. Check out the picture for my work, but instead of boring you with the calculus, I’m going to tell you the value which is 0.645576 \(kgm^2\). Quick note, in this case, we’re assuming the shield is a thin shell as it is probably closer to the rules of vibranium than a shield with thickness.

Now, to find angular velocity. To do this, we need to go back to the videos. All I had to do was count the amount of times Cap’s shield rotated in a certain time frame. This was actually difficult for two main reasons: 1) Cap’s shield is going 18.8 m/s and 2) camera angles, but I managed to get a good estimate by counting the rotations in slow motion and then speeding the video back to normal speed and measuring the actual time it took to spin. Doing various trials got me an average angular velocity of 65.3 rad/sec.

Now, it’s another plug and chug situation. We take the formula from before (\(\frac{1}{2}Iw^2\)) and just plug in the values. This give us a rotational kinetic energy of 1376.40 J. Kinetic energy is additive, so we add the translational and rotational kinetic energies to get a total of 2338.30 J. That’s a lot of kinetic energy dispersed over a small area. But, to clarify this value, let’s take a look at the force that is applied to our unlucky villain.

To do this, we need to take a look at momentum. Because the time that the force is applied is constant, we can use the formula F = (\(\frac{mv}{t}\)). This formula comes from Newton’s first law (F = ma) as a is equal to v/t. To find the time Captain America’s shield is in contact with the person, I again took various shots to get an average time of 0.015 seconds. So, the average force that our man would be experiencing is a tremendous 6,818.13 N.

Now, to find the force on the guy at a specific point, we would use Ft = Impulse = Δp = FΔt. This might seem like we’re repeating the same steps as before but this time we are looking at the velocities directly before and after the collision. The average I got for an velocity right before impact was about 26.4 m/s and the shield’s velocity right after the collision was 5 .5 m/s using the Open Source Physics software once again. Here’s what’s happening:

So, Δp = p\(_{f}\) – p\(_{i}\) = mv\(_{f}\) – mv\(_{i}\) and if the left positive direction is positive, we can keep both velocities to be positive (both velocities are heading to the left). Now, mv\(_{f}\) – mv\(_{i}\)= (5.44 kg)(5.5 m/s) – (5.44 kg)(26.4 m/s) = -113.696 kg*m/s. This is the impulse of the man on the shield so the impulse of the shield on the man is 113.696 kg*m/s.

Impulse equals the force time the change of time so now force is easy to find. The average time of contact for the shield hitting the person is 0.021 seconds. So now we put that into the equation to get 113.969 kg*m/s = F\(_{N}\)(0.015 sec) to get a force of 7,597.93 N. That number makes total sense as it’s a 12 lb disk going 42 mph (5.44 kg disk going 18.77 m/s). To put that number in perspective, normal human being has a 25% chance of breaking a bone at 4,000 N of force.[note 1] The shield, which hits someone with 7,597.93 N, has a 47.48% chance of breaking bones which is basically taking a 50/50 chance at not getting hurt. But, one thing that we fail to take into account by these numbers is the shield is effectively hitting you at a single point, which in turn means a lot of force will  hit you within a small area. This means the shield is definitely breaking bones and if it hits anywhere on your body, you’re not going to be too happy about it and, well, you’ll probably be dead.

In conclusion, if you were hit by Captain America’s shield, you definitely would not make it out alive, so it’s better to not to take on the Star-Spangled man with a plan.

Notes:

  1. Brute Force: Humans Can Sure Take a Punch

Bluetooth-controlled Car – Part 1

For a few weeks now, I have wanted to find an interesting project where I could pair up my 3D printing skills with the Arduino. I also wanted to try something new and decided to combine it by writing an iOS companion app. This led me to deciding to build a electric car that could be controlled via the phone’s bluetooth.

The 3D Model

I wanted my car to look realistic so I did some research and came up with a design that was both practical and interesting. The 3D model would have two main parts: a base and the body. The base had to be large enough to house the motors, Arduino and the sensors. It would also need to have four grooves that would be used by the wheels. The design of the body was pretty straightforward as you can see below. I used some of the design elements from the real car I drive, a Honda Civic.

Base

Body

Both the base of the car and the body were designed using Fusion 360. Fusion 360 is a great program because it’s free and works well for creating basic shapes. I used photos of a car and using the line tools, created a sketch on top of the image. This sketch was the basic shape of the car and was then extruded out to create a basic car shape. Two holes were cut out (using premade cylinders) for the wheels and then details were added (with the premade shapes and shapes created in sketch mode) and altered in the sculpt mode. I had to cut my model in half because my print bed (a Lulzbot Mini) was too small for the size that I wanted to print at. Honestly, I wish I had a better way of dividing my model because the seam in the base became a issue when connecting the two halves. I had designed the model so the base would be able to fit snuggly underneath the body, but the tension was too great and caused a crack on one side of the model. With hindsight, I should have made the body a bit bigger to better accommodate the internals. Overall, it took about 14 hours to print the base and body of the car at a 0.25 layer height.

Putting It Together

While the internals of the car are not exposed, I wanted it to look clean. I’ve always been fascinated by the clean internals of Apple devices. I placed the Arduino microcontroller in the center of the base and surrounded it with the four DC motors. The motors had motor shafts on them which were then connected to the wheels. Lastly, the bluetooth module was mounted to the Arduino. The black tape below was needed for me to keep my two halves connected since I printed my design in two halves due to my printer bed size. As Adam Savage has taught me over the years, nothing duct tape can’t fix!

One of the tricky parts was making sure that the motors were connected properly to the motor shield. I had to orient the four wires as below:


Next was the bluetooth module to pair the robot with a phone. I chose the HC-08 for this project. The module had 6 pins, but I only needed to use the RXD, TXT, GND, and VOC pins. These pins connect into the Arduino in the respective pins (RXD → RX (0), TXT → TX (1), GNG → GND, VOC → 5V).

Next I attached the wheels and spent some time painting it using the colors of my favorite Marvel character, Iron Man. Finally, my car was ready!

In the second part of this post, I’ll detail the software components of the car. In particular, the iOS app that sends commands to the car and the Arduino software that interprets these commands and moves the car. Stay tuned!

Parts List