Pages

Tuesday, January 16, 2018

How to use an Osepp Motor controller shield

A few weeks ago I bought an Osepp motor controller shield for the robot I'm building. All I needed it to do was control four Roomba vacuum motors, which I thought would be pretty simple. There weren't any instructions that came with the shield, but I figured it wouldn't be to hard to find some online.
But it was. I found almost nothing.

I did get it working eventually though, mostly through trial and error, so now I can explain to other people how it works. (Well, at least how to control DC motors with it.)

First of all, here is a diagram of the board:

This looks complicated, but it's actually quite simple to understand. I could explain what everything does individually, but that would take too long and not be very interesting. Instead, try this simple circuit.

Materials:
  • Arduino
  • Osepp motor shield
  • small DC motor
  • 6 volt power supply (a pack of AA batteries will do)
  1. Start by mounting the motor shield on the Arduino board. Carefully slide all of the leads on the bottom of the shield into the black terminals on the Arduino. They should be around two thirds of the way in. Don't try to force them further, as doing this could make them bend and possibly brake off.
  2. Next, take the two leads from the motor and insert them into the motor one connectors on the shield. Polarity doesn't matter for now. Grab a screwdriver and tighten the screw terminals until the motor leads are secure.
  3. Plug the 6v power source into motor VSrc on the top left corner of the board, with the positive terminal on the right and negative on the left. A light should come on.
  4. Finally, plug a USB cord leaing to you're computer into the USB port on the Arduino board. Open the Arduino IDE and follow the steps to program it, or copy the entire program. Upload it onto the Arduino and watch it go!
  5. Running a DC motor with the motor shield
The Programming
Type the following code into the Arduino IDE, or, if you prefer, copy and paste it.

    #include <AFMotor.h>
    
    AF_DCMotor myMotor(1, MOTOR34_64KHZ); // create motor #2, 64KHz pwm
    
    void setup() {
      Serial.begin(9600);           // set up Serial library at 9600 bps
     
      myMotor.setSpeed(100);     // set the speed to 200 (maximum speed is 255)
    }
    
    void loop() {
      myMotor.run(FORWARD);                   //run motor forwards
      delay(1000);
      myMotor.run(BACKWARD);
      delay(1000);
      myMotor.run(RELEASE);
      delay(1000);   
}




Let's go over all those commands.
  • #include <AFmotor.h> this command tells the arduino IDE to include commands from the adafruit motor controller library. It must always go at the beginning of the program.
  • AF_DCMotor myMotor(1, MOTOR34_64KHZ); this command tells the program to include a motor named myMotor connected to the motor one connectors, which runs at 64 kilohertz. You can change the name of the motor and what connector it's in, but just keep it like this for now.
  • myMotor.setSpeed(100); this sets the running speed of myMotor. It can be used once in the setup area, or to change the speed in the loop area.
  • myMotor.run(FORWARD/BACKWARD/RELEASE); use this command to turn on or off motors and decide which direction they turn. FORWARD and BACKWARD turn the motor on, and RELEASE turns the motor off.
  • delay(1000); this command sets a delay in milliseconds.
Now you can make your own programs! This isn't all you can do with the motor shield, but it's all I know how to do. For more information on commands and programming look at https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino. You can skip the non-programming parts, as it was written for a different (but code-compatible) shield.

Saturday, January 13, 2018

Quantum Supremacy Experiment: Lecture Response

    I have been going to a UBC lecture every thursday for a while. The most recent one was by John Martinis, who is working with Google to build and test quantum computers. The lecture was about an upcoming experiment by him and his team, which will hopefully demonstrate the superior power of quantum computers by checking the results from one with a classical supercomputer.
So what is a quantum computer? Many people have heard of them, but it’s quite hard to understand how they actually work.
    In normal computers, information is stored in the form of ‘bits’, which can either be 1 or 0. The 1s and 0s are processed by millions of tiny electrical switches called transistors, which can either be on or off. Modern consumer grade computers currently can have up to 7.2 billion transistors, and the number is constantly rising- but eventually it has to stop. Transistors are extremely small, and we’re reaching the minimum size; if they were to get much smaller, electricity starts to behave in strange ways- like jumping from wire to wire through a weird process called quantum tunneling.
    This is where quantum computing comes into play.
Instead of the bits of classical computers, quantum computers have Qubits, which, instead of just 1 or 0, can be 1 and 0, and every combination of the two of them.
If a classical bit was a coin sitting on a table, a qubit would be a coin floating in space. Instead of just heads or tails, it could be at any angle or combination of them.
    So what use are qubits? Are they any better than classical bits? They are a lot better. And their power increases exponentially; For example, a processor with just 50 qubits would be almost as powerful as our best supercomputers, while one with around 300 qubits would be able to process every atom in the whole universe (in other words, 1080, or a 1 with 80 zeros after it). While most computers can only do one thing at a time, quantum computers can do millions, which is water makes them so powerful.
    Why don’t we all have quantum computers, then?
