Skip to main content

Posts

Showing posts from 2011

Building a Quadcopter - Part 3

It's been another few weeks, and I'm back to building my quad. Since I recently got my transmitter, it was time to start building the electronics of the quad. The AeroQuad project ( link ) is based on an Arduino for the flight control. It basically uses a 3-axis Gyro and a 3-axis Accelerometer for the flight sensing (other sensors such as Magnetometers and Barometers are also supported, but optional: more info ). To connect these sensors, AeroQuad offers a 'shield' for the Arduino ( What is a 'shield'? ). The sensors need to be bought separately. There are 2 shields, AeroQuad Shield v2.0 ( link ) for Arduino Mega and AeroQuad Shield v1.9 ( link ) for Arduino Duemilanove. Since I already had an Arduino Mega, I ordered the 2.0 shield. With the normal shipping method, it took about 3 weeks to arrive. The shield kit included the following, AeroQuad Shield v2.0 Kit The shield PCB The Logic Level Converter 2 resistors (15K and 7.5K) ULN2003 IC 3 LEDs ...

Building a Quadcopter - Part 2

It's been over 2 months since I posted the first post on building a quadcopter ( link ). You would've thought that I must have completed the build by now. But actually, I couldn't do much. Mainly because that my transmitter shipment got late. As you remember, I ordered a HK-T6Av2 from HobbyKing ( link ) (Actually, a friend ordered it for me as a gift). It was shipped on 21st March. Usually takes less than a month to arrive. But since I didn't receive it until 25th April, I made a complaint to HobbyKing. They said they'd start an investigation on it. On 11th May, the Hong Kong Post mail tracking reported that the parcel was returned to sender. Why was it returned? no one knows... Anyway, I contacted HobbyKing again and they said they can arrange it to be resent once it reaches their warehouse. The parcel reached them on 25th May and it was re-shipped on 31st. It finally arrived about a week ago.... So, here it is... It's finally arrived... I have to sa...

Building a Quadcopter

Note: This is the start of the 'My Projects' section. This is where I post about the projects that I personally do. You can track my progress, my decisions and their outcomes for the problems I face and of course failures (sort of...). So, I hope you enjoy this as much as I do and please leave comments. Ever since I started building model aircrafts I wanted to build a Quadcopter (a.k.a. Quadrotor). I was fascinated by their agility, their simple design and control but need of a complicated stabilization system. The only thing that delayed me to build one is the relatively high cost for the components. But finally I found an opensource quadcopter project named AeroQuad ( link ) which was just within my budget. So, I started gathering my resources... The first thing I needed was a good Transmitter/Receiver pair, which turned out to be a problem because a good pair costs a lot. A quad will need at least a 4-Channel one. That's a bare minimum, so a 6-Channel one would be th...

Li-Po Batteries Explained - Part 4

Note: It's been about 2 months since I've posted the part 3 of this article. Sorry for being late with this part. I hope you have read my earlier articles on Li-Po batteries (Li-Po Batteries Explained Part 1 , Part 2 and Part 3 ). Now let's look at the most important part - charging and maintenance. First of all, why is this so important? Well, just watch the following video on what happens when you mistreat a Li-Po battery. So....., now that you've seen the dangers of Li-Po batteries, it should be clear that they should be handled with care. Li-Po's are very different from conventional rechargeable batteries, so you should only use a charger specifically designed for Li-Po's. Doing so will increase the life span of the Li-Po battery pack and yours as well.

How Hall Effect Sensors Work

If you have studied about brushless motors, you'll probably know that they need a electronic controller (ESC) to run. Since the ESC can't actually see how the motor is running,  it needs to somehow detect the orientation of the rotor (moving part) relative to the stator (stationary part) of the motor. The two most popular ways of doing this is to use a Hall Effect Sensor or to measure the Back EMF of the undriven coils. The Back EMF method does not require any additional sensors, but it's implementation is complicated and has to overcome several issues. The Hall Effect method is much simpler than that, but requires a Hall Effect Sensor near the rotor of the motor to operate. So, how does a Hall Effect sensor work? Simply put, it is a device that varies its output voltage based on changes on a magnetic field. The operation of the sensor is based on the Hall Effect which was discovered by Edwin Hall in 1879. The theory is explained as follows,  The Hall Effect

