Showing posts with label Robotics. Show all posts
Showing posts with label Robotics. Show all posts

Saturday, 22 February 2014

Artificial Hand by Bebionic significantly improves lives

artificial hand

Accidents happen and it is extremely difficult to predict its outcome. You may be either lucky enough to come out of it uunharmed, without even the smallest scratch or may suffer from grieve consequences. The stories of Charles Soitaboa Kango and Mike Swainger are very much similar. But with the help of BeBionic hand, they successfully live a normal life today and can do almost every activity without the slightest hitch.
Charles Soitabao Kango met with an accident while returning to his village. The accident crushed his hand severely and amputation was the only solution. That accident changed his life completely. Charles was just 15 training hours away from receiving commercial pilot’s license. But with the Bebionic hand, he can now resume his training and get his license again. Similarly, after an accident, Mike Swainger lost his hand. He was the first man in UK to receive the Bebionic hand which helped him overcome his loss. But, the artificial hand allows him to do all minor tasks which were previously impossible for him.
Bebionic hand is an advanced artificial hand that has a robot-like appearance. The hand allows the user to perform all types of tasks such as picking things, shaking hand with people, clicking a mouse, pushing a trolley or playing sports. The arm becomes a part of your body, without making you feel very different about it. It has been structured after a research of almost 20 years and hence, has taken into consideration of every single aspect that helps people live a normal life again.

Sunday, 3 November 2013

How to design and build a combat robot : PART 3

Step 8: Wiring and controls

A robot without controls is just a piece of art. You will need some way to control each one of your motors or sub systems remotely so that you can safely be outside of the area and still enjoy the fruits of your labors.

The control systems from robot to robot can be very differently based on the style that the builder chooses. Some builders prefer to use a mirocontroller ( a small computer) to program their bots for special functionality or to make them easier to drive. The most common method for combat is to use a Radio Control system similar to that used in model airplanes or cars.

The basics of the system is that your radio system comes with a receiver with different outputs or channels, connected to each one of these ports is a speed controller. The speed controller is necessary so that each motor can have proportional control. You can read more about their purpose and function here http://en.wikipedia.org/wiki/Electronic_speed_control 

The wiring connections are outlined in the photo below. Each motor is connected to it's own speed controller, which is connected to a power source through a switch or breakout board. The speed controllers also receive a signal in the form of PWM (Pulse Width Modulation). This signal gets interpreted in the speed controller which provides a correct voltage to the motor. For a live wiring example you can view a labeled photo here http://www.warbotsxtreme.com/basicelect.htm

Not all speed controllers are are created equal, there are many different voltage and amperage ratings make sure that the ones you get match the motors that you choose. The price for controllers is directly related to the amount of amperage they can handle. There are numerous companies that make speed controllers which would be appropriate. For all of my robots I use the Innovation First Victor line of controllers http://www.innovationfirst.com. They are one of the top selling controllers of all time and are built like a rock. The http://www.robotmarketplace.com has a good assortment of motor controllers, but since I don't have experience with others I suggest checking out some other reviews, especially for very small ones

When choosing a radio system you will have a choice these days between PPM (FM), PCM, 2.4 GHZ, 800MHZ, and 802.11 Each one of these has it's advantages and changes the price of the system.

PPM (FM) - one of the oldest forms and the cheapest you can get a complete setup for under $50. These tend to be really bad with interference and they are regulated by the FCC.There are different frequencies are made for Ground use and some are for Air. Make sure to get one for ground use as it is illegal to use one for air. 

PCM - Is a system similar to PPM except there are systems in place to link your transmitter and receiver which minimizes interference. These still fall under FCC regulations.

2.4 GHZ - is the same frequency as many household phones. It is a real digital system which will not allow any interference once the receiver is paired with the controller. This is the most common system in place now and what I use for my small battle bot (spektrum D6). These systems run ~$300 but once you own it you can use it time and time again.

800MHZ - the Innovation First micro controller system uses an 800MHZ system. This allows for programming of advanced functionality. These systems cost upwards of $1200 and are mostly used for larger robots. If you can afford one I recommend it. I use this system on my Heavyweight robot (220lbs) 

There are many types of batteries available for combat robots. Small robots commonly use LiPoly batteries, which have the advantage of being long lasting and powerful with minimal weight. These packs are beginning to come down in price but are still more expensive than other options.

