Wednesday 14 November 2012

MSP430-ing for TI's Analog Design Contest

Hey everyone! So in the previous blogpost, we showed you the Mastodon video and also promised you details about a quadcopter build.
And guess what?
WE HAVE BEGUN! :D
Well, sort of.


The quadcopter is for Texas Instruments' Analog Design Contest that's being held in India. We've already finished Phase 1A, where we had to work on their Analog Lab Starter Kit and solve a problem statement.
You can find our answer here. I'm sure that most of it is wrong, and if you know the right answer, please let us know.

So moving on, for the quadcopter, we did a little bit of preliminary research. We have no idea about the physics and everything. We wanted to build one that can be used for surveillance, reconnaissance and search and rescue during disaster time and otherwise, simply because it will add more value to the project.
Our first stop.


While looking for quadcopter parts online, we immediately found out that hobbyking was the place to acquire all our parts. 
So we ordered our BLDC motors, a frame, batteries, electronic speed controllers, the FPV gear and other knick-knacks. We'll get to those later when we actually start to build the thing. 
Patience, my friend. 


Pretty shiny, right?



And we also needed an Inertial Measurement Unit that contains the accelerometer, gyro and compass, so that we get the state of the quadcopter in flight and allow the algorithm to use the readings in order to stabilize and do other cool stuff. We used DIYDrones ArduIMU+ V3.










Texas Instruments was generous enough that they gave each team participating in the competition (and there are around 300 plus teams) 200USD worth TI components for free! 