What is the meaning of the numbers on Brushless Motors?

If you go shopping for Brushless motors you will be confronted with a lot of numbers to choose. For an example, you would see motors marked with 3632 22turn 1500Kv, 2213 20turn 920Kv etc. So what does all those numbers mean, and how would you choose? Here's a simple guide... Let's take this motor for an example, Turnigy 2213 20turn 1050Kv Outrunner It's marked as "2213 20turn 1050Kv Outrunner". Let's see what it means. First of all, it's clearly written that this is an Outrunner motor. The "2213" indicates the size of the stator, First two numbers = diameter of the stator = 22mm Second two numbers = length of the stator stack = 13mm

How to get 2 PWM Signals from the same PIC Microcontroller - mikroC

Using a popular PIC microcontroller such as the 16F877A and a high level compiler such as mikroC, you can do a lot of things. In the last post I discussed about how to get a PWM signal based on an analog signal. Now let's try to do extend that and try to get 2 PWM signals from the same PIC chip. Why would you need 2 PWM signals? Let's say you are building a robot, and you have 2 motors that need to work independently. Or 2 servos you need to control separately etc. As you know, the CCP (Capture/Compare/PWM) module in a microcontroller is responsible for generating PWM signals. So, to get 2 separate PWM signals, you need a microcontroller with 2 CCP modules. If we look at the datasheet ( link ) of the 16F877A, we can see that it has 2 CCP modules (PIC16F87XA Datasheet - Section 8). So, now let's get our PWM signals... However, there's one thing you have to know when you use the 2 CCP modules together. If you look at Table 8-2 from the datasheet, when you configure...

Generating a PWM Signal Based on an Analog Input - mikroC

If you like to experiment with microcontrollers you've probably tried out analog-to-digital conversion and generating PWM signals. Using a popular PIC microcontroller like the 16F877A, which has both ADC and CCP (Capture/Compare/PWM) modules, you can test out both of these easily because mikroC provides easy to use library functions for both of them. (Most of you will be familiar with these libraries, so I won't be going in to much detail about them here. Leave a comment if you like to learn more.. :) ) Now, think of a scenario like this: You want to change the duty cycle of your PWM signal based on a analog signal. It can be from a variable resistor that you want to use to increase or decrease the duty cycle, or it can be a feedback from a sensor which is analog. So, how can we do it?... we simply use the ADC to convert the analog signal and use that value as the duty cycle value. All we need is a microcontroller that has both a CCP and a PWM module. As I said before, the...

Li-Po Batteries Explained - Part 3

If you've read my previous posts about Li-Po batteries (Li-Po Batteries Explained Part 1 and Part 2 ), you'll now understand the basics of Li-Po's. Now let's look at some standard ratings of Li-Po's that you'll need to consider when you buy them. Voltage A single Li-Po cell is rated at 3.7V. This however doesn't mean that the fully charged voltage of a Li-Po cell is 3.7V. Actually, Li-Po cells have a minimum voltage of 2.7V (fully discharged) and a maximum of 4.23V (fully charged). The 3.7V is just the average operating voltage of a single cell. Many Li-Po battery packs have two or more cells connected in series to provide higher voltages. The cell count of the battery pack is denoted by the 'S' number. A 2S battery pack means that there are 2 cells connected in series, thus providing 7.4V. Here are some examples of standard size battery packs: 1S = 1 cell x 3.7V = 3.7V 2S = 2 cells x 3.7V = 7.4V 3S = 3 cells x 3.7V = 11.1V and so on....

Li-Po Batteries Explained - Part 2