Medium bots use NiCad packs, similar to those found in drill batteries. These packs are proven systems and relatively cheap. You can get battery packs premade in many different sizes, shapes, and configurations. Many companies online allow people to customize their packs and build them to order. I recommend http://www.battlepacks.com for custom packs of this type

Larger robots tend to use Sealed Lead Acid batteries or NiCad packs. SLA batteries are cheap and easy to come by. They are designed to be mounted in any configuration and come in many sizes. Unfortunately they tend to be heavier than their NiCad counterparts. 

Batteries for me are the last thing I choose since there are so many options. I calculate the amount of power I will use during the match and find the battery pack which has the right about of capacity and fits the spacial profile for the robot. Recently I have gotten a hold of some new lithium batteries which I will be experimenting with for future machines. 

Step 9: Testing and tweeking

Now that you have your robot mostly put together and wired you have reached the really fun part. TESTING. 

When doing this make sure you are properly protected and safe depending on the size of your robot and the weapons your robot may be lethal if not controlled properly.

I like to test the subsystems separately before I test the bot all together. That way I can analyze problems to each component before having to backtrack the entire machine to find problems. 

Once your robot is complete make sure to drive your robot, getting a feel for the controls, many matches have been won or lost just because of driving skill. The more you test before your competition the better prepared you will be. I try to break my robots before the event as I would rather figure out mistakes and fix problems when I have time to fix them rather than the time in between the match. 

Another advantage to running your machine is "break in period" Every new gearbox or mechanical component will have to wear in a bit and will loosen up. You want to try and get everything broken in before your first competition so you are not dealing with changing robot conditions throughout the day.

Ultimately It is important to remember that Design is an iterative process. You will never get it right the first time but with testing and modifications you can make it work.

Step 10: Enjoy your robot



Now that you have built a robot make sure to have fun with it. Take it to competition and try to do your best, remember that it isn't necessary that you win every match or event as building the machine is 75%+ the fun of the project. Every robot you build will be a little bit better than the last, and use them to improve your skills as a designer and engineer. 

I hope you found this instructable both helpful and informative. Below are a bunch of other resources for bot building.

Forum for combat robotics: http://forums.delphiforums.com/THERFL/ 

Http://www.botcentric.com - my new robotics video show, much more diy content and news (coming soon)

Sources of parts and supplies :

AndyMark.biz - mechanical components
Banebots.com - motors, wheels, and components
Robotmarketplace - everything you need
Yarde Metals - metal suplus
onlinemetals.com - huge assortment of metal
B.G. Micro - Surplus Electonics, etc.
SDP-SI - drive componets
C&H - Surplus Electronics and mechanical
Alltronics - Surplus Electronics, etc.
All Electronics - Surplus Electronics, etc.
Northern Tool - Tools, wheels, chain transmission components
Grainger - Industrial Supply
McMaster-Carr - Industrial Supply
WM Berg - Precision Gear Products
American Science & Surplus - Surplus motors, batteries, gears, pulleys, and ?
Industrial Metal Supply - Great deals on remains stock and Steel and Al by the pound.
Team Delta Engineering - RC Interfaces, Motors and other combat specific robot parts
RobotBooks.com - Great collection of robot and electronic guidebook, fiction, toys, etc.

How to design and build a combat robot : PART 2

Step 4: Choosing Components






Every bot is made up of a combination of both manufactured and purchased components. Choosing the right components is crucial for a successful robot. In this step I will step through some of the major components for small to medium robots and how you choose which is right for your bot.

Motors: The driving force behind any size robot you build. They make your robot move and in many cases power your weapons. The motors used in combat robots are DC or Direct current motors, designed for anywhere between 3 and 72 volts. Just like every other component you need to make decisions to choose the right one. The four traits to consider in on each motor is torque/speed, voltage, size, and weight. Motor torque is typically rated in oz-in or in-lbs at the "stall" area. Since dc motors produce their maximum torque with minimal RPM stall torque is only a reference point. I only use the torque as a baseline for comparison for different motors and try to get the most torque I can within my other constraints. Size and weight go hand and hand since the larger form factor your robot is the more it will weigh. When defining the size of your bot try to make it as small as possible without sacrificing functionality. Voltage is one of those things that is my last priority, most motors are 12 volts but for those that aren't you just need to make sure that your electronics all match the voltage of your motors.