First of all, qubits are quite hard to maintain. Current qubits involving superconductors require complex cooling systems to keep them working. But that’s not the main problem; the most difficult thing about qubits is that they aren't necessarily always accurate in their calculations.
Let’s go back to the coin analogy, with the classical bit being represented by a coin on a table. Classical bits might have some randomness or outside interference, but they always have the restoring force of the table underneath keeping them stable. Quantum bits, on the other hand, are floating in space, and any outside interference can cause them to turn any which way, messing up whatever operation they are trying to complete.
    Despite this challenge, qubit technology has come a long way recently, breakthroughs are being made all the time. Hopefully within a few years we will have a working quantum computer!

The Remarkable Accuracy of Colour Perception: Lecture Response

    Last week I went to a lecture by Lorne Whitehead, who is a physics professor and professional engineer at UBC. The lecture was about new discoveries about colour processing in the eye and brain, and specifically the unlikely-seeming accuracy of colour perception.
I didn’t understand most of it, but I’ll tell about some of the interesting facts that I did get, and then hopefully you will understand them to.
    Trichromatic (colour) vision evolved as a way to see what things were made out of, or what was inside them. Our early human ancestors originally saw light in the UV range, as many birds and other animals do still. But as humans became more diurnal (awake in the day), it became more beneficial to see colour. It helps us judge what fruits to eat, decide when meat is done, tell how healthy people are… and many other things. This is pretty obvious.
    But something unexpected was how accurate our colour perception turns out to be. While most of our senses (smell, temperature, etc.) have around a 50% percent accuracy, the accuracy of colour perception is around 5%.So why is colour vision so accurate? Think about a banana. You can easily tell if it’s it’s good or not with one look- even though it’s colour barely changes at all.
    Another interesting thing Dr Whitehead mentioned was an answer to someone’s question at the end of the lecture. Someone had asked if he was worried about humans losing colour vision, since it wasn’t necessary for survival anymore, to which he answered no, but he said he was “very worried” about what screens did to us. Screens are always getting better, which often includes more vibrant colours and contrast, which he says is very bad for our eyes. According to him, it can take up to a week for our eyes to fully recover from viewing a contrasty screen. Luckily, we can easily avoid this problem; almost all screens have ways of adjusting the colour and contrast.
    Lastly, I want to show you an interesting image that Dr. Whitehead used in his slide show. It shows what the raw signal coming out of your eye looks like.
https://i.pinimg.com/originals/fc/ea/76/fcea76d986367493f568789540cc75b9.jpg
That is all you’re eyes actually see- anything else is a result of your brain’s processing.

A Stars Life

    There are around 1024 stars in the universe, and each one is a bit different from the others. But what every star has in common is their life cycle. From a huge molecular cloud to a main sequence star, to a giant, and then, finally, a supernova, each star lives an exciting life. Read on to find out more!
   
    Stage one: Molecular Cloud
A molecular cloud is a giant accumulation of gas and dust (mostly molecular hydrogen) in outer space. Molecular clouds are quite cool as compared other parts of outer space, at around 10 - 30 degrees kelvin (around -230oC). Molecular clouds can be up to 600 light years in diameter, and their mass can be up to a few million solar masses (around 0.7x1034 kilograms). These clouds aren’t totally homogeneous- they contain areas of higher gas and dust density, known as knots, or cores. It is in these knots where stars begin to form.

    Stage two: Protostar
A protostar is the first stage in a star’s evolution. First suggested by Chushiro Hayashi in 1966, a protostar is formed when one of the knots in a molecular cloud begins to contract, and then gain mass, which in turn causes them to contract further due to increase in gravity. The resulting clump of hot gas and dust is a protostar, which is around the size of a solar system. As the protostar gains more gravity, it continues to heat up and attract material, which is pulled into a disk around the star. In stars the size of our sun this stage last for about a million years.

    Stage three: Proplyd
The proplyd is a large (around 100 AU across) pancake-shaped disk of gas and dust that forms around a million years after the protostar, which has at this point shrunk to around one AU (astronomical unit) in diameter. The proplyd is thought to be what planets eventually form from, with the dust compacting to form planets orbiting the star. These proplyds are strong infrared sources, with hot and active centers, which gradually cool off and bulge towards the edges. Proplyds are also known as protoplanetary disks.
   
    Stage four: T. Tauri star and Bipolar Molecular Outflow
After another million or so years, the protostar has again shrunk to form what is known as a T Tauri star, which is the name of the first star of this type discovered. T Tauri stars are highly active young stars, generally a few times the diameter of our sun, which means they appear brighter than other stars of the same mass. T Tauri stars spin rapidly, and they are characterized by their large solar flares caused by intense magnetic activity, which also causes huge sunspots to form over large areas of the star.
    Bipolar molecular outflow
As a T Tauri star pulls gas from it’s protoplanetary disk, it ejects it outward in two particle beam jets perpendicular to the disk, which light up when they interact the gases surrounding the star. These beams form bright nebulae known as Herbig-Haro objects.

    Stage Five: Main Sequence Star