I explained about Li-ion batteries (the predecessor of Li-Po) in my earlier post ( Li-Po Batteries Explained - Part 1 ). Now let's see what these 'Lithium Polymers' are. Lithium-Polymer Batteries - The real ones Li-Po batteries - also known as Li-Poly, Pi-Pol, PLI and PLI - are a type of rechargeable batteries that uses same types of electrodes as the Li-ion batteries. The difference is with the electrolyte it uses. Instead of the liquid solvent used in Li-ions, Li-Po uses a polymer electrolyte. In the original design, which dates back to the 1970's, the electrolyte is a dry, plastic-like, thin film. It doesn't conduct electricity, but allows the exchange of ions between the electrodes. Theoretically, with this design, batteries could be made very thin (less than 1 millimeter) and to a variety of form factors. And because of the electrolyte being dry, the manufacturing process can be simplified and the safety of the battery will be higher because of no risk in...

Make Your Own Jupmer Wires for Electronic Breadboard

Note: After starting the 'Tips and Tricks' section I wanted to do my own 'tutorial'. So, here's my first attempt of it. Hope you all find this useful, and sorry about the low quality of the photographs, my camera is just a 2MP. If you, like me, like to experiment with electronics, then you'd probably use an electronic breadboard (also known as protoboard or project-board). These allow you to construct and test circuits without the need to permanently soldering the components. The problem with these is that you have to use wires to connect the components across the bus lines. We normally use single core circuit wires for this purpose, but they tend to bend, break and get stuck in the breadboard when used repeatedly. This may cause short circuiting the bus lines and could be the failure of your circuit. A better option would be to buy a 'Breadboard Jumper Wire' kit, such as this. A Breadboard Jumper Wire Kit These have sets of wire of differ...

Li-Po Batteries Explained

If you are interested in radio controlled aircrafts and stuff, you've probably heard about Li-Po batteries. They are very common in RC planes, cars, boats etc. because they have several advantages over other batteries like less weight, variety of form factors, high discharge rates etc. So what are these "Lithium Polymer" battries? How are they different  from the common Li-ion batteries (which are found on mobile phones etc.)? And most importantly, are they really "Lithium Polymer"? To understand these, we must first look at the more common Li-ion battery, and then move on to Li-Po batteries. Lithium-ion Batteries - The predecessor of Li-Po Lithium-ion batteries - also known as Li-ion or LIBs - is one of the most common types of rechargeable batteries used in consumer electronics. They are especially popular in portable electronic devices such as mobile phones. This is because they offer several advantages like high energy density, no memory effect, low se...

Calculating the length of an array in mikroC

Note: This is the beginning of a new category on my blog, which it the 'Tips and Tricks' category. This is where I share small tips on all the other subjects I discuss here. On my post about RS232 communication using microcontrollers ( here ), I explained how to send and receive one character (one Byte) at a time. Now I wanted to send a whole string using RS232. Since a string is essentially an array of characters in C, we just have to loop through the array and send one char at a time as usual, which is done in the following code. char *mystr; unsigned int i; void main(){ Usart_Init(9600); mystr = "Testing"; for(i=0; i<5; i++){ Usart_Write(mystr[i]); Delay_ms(500); } } This works well when you know the length of the string and only one string needs to be sent. When there are several strings, writing a loop for each of them isn't a good programming method. The better way is to write a separate method to...

How does a Laser 3-D Scanner Work

Here's a quick post about a few things I learned about laser 3-D scanners. In the classification of 3-D scanners, laser scanners fall in to the category of 'Non-Contact Active'. There several types of scanners in this category, but the most common type used is the Laser Triangulation scanner. These are used in scanning relatively small objects with high accuracy. How does it work? A triangulation scanner shines a laser dot to the object and uses a camera to look for the location of the laser dot. Depending of the distance from the laser emitter to the surface of the object, the dot appears at different places on the camera's field of view, as seen on the following diagram. Operating principle of a triangulation laser scanner

Understanding IR Remote Controls - Part 3

We talked about the basics of IR ( Part 1 ) and the SIRC protocol ( Part 2 ). Now let's see how RC 5 protocol works. RC 5 RC 5 was introduces by Philips. It uses IR pulses modulated to 36 KHz. The logic level encoding is simpler than in SIRC. RC 5 Logic Levels Logic '0' is represented by an IR pulse of 0.9ms and then waiting 0.9ms. Logic '1' is the complete opposite, 0.9ms waiting and then 0.9ms pulse. Therefore, both '0' and '1' have a similar 1.8ms pulse width. As in SIRC, a command in RC 5 is also sent as a data packet. Its structure is as follows. RC 5 Data Packet As you can see, RC 5 has 2 start bits, which are always '1'. The address part and the command part are 5 bits and 6 bits respectively. Their function is similar to those of SIRC. The bit marked as 'T' has a special purpose. If you press the same button of the remote several times, the 'T' bit will toggle between 0 and 1. If you press and hold the...