Common motors used for 12-30lb robots:
Drill motors - cheap drills from discount tool store harbor freight are stripped from their housings and mounted for the drives. Many people also use the battery packs from these drills as well. While the cheap drills are common many people spend the extra dollars for high quality ones such as ones made by DeWALT.

Banebots - banebots is a company founded a few years ago for the sole purpose of providing parts for combat. They have a large range of motors and transmissions which are "ready to run" out of the box. For the convenience of not having to modify drills to get the motors I chose these for my robot, the old 36mm series (which I used) broke easily, but I have had good results with the new 42mm ones. http://www.banebots.com

Other motors: A wide assortment of motors exists you can check out many of them at the robot marketplace. http://www.robotmarketplace.com 

Wheels - The wheels on the robot go round and round.... The saying don't reinvent the wheel comes to mind for this section as there are as many different styles of wheels as there are builders in this sport. The main question you need to ask yourself is if you want a live axle or dead axle system. 

In live axle system the wheel is hard mounted to the axle similar to a wheel in a car. The challenge with this system is that now you will need to have bearings on the shaft and find a way to couple the wheel to the axle.

In a dead axle setup the wheel freely spins on a shaft and is usually driven by a sprocket or belt attached directly to the wheel. While this system may seem easier it still has it's own challenges like the need for a power transmission method (chain or belt) and in the small spaces for this size robot direct drive systems work better.

The most common wheel used for most all combat robots is made by the colson company and is a soft urethane wheel which performs well on the many different arena surfaces. The major problem with these wheels is that they don't have a way to drive them for live axle applications. For my robot I made custom hubs on a lathe but you can buy pre-made colsons' with hubs from places like 
http://cncbotparts.com or hubs that you can use to fit from http://andymark.biz.

Banebots recently came out with some of their own wheels similar to colsons' but I have not seen or tested them. 

Building Materials - Small robots use a variety of materials from composites like carbon fiber sheets and aluminum. Just like any other component on your machine each material will have advantages and disadvantages. These are a few of the ones used commonly.

Aluminum: is a light weight common metal which can be easily formed and machined. It is used for the chassis of most machines for those reasons. Aluminum comes in many different alloys but the most popular ones are 6061-T6 which is heat treated and suited for machining and welding. This alloy can be soft and not great for impact resistance so use it for components which arn't going to see direct contact. 7075 is the other major alloy and is much tougher of a material which makes it harder to form and weld but has better resistance to hits. 

UHMW - is a durable plastic commonly used for internal components as mounts. It has a bit of give to it, but it holds up well under competition. It is also very easy to form with even hand tools.

Polycarbonate - or lexan as it is commonly known is a clear durable plastic which is for the most part impact resistant and light weight. pound for pound it compares to aluminum but it bends and bounces back instead of deforming like metal will. Under extreme impacts it can crack and break away so use it for top panels but not armor.

Titanium - a great material for armor but it is very cost prohibitive, although many builders still use this for high end machines. 

For my robot I used both 6061 and 7075 aluminum. Mainly 6061 for my supports and chassis and 7057 for my outer frame supports. I used a live axle setup with banebot 12:1 transmissions powering 3" x 7/8 coloson wheels with a custom made hub.

Step 5: Computer Aided Design (CAD)


CAD is the system used by all professionals for the creation of the products you see and use everyday. It allows you to make 3D computer renderings, seeing how things fit together on the computer before you build. This step can revel potential problems on your bot which will reduce your time and cost overall. 

It is a common thought that CAD systems are difficult to use and build if you are not an engineer or have been trained to use them through some class. Recent CAD software has been shifted from even five years ago so that they are easier to build models with a user interface that anyone can pick up and learn within a few hours.

Within industry the three most popular pieces of software are Autodesk Inventor, Solidworks, and Pro-e. Each one of these has advantages and disadvantages to their own right but all are comparable for this type of design. I will not be going into how to use CAD in this instructable but there are many resources online for using this type of software.

Buying CAD software can be very expensive but fortunately there are many opportunities for free licenses of software if you are a student, or if your company has licenses of the software.

Students can get autodesk inventor for free from http://students.autodesk.com All you need is an email with a .edu ending

You can also get a copy of student version of solidworks very cheep/ free from time to time online.
They also have a great tutorial for robotics design located here http://www.solidworks.com/pages/products/edu/Robotics.html?PID=107