So we asked for a couple of MSP430 Launchpads, an EZ430-RF2500, a CC2500EMK(it's just a RF module) some LED drivers, Li-Ion battery management chips(just to see if we can try to build a charger ourselves). 

So while we wait for the stuff from HobbyKing to arrive, we thought we should get started on learning about the MSP430 launchpad and all it's functions like PWM, I2C, SPI and OTHER THINGS THAT WILL BLOW YOUR MIND. 

MSP430 Launchpad, just like an Arduino, except, well, redder. 
The MSP430 launchpad is basically a really inexpensive target board for MSP430 microcontrollers. You place a MSP430G2xx microcontroller in the socket, select the right device and write all your code in Code Composer Studio (or any of the other software tools), and you can flash program and debug your MSP430! :D
It's pretty awesome, and in construction seems very similar to an Arduino? But I wouldn't recommend it for the absolute beginner. If you have an idea and you want stuff blinking or moving within a matter of minutes, go for an Arduino. 
But if you want to take your time then you can buy around three Launchpads for the price of one Arduino.
Or you can try this(Which is pretty awesome. I need to check it out).
It actually took me quite some time to understand the code that blinks the on-board LED's. But as we're learning, we'll talk about everything and if you're as stumped as we are about learning about the Launchpad from the internet, then hopefully our blogpost/tutorial things will help you out.

See you soon! 

Sunday 29 July 2012

Mastodon 1.0 - The Movie

Finally, the movie is done! 
There are a couple of things in the video that we left in intentionally, lets see if you get both of them! =P





If you want to know anything about the build, do let us know. There were a few problems we faced with it, mostly because the platform was a rat's nest of wires on top of a breadboard which was held down by a rubber band and a whole lot of tape. And if you do that on a moving platform where almost nothing is held down with solder, stuff is bound to come flying out.

Also, we're planning to post more regularly, and keep checking this spot, because a HUGE quadcopter build is on it's way!!

So until next time, keep making!

Friday 13 July 2012

Mastodon 1.0 and DIY Dinner



About a week ago Bhargav started working on a bluetooth controlled car. It was inspired by this instructable. It consisted of four motors connected to a mechanix frame. If you don't already know what mechanix is, it is a kids toy used for building structures using nuts and bolts.  

Mechanix.
If you haven't used it as a child,
you're probably nuts.



To this he attatched a 12V battery to power the motors and a L293 H-Bridge motor driver IC. And he used an Arduino Uno along with a bluetooth module for controlling it. He used a 9V battery to power the Arduino. It looked something like the picture below.


Now lets look into a few details before we proceed. First, the L293. The L293 is a motor driver used to control the direction of rotation of motor rotation using digital signals. That means that by using the digital output pins of the Arduino you can control the motor. It works with two digital inputs for each motor, and it can control 2 sets of motors independently. You can also have a separate power source for the motors (we used the 12V one).

The logic table is something like this.

A and B refer to the digital inputs.
The basic idea that shines here is the you can change direction of the motor digitally.



What we did was we tied up two motors together, both the left ones and both the right ones, so that they can be controlled simultaneously. So if we wanted to turn the vehicle to the right, we would turn only the left motors or vice versa. One limitation with this usage that we noticed was that we cannot move and turn simultaneously. It has to move, stop and only then turn. 

Now lets look into the control. We used the bluetooth module, the same one we used in Ayana '12 along with this Android app called Blue Control available for free in Google's Play store. It is a very simple app which has direction buttons and a bunch of other buttons. 

The center button actually opens a Blue portal.
The orange one is in Narnia.
When you pair your phone with the bluetooth module, it sends certain ASCII characters to the bluetooth module which can be serially recieved by the Arduino. The ASCII character which is sent depends on the button which is pressed on the app.


So what our Arduino code should basically do is receive these serial signals and send appropriate signals to the motor drivers such that they activate the right motors.

Its that time again, time for a block diagram.
A picture says a thousand words, this block diagram says sixteen.
Problems, problems and then some.
One major problem we ran into was, after a couple of minutes of neck breaking speeds the motor driver would heat up. And this would cut off supply all motors due to its automatic thermal shutdown feature.

We decided to pick up the L298 motor driver instead because it seemed to have better thermal stability and a heat sink as well. 
The only disadvantage with this was that it was only available in a Multiwatt-15 package as opposed to a dual-inline package. We took more than three hours trying to fit this thing onto a breadboard and trying to make it work without any loose connections but to no avail.
L298N: ST MICRO
The L298 Multiwatt package, breadboard's arch nemesis.





DIY Dinner.
We decided to take a break for dinner and went out shopping for instant noodles which we usually buy on all-night soldering parties like this one.
But instead we decided to make something a little more interesting so we bought:

There is something magical about eggs.

    •  Mozzarella cheese
    • One loaf of whole wheat bread
    • Mushrooms
    • Half a dozen of eggs
    • Maggi Pizza sauce




    That is a killer knife right there.

    What kind of a hideous dinner we made from these you ask? We made some ommlettes and bread pizzas. Its quite simple actually, you just pretend your bread slices are the pizza base and top it like you would a regular pizza. We bought whole wheat bread because we are health conscious. No, really. 

    Anyways we sauted the mushrooms and some onions before putting them on the pizza. We put them in the oven for about 15 minutes and we had lovely bread pizza. 
    Don't try this at home.

    Before.

    Artistic oven shot.

    After.
    We did a little experimenting with the omlettes too. We made cheese omlette with mushrooms and herbs. Check it out.
    Mushroom omlette. With Shyam's secret recipe
    that no one will know.

    Cheese omlette with herbs.


    Revival.
    Well we spent a good three hours in the kitchen, and we were tired and full so we decided to turn in. But Bhargav decides to try the circuit out one last time before that. And as we listened to some Color Haze we suddenly hear the whirr of the motors, it finally works!
    We are not superstitious. We really aren't.


    Anyways this got us really excited so we decided to shoot some videos of it and do a couple of test runs on the street. We taped a camera onto it to get a first person's view.
    And who doesn't love blue LEDs? So we decided to include a blue LED into the circuit, for *ahem* better vision.
    This is how it looked with the
    camera taped on it.
    You can never go
    wrong with a blue LED.














    All of this leads up to the video we are making of it. We decided to call it Mastodon 1.0. (Why? Because Mastodon is awesome). 

    You can see the trailer here.





    Stay tuned for the actual video.

    P.S. - The Arduino code we used is here.

    To a web browser near you.


    -Akshay

    Tuesday 1 May 2012

    Ayana12 - Hackathon idea: Android-Arduino-Bluetooth-Twitter-thing


    The open source group in our college hosted a 24 hour hackathon last week called Ayana 2012. We'd heard that they were allowing hardware hacks too, we were totally excited about it and decided to check it out! 


    After a couple of days of idea spit-balling at Akshay's place, we decided to go ahead with making an Android-controller thingy that lets us use a phone like a steering wheel or however you wanted to use it. After dabbling around with TCP, UDP, Telnet, SSH, and all those other wonderful wonderful networking protocols, we decided to go ahead with bluetooth. 
    Now again, we just couldn't figure how to send sensor data directly from the phone to the computer we were using. Until Shyam found out that we could use a bluetooth module on the arduino to receive sensor data from the phone using The Amarino App on Android. The arduino, once receiving, can send some serial message back to the computer and that in turn generates a keyboard event.  

    Now this app is amazing simply because of it's amazingly simple interface that easily connects to our bluetooth module and send sensor values serially to the computer! It's amazing! 

    So the next part we thought was pretty simple.

    1. Read sensor values.
    2. Setup a threshold to send a serial message.
    3. Convert serial message into a keyboard event.
    Not that simple. The code was still buggy even after working on it for several hours. We'll put it up once it's nice and all. But it's loosely based on This Instructable (which I think is really cool and shall definitely try out as soon as I get the time)

    And after that part was kinda down, we needed to create keyboard events. Again, not so simple. But after Google searching for several hours looking at Java libraries and all that, we came across: 

    Serial2Keyboard

    Not many times does a google search lead you to jump around in a manic fashion cursing happily, but this did. And something about this software is kinda buggy too, or maybe we still don't know how to use it. But it's brilliant! 

    All we had to do was change the hex values in the protocol.txt file to ASCII values and we were good to go! 

    Serial.println('a');

    would make the cursor go up, up, up! It was awesome. 

    But the reason I keep saying it was buggy because when we tried it on a game, we'd go left, and then we'd go right and then, yeah, we'd be stuck there. It just wouldn't go the other way. But it worked fine on notepad! DAMN. 

    Pissing off, man. 

    Anyway, I went and bought a bulb from somewhere and thought we could use it to demonstrate how we can turn on and off appliances using the phone. We got it working after a while, using the proximity sensor on the phone.
    It would just toggle on and off though, we couldn't get it to stay on or off. 
    We'll post the code once we fix that. 


    We also wrote a little python code that let us turn on and off the bulb using twitter! :D The time delay was terrible though, I'll write another post about it soon, as I have a lot more to say about it. 

    Overall, Ayana12 was a terrific experience. The atmosphere was humming with creativity and laptop fans. I managed to click a few pics too! 

    Shreya, Surabhi, and Aditi. Trying to look cool. 

    They had BEAN BAGS!!!!

    Shyam hooking up the bluetooth module to the Arduino.

    Anjana and her team, Vivek and Kiran. 

    Vincent. Showing off. He single-handedly won the whole thing later anyway.  :P

    Our station. 

    This guy had wireless-ly interfaced a 3x3 array of LCD screens and  was playing Die Hard 4 on them.
    It looked awesome!

    -Bhargav

    Sunday 11 March 2012

    Computer Controlled Light Bulb

    The first thing anyone ever does on the Arduino board is to make an LED blink. Some go even so far as to call it the ‘Hello World’ of electronics. We took it a step further and made a Light bulb blink.

    How is that different?
    An LED works fine with a 2V DC supply voltage.
    Billions of blue blistering LEDs

    A standard light bulb with a tungsten filament 
    works with the household 220V AC supply. (or 110V, whatever the local power supply is)
    How many DIY'ers does it take to screw in a lightbulb?
    This means that an LED can be directly connected to the Arduino board because the board’s digital pins are at 5V when they are in an ON state. There is no way the light bulb can be powered by the Arduino board.
    Its not JUST orange juice.




    How we solved it? 
    After some research, and a lot of Pulpy Orange, we came across these magical little things called relays. No, not the one involving the baton, but the basic philosophy still holds good.






    A relay is used when you need to control a circuit with a higher voltage with a low voltage signal.
    When you input a digital HIGH (that’s 5 Volts) it shorts the other two leads with almost no physical connection between the two circuits. Something like this.
    The circle like thing is the light bulb and the rectangle is the relay.
    A digital HIGH connects the output circuit.


    When you input a digital LOW (that’s 0 Volts) it leaves the other two leads open. This is like disconnecting the other circuit. Like this.
    A digital LOW disconnects the output circuit.
    So you can almost say the relay helps pass the baton from one circuit to the other. (You saw this coming:-P)

    The Arduino can send and receive serial data via USB to the computer. We used a simple Physical pixel code from the Arduino website available here. What it basically does is,
     if the Arduino receives an ASCII letter ‘H’ through the serial port then it sets the output pin to a digital HIGH. This eventually causes the light bulb to turn on because this HIGH is fed into the relay as shown above.
    When the Arduino receives an ASCII letter ‘L’ through the serial port it sets the output pin to a digital LOW, which in turn turns the light bulb off. 

    We wanted a way to control the light bulb with an app on the computer. We basically built a simple GUI using the Processing tool. What it does is it basically uses a Java code to generate an application on the computer through which it sends serial data to the Arduino. Note that we didn't use the mouse-over program which Physical pixel used. But they both work the same way and work equally well.

    So we used one of the example programs which creates a button and added a few things which makes it do what we want it to do. The code basically uses a
    port.write() command to send the ASCII characters to the serial port a.k.a., the Arduino.

    If you want the code we used its available here. It finally worked out in the end and you can see it in this video.


    Well, the project isn’t all that high tech. We were just experimenting with a concept, and it worked. We want to expand on this idea and eventually have a completely automated room. There is a lot more to come. So stay tuned.
     - Akshay

    Thursday 12 January 2012

    The Arduino Air Drums Part 2


    Doing things the way you see it, going by your own heart and soul, that is pure artistic integrity. Whatever the hair is six or sixty inches long, the eyes have make-up or not, the riffs are in 'E' or 'F' sharp, the amps are Marshall or not, all those things don't matter if you are doing it for the right reason, which to me means doing it for yourself! 

    “What's the message in Metallica? There is no message,
     but if there was a message, it really should be look within yourself,
     don't listen to me,
     don't listen to James, don't listen to anybody,
    look within yourself for the answers.”
    Lars Ulrich
    - this guy -






















    Although people hate Lars because he's not a great drummer and he sued Napster and can't play things right away and everything, you have to give it to the guy for being one of the most vocal drummer and speaking his mind out.
    Anyway, I wanted to start the post with a cool quote and it kinda blew out. Sorry. :P 

    So BACK TO BUSINESS!
    The drums aren't complete without pedals, right? We need the bass pedal to play the bass and a hi-hat pedal to open and close the hi-hat. If you're unfamiliar with the awesome kit that is the drums, Google has THE picture. 



    We followed mmidgal on his concept and used two slippers, one with a ADXL335 accelerometer and one with the photocell. 
    [UPDATE: The photocell that we got wasn't very effective in changing it's resistance fast, so we decided to remove this part of the kit completely] 

    So what we did was, we made a slit in our first slipper almost 3/4th the way in the front so as to insert the accelerometer. 



    The accelerometer was connected to the USB connector
     the same way that we had done for the sticks. 

    Now that we're done with all three of our elements, the easy part was hooking the circuit up. USB cables are awesome for the job, and pretty cheap as well! 





    Now we move on to 




    The Program 





    For the impatient, you can find the code Here.

    But I'd like to take a while and explain what we tried to do with the code and the problems that we ran into:

    Firstly, a useful function to see how the Arduino is 'reporting' back changes given by the accelerometer is the analogRead(pinNum)
    along with the Serial.println(var) function, both of these when used in one program displays the reading received by the Arduino program as illustrated here. The results are then printed on the Arduino's serial monitor. 

    Using the above program we noticed that the value printed changes when the accelerometers are moved in their respective directions. So we figured our basic logic would be

    if(valueReadBySensor > someThreshold) then return (a MIDI message)

    and that's just repeated for all the other accelerometers.

    One more important thing is that we could never get our MIDI to USB converter to work with our program, after days of searching, we chanced upon a brilliant little piece of software, that reads MIDI messages directly from the USB port without the use of any DIN connectors or anything!!

    It's brilliant and so simple to use!! Just select the output port as Microsoft GS Wavesynth and you're good to go! We experimented with other softwares and virtual MIDI ports such as LoopBe and MIDIyoke but we could never get a sound out of Reaper or Audacity. 

    Alright, so now you have your simple piece of code to play a note when the accelerometer moves an appropriate amount.

    void loop()
    {
      int threshold = 375;
      int reading = analogRead(A0);
      if(reading > threshold)
      noteOn(9, 35, 120);
            } 


    [You will find the definitions for noteOn and everything in the code.]

    This is great now, but what was happening was since there were a bunch of readings above the threshold that appeared as the drumstick was flicked, the S2MIDI software gave us a 'trrrrrrrrrrrrrk' sound. 

    So, we thought delay() was a great function, which paused the function for a certain number of milliseconds. But this still was not good enough because we could never reach a compromise between a really low delay value and the 'trrrrrrk' sound.

    After days and days of experimenting, we finally decided that the code mmidgal posted on his video was the best, although we made some modifications to make it better.

    Dave Lombardo style. Well, almost. :P 





    We used arrays along with the function millis() which really increased the response of the drum kit and allowed us to play Slayer songs. Almost.








    A few things that we wanted to add were: 
    • A button on one of the sticks that when pressed, would play a pre-recorded drum roll.
    • A crash cymbal sound when the hi-hat stick is swung a bit harder [the code was also written, but it was still a bit fickle and we could never get it right, so that one line is commented out].
    • A more responsive bass pedal.
    • A ride sound when the stick is swung in the X direction. This we could never get right because it was happening even when the stick was swung in the Z direction.  




    And that's it, so try it out and if you have any questions about the code, about the concept, criticisms on the blog or any feedback, really, please leave a post or send us an e-mail at blimptech2012@gmail.com

    Sorry I couldn't post a demonstration video.. None of us are drummers, all of us are guitarists, actually, we'll make one as soon as we get our hands on a kickass drummer. :D
    Thanks for reading and happy drumming!!!



    - Bhargav

    PS: If you have an interesting project or idea, or recommendations for our next project, do share it with us, we would love to hear it!

    Wednesday 11 January 2012

    The Arduino Air Drums Part 1


    The summer before, as all of us were getting excited to start our specific engineering courses, Vincent got us all excited about a prototyping board called the Arduino,
     using which, microprocessor programming is made really easy! They have their own simplified coding language based on C and the editing platform is up for free download. Read it all up on their website: http://www.arduino.cc/

    And one of the videos that caught our eye was mmidgal's Arduino Air Drums.



    He had constructed a 3 piece drum kit with 4 sounds using a MIDI interface, 3 accelerometers, a Photocell, some USB ports, two garden rakes and a couple of slippers. All in an afternoon, according to Gizmodo. [which we SERIOUSLY doubt because it took us a little over a week]




    Shyam came up with the idea a couple of weeks before our semester end exams, and I was a little skeptical at first, but then I remembered my dream of always wanting to play kickass drums. Because, lets face it, drums are cool. Maybe not as cool as guitars, but still, pretty cool.


    So, on day 1, Shyam and I make our way to Malleshwaram, to meet at Akshay's house. We decided everything that we needed to get, and set our budget at around 4k and left to
    SP Road. 

    So, here comes the slightly technical bits: 
    Stuff we bought were: 
    1. The Arduino Uno
    2. ADXL335 accelerometers     [x3]
    3. USB cables      [x4] 
    4. USB females    [x8]
    5. 5 pin DIN connector 
    6. A no-company-comes-without-a-box MIDI to USB converter for Rs. 8oo, because the M-Audio Uno that the mmidgal recommends is 2.7k. lol. 
    7. A bunch of Photocells (they cost about Rs. 5 a piece, so we thought we'd build a keyboard later with them)

    All these items we bought, solely on the recommendation of the video and we didn't realize that some of them might be not necessary. Like the DIN connector and the MIDI to USB converter cable. :|

    Okay, before we continue, a little introduction into MIDI: 

    MIDI (Musical Instrument Digital Interface) uses a form of serial to communicate at a data rate of 31250 bps with each byte made of 8 bits plus a stop and start bit. MIDI commands are most often three bytes in length but sometimes more or less. The Serial-MIDI converter currently only handles three byte MIDI commands.

    The first byte is called the Status byte and contains both the type of MIDI command and the channel number. The high nibble of this byte tells the MIDI device what it is doing, such as Note Off, Note ON, Control change etc... The low nibble is the channel, it is used to differentiate between devices that are on the same MIDI bus and varies from 0 to 15.

    The second byte is the Pitch byte and is simply the note being played, stopped, altered etc... This byte is in the range of zero to 127.

    The third byte (when used with Note-On or Note-Off) is the velocity, which is a form of volume for the note being played. Imagine that you hit a drum softly, then the velocity would be a low number, but if you really whaled on it then the velocity would be higher. This byte is also in the range of zero to 127.


    And a little bit about the ADXL335 accelerometers: 
     Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors - the holy grail of accelerometers. The ADXL335 is a triple axis accelerometer with extremely low noise and power consumption - only 320uA! The sensor has a full sensing range of +/-3g.
    There is no on-board regulation, provided power should be between 1.8 and 3.6VDC.
    Board comes fully assembled and tested with external components installed. The included 0.1uF capacitors set the bandwidth of each axis to 50Hz.

    So all that it is is a little chip with an IC and a few capacitors on it. There are 6 terminals;
    VCC
    GND
    X OUT
    Y OUT 
    Z OUT
    Self Test (ST)

    Which are pretty self explanatory, basically the value of the at the three output pins change when motion in their respective axis is carried out. And about the Self Test pin, the data sheet had this to say: 


    The ST pin controls the self-test feature. When this pin is set to VS, an electrostatic force is exerted on the accelerometer beam. The resulting movement of the beam allows the user to test if the accelerometer is functional.The typical change in output is −1.08 g (corresponding to −325 mV) in the X-axis, +1.08 g (or +325 mV) on the Y-axis, and +1.83 g (or +550 mV) on the Z-axis. This ST pin can be left open-circuit or connected to  common (COM) in normal use. 
    er.. WE CAN LEAVE IT OPEN!


    The acclerometer that we used were built by NSK Electronics, and the board said that that the supply voltage should be 5V. We rarely experienced any overheating problems and pretty faithful responses to movement. One gripe that we did have was when we moved the accelerometer in the Z direction, there was a change in signal coming from the YOUT pin which made it hard for us to program the ride sound. 


    Okay that's all cool, but how the hell are we going to connect them to the Arduino?!? 

    The cool thing about the Arduino Uno is that it has a set of analog and digital pins that can be used for either outputs or reading inputs! A very simple example is illustrated in the Arduino website: Analog Input Digital Output.

    All we had to do was hook up the 5V pin and GND pin on the Arduino to two lines on our breadboard and use those to feed our Accelerometers. 
    The readings from our Accelerometers have to be fed into the analog inputs on the Arduino to be read, so, we chose the Z axis as the one we're going to use for everything and hooked those up to the bread board and the Arduino. 


    [Sorry about the messy diagrams, we're still learning how to use Fritzing.]

    So now we have our inputs for the snare sound, the bass drum sound and the hi-hat sound.
    Lets add a photocell in a voltage divider configuration with a 47k resistor to help us decide whether the hi-hat accelerometer is going to play closed hi-hat or open hi-hat.
    Here is a neat instructable explaining how the voltage divider works.

    So that's, basically our circuit. We made use of USB cables and connectors to help manage all the wires, otherwise it would have been a HUGE mess!
    Be sure to remember the colours!





    And be sure to label them too!


    Secured the accelerometer to the drum sticks using lots
    and lots of sticky tape. Lots. 





    And buy plenty of different coloured wires, trust me, they
    are super useful. 

    Once you're done with the sticks, your circuit will look more or less like this: 
    The sticks we used were Tama Rhythmic Fire size 7A sticks.
    -_-


    And hopefully you wouldn't look like: 















    All that's left are the 'pedals' and programming, which I will be covering in the next blog post and we will hopefully be done with the demonstration video!! 

    -Bhargav