Understanding IR Remote Controls - Part 2

In the last post ( Understanding IR Remote Controls ) I explained what IR is and why it is commonly used in remote controls. Now let's see some common encoding methods used in IR remotes. As you know by now, the IR signals emitted by remote controls are modulated to a frequency between 30 KHz and 60 KHz. In order to send a command, it has to be encoded in to this signal. There are several encoding protocols of which the SIRC protocol introduced by SONY and the RC 5 protocol introduced by Philips are used more commonly. SIRC SIRC stands for 'SONY Infrared Remote Control Code'. It used 40 KHz modulated IR signals. The logic levels (0 and 1) are represented by the width of the IR pulse. SIRC Logic Levels As you can see, the logic '1' is sent by a pulse of 1.2ms and then waiting 0.6ms. Similarly, logic '0' is sent by a pulse of a 0.6ms and then waiting 0.6ms. Those who are familiar will identify this as a sort of a pulse width modulation (I'll be ...

Understanding IR Remote Controls

When hearing the word 'Remote Control', the first thing that comes to most people’s mind would be the TV remote control. They have become so common that other devices - CD/DVD players, Fans, Air-conditioners, Refrigerators, Washing machines etc. - are also getting the same sort of remote controls. These days it's easy to find that almost all consumer electronic devices have a remote control. Almost all of these are IR remote controls. What is IR? IR, or Infrared, is an electromagnetic radiation that has a wavelength between 0.7 and 300 micrometers (frequency range between 1 THz and 430 THz). The Electromagnetic Spectrum There are several advantages in choosing IR for remote controls, such as: Low power requirements Low circuitry costs Simple circuitry Portability Few international regulatory constraints High noise immunity  However, there are a few disadvantages like requiring line of sight, blocked by common materials, short range and light and weather ...

Long Duration Timer Circuit

I was looking for a good timer circuit, one that can produce delays up to several hours. I did have few basic timer circuits that use the 555 IC, but they couldn't be used to effectively get a time delay of few hours because capacitors with low leakage currents are harder to find. So, searched on the internet for alternate solutions. I found a good circuit at a site named www.brighthub.com . It was a pretty simple circuit but the site claimed it can produce time delays from 60 seconds to maximum of 720 hours! I still haven't tested this out, but I have bought all the parts so I will start constructing it soon. Just thought of sharing the circuit with you in the mean time :) Here's the circuit Timer Circuit The circuit is pretty simple, only two CMOS ICs - 4060 and 4040. The S1 switch is used to select different time configurations and the 50k preset (R1) is used for fine tuning the time delay. The circuit operates on 230v but doesn't use a step-down transform...

Picoflyer - Worlds Smallest RC Helicopter

I found this while searching about helicopters. Picoflyer Petter Muren, a Norwegian engineer has invented world's smallest RC helicopter. With just a rotor diameter of 60mm and a weight of just 3.3 grams, the Picoflyer can take off from the palm of your hand. While normal RC helicopters rely on gyros or sophisticated autopilot systems for stability, the Picoflyer uses a unique stability system (invented and patented also by Petter Muren). The Picoflyer relies on a passive-stability system that naturally tilts the ringed rotors to keeps the heli stable if it starts to lean one way. This new system adds no extra parts or weight to the heli. parts of the Picoflyer While intended to be a one-off prototype, the military, universities and hobby manufacturers have expressed their interest to it. The passive-stability system has already inspired a larger commercial RC helicopter named Bladerunner. The Bladerunner References  http://www.popsci.com/diy/article/2006-0...

RC Helicopter Gyro Explained - Part 3