After around 10,000 years of bipolar molecular outflow, the T Tauri star gets hot and massive enough to initiate fusion in its core. At this point the star is, so to speak, fully grown, or a main sequence star. It is estimated that around 90% of stars in the universe are main-sequence.
Fusion is the process wherein hydrogen atoms combine to form helium, releasing 0.7 percent of their mass as pure energy in the form of heat and radiation. This doesn’t sound like much, but according to Albert Einstein’s famous equation, E=mc2, one gram of mass converted into energy would be around 900,000,000,000,000.0 joules. One joule is approximately the energy used to lift an apple, so you could lift 0.9x.1014 apples with this much energy. Technically.
This means that our sun (an average-sized star) produces approximately 0.4x1014 joules of energy, which is equivalent to the energy produced by about a trillion tons of TNT going off every second.
The lifetime of a main sequence star depends heavily on its size. A small star can last around 80-100 billion years, while a large star (around 100 times the mass of our sun) may last for only around twenty million. The fact that large stars have such short lives seems counterintuitive, but is caused by the fact that they use up their fuel (hydrogen) at a much faster rate than smaller stars.

    Stage six: Giant
Once all of a stars hydrogen is converted to helium, a star’s core will collapse upon itself, causing the outer layers to expand forming a subgiant, and then finally, a red giant, the red colour being caused by lower surface temperature. Red giants are generally 0.3 - 8 solar masses, their size depending heavily on the original size of the star. Extremely massive stars can sometimes even form into an even larger class of giant, known as supergiants, whos size also depends on the size of the star, but is estimated that a large supergiant could be up to 2,600 times the size of our sun.
Stage seven: Core Fusion
As the star expands and the core shrinks, it starts to fuse the helium inside it. This forms other atoms, which also start to fuse, while the core keeps shrinking. This process keeps repeating until iron is formed, which is the first element that takes more energy to fuse then it makes. Since the star has at this point stopped making energy, the fusion stops.

    Stage eight: core collapse supernova
When the core of a massive star stops producing energy, the outer layers of the core collapse, which creates a massive explosion called a supernova.
    According to Dr. Donald Spector, a Hobart and William Smith Colleges physicist, “However big you think supernovae are, they’re bigger than that.” although this claim is obviously and irreparably paradoxical, it is a good rule of thumb when estimating supernova-related numbers.
    Dr. Spector’s rule certainly applies here. The amount of energy produced by a normal-sized supernova is around 1044 joules. To put that into context, that is equivalent to 2.39x1060 megatons of TNT. A supernova can outshine an entire galaxy.
And that is how a star dies.
   
    After Death: Dwarfs, Neutron Stars and Black holes
Not all stars produce supernova. Medium to small stars, such as our own sun, simply shrink to become what is known as a white dwarf. White dwarfs are extremely dense. A white dwarf with the mass of our sun would only be around as big as the Earth. White dwarfs don’t produce fusion; they glow purely from their thermal energy, and last for billions of years.
    When larger stars (between 10 and 29 solar masses) collapse as a supernova, they often form an incredibly dense Neutron stars. These stars are even denser and smaller than white dwarfs, with stars around ten kilometers wide weighing twice as much as our sun. These stars are believed to be made almost entirely of neutrons, and there are a few different types of them. Most neutron stars are known as Pulsars, due to their pulsating radio signal. This is caused by a combination of extremely rapid rotation and a beam of radiation jetting out of the magnetic poles. Another kind of neutron star is the Magnetar. These neutron stars have a huge magnetic field, around a thousand times the strength of an ordinary neutron star.
    The largest supernovae can form Black Holes. These strange objects are so massive that they collapse into a dimensionless point known as a singularity, which has infinite mass. Almost nothing escapes a black hole’s gravity. Not even light, or electromagnetic radiation. Matter can only escape a black hole in the form of hawking radiation, which is still purely theoretical. There is believed to be a supermassive black hole at the center of our galaxy.
And that is a star’s life.
A star’s life

From birth as a protostar, to the formation of a protoplanetary disk, to the transformation into a red giant, then finally, to death as a supernova. Every stage of a star’s life cycle is awesome. To learn more, see the sources page below.

REFERENCES
Molecular clouds
http://www.sun.org/encyclopedia/molecular-clouds-and-dark-nebulae
Energy from sun
http://archive.boston.com/news/science/articles/2005/09/05/how_much_energy_does_the_sun_produce/
Main sequence stars
https://www.space.com/22437-main-sequence-stars.html
Amount of zeros because I don’t know for some reason
https://www.quora.com/How-many-zeros-are-in-1-million
Main stages of a star’s life
https://sciencing.com/7-main-stages-star-8157330.html
Energy conversions
https://www.unitjuggler.com/convert-energy-from-J-to-MT.html?val=1.0E-44
Dr. Spector
http://people.hws.edu/spector/
Info on white dwarfs
https://en.wikipedia.org/wiki/White_dwarf
Info on neutron stars
https://en.wikipedia.org/wiki/Neutron_star
Info on black holes
https://en.wikipedia.org/wiki/Black_hole
Dr. Spector quote:
What if? By Randall Munroe
Info on star life cycle:
The Illustrated Atlas of the Universe By Mark A. Garlick and Wil Tirion

Knife handdle update!

It looks better now! I got a new soldering iron, and it's really hot, so I burnt designs into my handle to make it looker better.