For robot design with little to no CAD experience I recommend Inventor or Solidworks both provide a simple interface, and more importantly there are lots of models available for free download. Stock parts like bearings, screws, motors, etc can be found. Using these models will save time when modeling. 

The most important thing about CAD design is that you have your dimensions right. Now that may seem like a straight forward piece of advise but I see loads of people trying to make realistic renderings and spend too much time making their parts look nice instead of focusing on the real goal of CAD to make models which are accurate. 

I am going to leave this step because if you take the time to learn CAD the process steps for design in the software become more apparent. If you choose to skip this step due to the inablity to run the software or the lack of interest I recommend a "cardboard template" method. Take cardboard and cut out scale models of each one of your parts for layout, before you cut your real material. A good example of this method in the webshow by revison3 called Systm located here http://revision3.com/systm/robots/ 

Ultimately the purpose of this design step is to minimize the mistakes with your expensive.materials.

Additional notes:
*modern CAD software can assign weight properties so you will know how much your bot should weigh before you build
*Ensure that you have sized things correctly so they fit together, for example a 1/2" shaft will not fit through a 1/2" hole. For exact machining you are dealing with thousands of an inch (.001") 

Step 6: Construction of manufactured parts



Depending on how much design and your resources you can start building parts. There are many ways to do things, hand tools (jigsaw, hammer, etc), Manual mill lathe, full cnc; Which ever method you choose Make sure you are Safe.

If you are building a budget robot you will most likely be using hand tools or light power tools. This is the method used by more bots than anything else. The only advise that I can offer for doing this is to take your time and use the templates or CAD drawings you created to help in the process. One of my preferred methods for this when I am unable to use the machine shop is to make drawings from CAD in a full scale and paste them to the material then use those guides to cut your parts.

The next step up from manual tools is a standard machine shop. If you have access to a Mil or a lathe you will be able to create highly accurate parts. These tools can be very dangerous if you don't know what you are doing so make sure supervision or proper instruction happens before you start. If you are looking for access to a machine shops most towns and citys have them and you should be able to open a phone book and find someone to help. Sometimes they are willing to donate their time other times you will need to pay for their time. At this day in age there are some great resources online for manufacturing which can help you out. http://www.emachineshop.com/ and www.cncbotparts.com both are great sources.

Advanced manufacturing can come into play for many complex robots. For my past few robots I have been fortunate to have access to CNC (computer numeric controlled) and waterjet for my bot parts. This makes building the components very easy but it makes the CAD design even more crucial for accuracy, as any machine shop will build EXACTLY what you give them. If you are going down this road make sure you take the extra steps to ensure that your design is right. I would even go as far to find someone else who knows CAD to review your designs to make sure you have not overlooked something.

Step 7: Assembly of components



As you are in the process of building your components test fit your parts together. Don't be surprised if you have to modify some of them as they won't always fit. Depending on how they were manufactured your parts will fit together differently. 

Ones made in a machine shop or with a CNC will most likely go together as designed, the more manual the manufacturing the more modification you will need to do. Just make sure to use the montra of "measure twice cut once" as it is very hard to make material grow once you cut it away.

The main advice in this process is don't get discouraged if you take your time things will go together just fine. 


Notes: 
if you are using threaded fasteners make sure to use high quality ones. The fasteners at the big box stores (home depot and lows  are of low quality. I recommend ordering from McMaster Carr www.mcmaster.com or another industrial distributor. 


How to design and build a combat robot : PART 1

Combat robots have been entertaining and amusing since before they were popular on Comedy Central. A while back I undertook the challenge of building a couple of combat robots (a 30lb and a 220lb). Regardless of the size of the machine the steps in the process are the same. This Instructable will walk you through the steps and provide you with resources to help with the machine and give an understanding of what is involved using my 30lb robot as an example.

164-6473_IMG.JPG

Step 1: Decide what size robot you want to build

Combat robots come in many sizes from 75grams to 340lbs each one of them has their pros and cons. The first thing to do when thinking about building is to find the competition which you want to compete and see what weight classes are going to be there, because what is the point of building a bot you can never fight. Listing of robotic competitions are available on 
http://www.buildersdb.com and http://www.robotevents.com.

Large robots: 60lbs + 
There is nothing like the thrill of seeing two large machines hitting each other with the force of a small car wreck. When most people think of combat robots it is these larger machines which first cross your mind. If you are fortunate to live near one of the large robotic events these machines can be fun builds, but at the same time the level of engineering required can be quite difficult. These large machines can also cost quite a bit of money. When you commit to building a machine this size you are committing at least $1000, and in many cases much more. I would estimate that your average heavy weight (220lbs) would cost a builder $4000-$5000 to build a competitive machine, and it is not uncommon to see builders spend upwards of $15,000+ on their machines over the course of a few years. In the days when combat robotics was televised there were many sponsorship opportunities which would subsidize the cost, unfortunately now as a builder you will be on your own. 

On the good side of larger machines is that many times you can find surplus parts online which can reduce the cost of the machine. Using off the shelf components such as items fromhttp://www.teamwhyachi.com/ or http://www.AndyMark.biz can help make things easier. There are more of these components available for larger machines. Those Larger machines also have the added ability for service, fixing a machine is much easier the larger it is. Building a large robot can be both fun and enjoyable and you wont regret being able to say "I have a 120 lb battlebot in my garage"

Small Robot:

Building a small robot can be alot of fun but also a good challenge, with a restricted weight limit it makes every part on the machine to be critically thought about and designed. Most people are drawn to these smaller machines because of the frequency of competitions for them as well as the ability to transport them easily. While it is the common misconception that small robots are cheap they can be just as expensive as their larger counterparts. Alot of times the small electronics required for these can cost quite a bit as compared to larger components. 

weight classes (list from wikipedia): 

  • 75g- Fleaweight
  • 150g- Fairyweight (UK - Antweight)
  • 1 pound (454 g) - Antweight
  • 1 kilogram (2.2 lbs) Kilobot
  • 3 pound (1.36 kg) - Beetleweight
  • 6 pound (2.72 kg) - Mantisweight
  • 12 pound (5.44 kg) - Hobbyweight
  • 15 pound (6.80 kg) - BotsIQ Mini class
  • 30 pound (14 kg) - Featherweight
  • 60 pound (27 kg) - Lightweight
  • 120 pound (54 kg) - Middleweight
  • 220 pound (100 kg) - Heavyweight
  • 340 pound (154 kg) Super Heavyweight

Step 2: Do some research and set a budget.

The first step to building a bot is to think about what kind you would want to build. When I start the project I always take a look at what people have done already and draw from the knowledge learned by others over time.

A good place to start with your research is the builders database. http://www.buildersdb.com this website is used by most competitions for registration. One of the requirements of this site is each team/robot have a profile with a picture of their bots. Because of this you can easily browse hundreds of other robots in your weight class.

Anther good starting point is to determine how much money you are willing to invest. Unless you have lots of parts hanging around which can be re-used from other projects you will need to account for ever item from motors to materials and don't forget about the machining/ building time. Below is a list of the components commonly required for most combat robots.

The main reason that setting a budget is important for your project is that you can very easily spend hundreds if not thousands of dollars very quickly. Robotics is a fun hobby and can fit any budget if you plan for it. The last thing anyone wants is to get part of the way into the build and then not be able to finish due to funds.

Common components:
*Drive motors/ transmissions
*wheels
*chassis materials
*weapon motor
*speed controllers for each motor
*radio control system (receiver and transmitter)
*batteries
*wire
*main power switch
*Bearings
*shafts and axles
*screws and fasteners
*armor material
*weapon (material or purchase)

It is also important not to forget spare parts, as during combat you will break parts and components. Also having at least 2 sets of batteries will be necessary for competition 

Step 3: Initial design


It all starts with a few sketches and a few different concepts. I always do a few concepts and some initial layouts so that I can make a determination as to the best design. Also the more layout is done before the final design the easier to transition to computer design for machining. Use your Imagination and make

It is one of my personal rules that when I start thinking about a design I look for robots that have done similar things and try to see what was successful and what wasn't so I can always improve on the design concept.

I try and keep two things in my mind at all times:
1)Is this robot unique from others? Does it have that wow factor, and will I be happy with it as a personal product as well as how competitive it might be

2) How easy will it be to maintain. Does changing a fried motor require the complete dis-assembly of the robot? Can I change parts out in 10-15 mins if needed?