I hope you've read my earlier posts on helicopter gyro (RC Helicopter Gyro Explained - Part 1 and Part 2 ). Now let’s see how gyros are categorized by how they respond to yaw movements. Yaw Rate Gyros Yaw rate gyros (sometimes known as Standard Rate Gyros) are the simplest form of helicopter gyros. They work as a dampener to any yaw movements. This limits the amount of yaw movement because of torque variations from the main rotor, gusts of wind trying to turn the helicopter or even commands from the transmitter. A yaw rate gyro doesn't stop a heli turning because of external forces; it just limits them to a controllable amount. For an example, if a helicopter with a yaw rate gyro is hit by a sudden crosswind, it will slowly turn in that direction rather than a sudden spin, making it easier to keep it under control. Almost all the old mechanical gyros and few of the new piezo gyros are yaw rate type. They are mostly being replaced by the new Heading Hold Gyros. Headi...

RC Helicopter Gyro Explained - Part 2

Now that we know what a gyro is (from the previous post) lets see how it applies to RC helicopters. Why does a helicopter need a gyro? The answer is - for stability. As you might know, in a helicopter the main rotor generates both the lift and the trust. Therefore the engine (or the main motor) has to provide a lot of torque to the rotor. Unfortunately, this torque not only spins the rotor but also spins the fuselage of the helicopter in the opposite direction. That's why a helicopter needs a Tail Rotor or a similar 'anti-torque' mechanism to cancel out the torque on the fuselage. To keep the helicopter stable the anti-torque mechanism must respond quickly to any changes in torque. But the problem is, the torque is always changing. Changes in the engine or motor speed, changing the pitch of the rotor or even gusts of wind change the torque and will try to spin the helicopter out of control. In a RC helicopter, manually adjusting the tail rotor for these constant ch...

RC Helicopter Gyro Explained

I recently bought a RC Helicopter - a Falcon 8911 4-Channel  RC with a built-in Gyroscope (Gyro for short). It's the first time I've seen a 4-Channel RC helicopter, let alone a one with a gyro, in the Sri Lankan market. The heli was pretty good, although I still need more 'flight training'. I will do a separate post on my heli ;) The thing that interested me most is the gyroscope. I knew the basic concept of a gyroscope but didn't know how it applied to helicopters. So I did a little research on the internet and found out a lot about gyros. To others who are interested, here's what I've learned. First of all, what is a gyro? A gyroscope is a device for measuring or maintaining orientation (a.k.a. angular position). The most basic is the mechanical gyro. A mechanical gyro is essentially a wheel spinning at a high rated speed and whose axle is free to take any orientation. Based on the principles of conservation of angular momentum, the orientation of ...

Code for RS232 Communication

I was using mikroC for the coding because programming microcontrollers in C is much easier than using Assembly. The C code for RS232 communication is pretty easy. void main(){ USART_init(9600); // initialize USART module // (8 bit, 9600 baud rate, no parity bit... while (1){ if (USART_Data_Ready()){ // if data is received i = USART_Read(); // read the received data USART_Write(i); // send back via USART } } } You only need four methods to use the USART module (Universal Synchronous/Asynchronous Receiver/Transmitter). USART_init() method initializes the USART module and sets the bit rate etc. USART_Read() and USART_Write() methods can read and write one Byte of data at a time. USART_Data_Ready() is used to check whether the data has arrived. What this simple program does is read the data send by the computer and repeat it back to the computer one character at a time. While this program alone is not much of a use in pra...

Remote Control Based on the RS232 Protocol

A few weeks ago I was studying PIC Microcontrollers and how to interface them with the computer using the computer serial port. This was possible because many PIC Microcontrollers such as PIC16F628 and PIC16F877 has a built in UART module (Universal Asynchronous Receiver/Transmitter) that enables serial communication using the RS232 protocol. The tutorial I used suggested the following circuit. To explain the circuit briefly, The PIC used is PIC16F628A. The MAX232 IC is used for the logic level translation. This is because the logic levels as well as the voltage levels on which the computer serial port and the microcontrollers work on are different.  These levels are illustrated below, Logic levels of the computer serial port Logic levels of the microcontrollers The MAX232 works as an interface between the microcontroller and the computer translating these logic levels. I'll discuss the code used for serial communication in the next post.