Those two key concepts help focus your thoughts when thinking about your bot. Also make sure that you check the rules for the competition you are thinking about. Most events use the rules governed by the Robot Fighting League (http://www.botleague.net/ ) , but some organizations such as Battlebots (http://www.battlebots.com ) have some different rules. These rule sets will dictate the types of machines you can build and how to make them safe.

The last part of the initial design is to figure out what parts you have that might work and do a quick layout of your basic overall dimensions, with weight limits for each subsystem. The more planning you do at this stage will help along the way.

Saturday, 2 November 2013

Better Joints : Better Mechanisms.


Compliant materials with a strong impact
The recent Empa spin-off Monolitix AG specializes in compliant mechanisms. These are friction-less and wear-free and are also lighter, more hygienic and cheaper than conventional joint mechanisms. They have an enormous range of potential applications in the most diverse fields. The new company's young entrepreneurs are now setting about breaking into the market with their first products.
We are surrounded by objects with joints from morning till night. "We come across them in a thousand different forms", explains Flavio Campanile, aeronautical engineer and Chairman of the Board of Directors at the Empa spin-off Monolitix. "Without joints, everything would be rigid: you would not able to steer a car and the brakes on bicycles would not work." The "trick" is that rather than using conventional bearings and joints to create the required movement for a mechanism, these so-called solid-state mechanisms deliberately dispense with these types of elements. Instead, the material is deformed in a controlled and reversible way. As a figurative example, instead of a pair of pliers made from several parts, as representative of the traditional joint principle, Campanile highlights a pair of tweezers made from a single, elastically deformable component.
Monolithic systems with many advantages
"The advantages of monolithic systems are obvious" explains Campanile: joint-free mechanisms are friction-less and wear-free and therefore also maintenance-free. This can drastically reduce the running costs of machines and instruments. In areas where high standards of hygiene are required, such as in medical devices or in the food industry, they are advantageous because they are easier to clean and sterilize. In addition, with solid-state mechanisms, assembly costs can be reduced dramatically or even avoided altogether. This leads to much cheaper production processes.

Compliant materials with a strong impact
A conventional joint construction (left) has a very simple design. A monolithic solution (right) has a more complex design, but has many advantages in operation.
And finally, compliant mechanisms can also perform functions that would be inconceivable with conventional systems: for example, aircraft wings which constantly change their geometry - like those found in nature - and optimise their use of the aerodynamic forces. Another possibility is rear spoilers for Formula 1 racing cars which generate more down force with the same air resistance, thus enabling the car to travel faster through corners. Compliant concepts are also extremely well-suited to rotor blades on wind turbines that are difficult to access or for anti-friction and friction bearings in solar power plants, which are subjected to mud, sand or dust and have to function under extreme conditions.
The business idea began to take shape when Campanile's doctoral students at the Federal Institute of Technology (ETH) Zurich, René Jähne and Alexander Hasse, began working in this field. The first prototypes for medical technology were created in the course of their dissertations. This is how the ideas came to life. For many years, the team of three carried out their research at the Empa laboratory "Mechanics for Modelling and Simulation", during which time they developed techniques for analyzing flexible elements and their deformation as well as algorithms for shape optimization. Their results were then incorporated into software modules, databases and patents. The time to establish their own company came in 2010.
Gripping systems from the catalogue and innovative ideas from the custom manufacturing team
Compliant materials with a strong impact
A range of robotic grippers from Monolitix is already available to mechanical engineers. They are extremely light, free of play and friction less.

Even before they joined glaTec, Empa's business start-up center in Dübendorf, they acquired their first customer: baked-goods manufacturer HUG uses their robotic grippers to take small pastry cases carefully, quickly and hygienically off the production line and put them into their packaging. The task for Campanile and his colleagues is now to inspire new customers with their many ideas and to persuade them to develop new products together. The Head of Product Development at Monolitix, René Jähne, explains: "As a small company, it would be too expensive for us to develop and market complex products for a specific market single-handedly." The company does offer a small, but refined range of gripping systems in its catalog. However, an approach that he believes will be far more successful is to actively approach manufacturers of machine components, tools and instruments. According to Jähne, "In this way, with every project, we become better acquainted with the needs of individual partners and their markets." During the discussions, clients in return gain an insight into the engineering work carried out at Monolitix. It is quickly becoming clear that the design for a compliant system can ultimately only be created with a multidisciplinary approach and a lot of expertise.
Demand for the new technology is strong, as the company's founders are proud to note, also referring to the fact that Monolitix is already financially independent. This is quite unusual for such a young company. According to the business plan, Monolitix should grow into an SME with around 40 employees within the next five years. 

Sunday, 18 August 2013

HOW TO MAKE ROBOTS? Lesson 10: Programming a Robot - Robotshop Blog

Programming is usually the final step involved in building a robot. If you followed the lessons, so far you have chosen the actuators, electronics, sensors and more, and have assembled the robot so it hopefully looks something like what you had initially set out to build. Without programming though, the robot is a very nice looking and expensive paperweight.
It would take much more than one lesson to teach you how to program a robot, so instead, this lesson will help you with how to get started and where (and what) to learn. The practical example will use “Processing”, a popular hobbyist programming language intended to be used with the Arduino microcontroller chosen in previous lessons. We will also assume that you will be programming a microcontroller rather than software for a full-fledged computer.

What Language to Choose?

Programming Robot from syraweb.orgThere are many programming languages which can be used to program microcontrollers, the most common of which are:
  • Assembly; its just one step away from machine code and as such it is very tedious to use. Assembly should only be used when you need absolute instruction-level control of your code.
  • Basic; one of the first widely used programming languages, it is still used by some microcontrollers (Basic Micro,BasicXParallax) for educational robots.
  • C/C++; one of the most popular languages, C provides high-level functionality while keeping a good low-level control.
  • Java; it is more modern than C and provides lots of safety features to the detriment of low-level control. Some manufacturers like Parallax make microcontrollers specifically for use with Java.
  • .NET/C#; Microsoft’s proprietary language used to develop applications in Visual Studio. Examples include NetduinoFEZ Rhino and others).
  • Processing (Arduino); a variant of C++ that includes some simplifications in order to make the programming for easier.
  • Python, one of the most popular scripting languages. It is very simple to learn and can be used to put programs together very fast and efficiently.
In lesson 4, you chose a microcontroller based on the features you needed (number of I/O, user community, special features, etc). Often times, a microcontroller is intended to be programmed in a specific language. For example:
If you have chosen a hobbyist microcontroller from a known or popular manufacturer, there is likely a large book available so you can learn to program in their chosen programming language. If you instead chose a microcontroller from a smaller, lesser known manufacturer (e.g. since it had many features which you thought would be useful for your project), it’s important to see what language the controller is intended to be programmed in (C in many cases) and what development tools are there available (usually from the chip manufacturer).

Getting Started

Hello World PSPThe first program you will likely write is  “Hello World” (referred to as such for historic reasons). This is one of the simplest programs that can be made in a computer and is intended to print a line of text (e.g. “Hello World”) on the computer monitor or LCD screen. In the case of a microcontroller, another very basic program you can do that has an effect on the outside world (rather than just on-board computations) is toggling an IO pin. Connecting an LED to and I/O pin then setting the I/O pin to ON and OFF will make the LED blink. Although the simple act of turning on an LED may seem basic, the function can allow for some complex programs (you can use it to light up multi-segment LEDs, to display text and numbers, operate relays, servos and more).
Step 1: Ensure you have all components needed to program the microcontroller
Not all microcontrollers come with everything you need to program them, and most microcontrollers need to be connected to a computer via USB plug. If your microcontroller does not have a USB or DB9 connector, then you will need a separate USB to serial adapter, and wire it correctly. Fortunately many hobbyist microcontrollers are programmable either via an RS-232 port or by USB, and include the USB connector on-board which is used not only for two-way communication, but also to power the microcontroller board.
Step 2: Connect the microcontroller to the computer and verify which COM port it is connected to. Not all microcontrollers will be picked up by the computer and you should read the “getting started” guide in the manual to know exactly what to do to have your computer recognize it and be able to communicate with it. You often need to download “drivers” (specific to each operating system) to allow your computer to understand how to communicate with the microcontroller and/or the USB to serial converter chip.
Step 3: Check product’s user guide for sample code and communication method / protocol
Don’t reinvent the wheel if you don’t have to. Most manufacturers provide some code (or pseudo code) explaining how to get their product working. The sample code may not be in the programming language of your choice, but don’t despair; do a search on the Internet to see if other people have created the necessary code.
  • Check product manuals / user guides
  • Check the manufacturer’s forum
  • Check the internet for the product + code
  • Read the manual to understand how to write the code

Useful Tips

  1. Create manageable chunks of functional code: By creating segments of code specific to each product, you gradually build up a library. Develop a file system on your computer to easily look up the necessary code.
  2. Document everything within the code using comments: Documenting everything is necessary in almost all jobs, especially robotics. As you become more and more advanced, you may add comments to general sections of code, though as you start, you should add a comment to (almost) every line.
  3. Save different versions of the code – do not always overwrite the same file: if you find one day that your 200+ lines of code do not compile, you won’t be stuck going through it line by line; instead you can revert to a previously saved (and functional) version and add / modify it as needed. Code does not take up much space o a hard drive, so you should not feel pressured to only save a few copies.
  4. Raise the robot off the table or floor when debugging (so its wheels/legs/tracks don’t accidentally launch it off the edge), and have the power switch close by in case the robot tries to destroy itself. An example of this is if you try to send a servo motor to a 400us signal when it only accepts a 500 (corresponding to 0 degrees) to 2500us (corresponding to 180 degrees) signal. The servo would try to move to a location which it cannot physically go to (-9 degrees) and ultimately burn out.
  5. If code does something that does not seem to be working correctly after a few seconds, turn off the power – it’s highly unlikely the problem will “fix itself” and in the meantime, you may be destroying part of the mechanics.
  6. Subroutines may be a bit difficult to understand at first, but they greatly simplify your code. If a segment of code is repeated many times within the code, it is a good candidate to be replaced with a subroutine.

Practical Example

Arduino UnoWe have chosen an Arduino microcontroller to be the “brain” of our robot. To get started, we can take a look at the Arduino 5 Minute Tutorials. These tutorials will help you use and understand the basic functionality of the Arduino programming language. Once you have finished these tutorials, take a look at the example below.
For the robot we have made, we will create code to have it move around (left, right, forward, reverse), move the two servos (pan/tilt) and communicate with the distance sensor. We chose Arduino because of the large user community, abundance of sample code and ease of integration with other products.
Sharp GP2D120 IR Range Finder
Distance sensor
Fortunately in the Arduino code, there is an example for getting values from an analog sensor. For this, we go to File -> Examples -> Analog -> AnalogInOutSerial (so we can see the values)
Pan/Tilt
Again, we are fortunate to have sample code to operate servos from an Arduino. File -> Examples ->  Servo -> Sweep
Servocity Pan and TiltNote that text after two slashes // are comments and not part of the compiled code
#include <Servo.h>            // This loads the servo script, allowing you to use specific functions below
Servo myservo;                      // create servo object to control a servo
int pos = 0;                             // variable to store the servo position
void setup()                           // required in all Arduino code
{
myservo.attach(9);             // attaches the servo on pin 9 to the servo object
}
void loop()                               // required in all Arduino code
{
for(pos = 0; pos < 180; pos += 1)  // variable ‘pos’ goes from 0 degrees to 180 degrees in steps of 1 degree
{
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                                 // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1)     // variable ‘pos’ goes from 180 degrees to 0 degrees
{
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                               // waits 15ms at each degree
}
}
Motor Controller
Pololu Serial Motor ControllerHere is where it gets a bit harder, since no sample code is available specifically for the Arduino. The controller is connected to the Tx (serial) pin of the Arduino and waits for a specific “start byte” before taking any action. The manual does indicate the communication protocol required; a string with specific structure:
  • 0×80 (start byte)
  • 0×00 (specific to this motor controller; if it receives anything else it will not take action)
  • motor # and direction (motor one or two and direction explained in the manual)
  • motor speed (hexadecimal from 0 to 127)
In order to do this, we create a character with each of these as bytes within the character:
unsigned char buff[6];
buff[0]=0×80; //start byte specific to Pololu motor controller
buff[1]=0; //Device type byte specific to this Pololu controller
buff[2]=1; //Motor number and direction byte; motor one =00,01
buff[3]=127; //Motor speed “0 to 128″ (ex 100 is 64 in hex)
Serial.write(buff);
Therefore when this is sent via the serial pin, it will be sent in the correct order.
Putting all the code together makes the robot move forward and sweep the servo while reading distance values.
You can see the full robot and the user manual.