Article to Develop AVR programs on Eclipse IDE

May 20th, 2010

Article to Develop AVR programs on Eclipse IDE

Steps to install Eclipse IDE:

1.Download Eclipse from for C/C++ developers as shown below:

2.Now Extract the package:
Right click the package and open with Archive Manager and extract it to home directory as shown below:

3.Open the eclipse executable to the folder that you have extracted ~/eclipse/ as shown below:


If it displays the error than there is no JRE in your system, you will need to install it. Follow the steps given to install JRE or else skip the step.
4.Run the following command on the prompt to install JRE as shown below:
1.Open Applications > Accessories > Terminal
2.Execute the command given below:
thinklabs@thinklabs:~$ sudo aptitude install default-jre

This will take some time to install.

Now start eclipse again an Eclipse IDE will start as shown below:

Steps to install AVR Eclipse plugin:

Now close the Eclipse IDE and download the AVR Eclipse plugin from the link given below:

http://avr-eclipse.sourceforge.net/

Now go to download section and select direct download as shown below:

Once you have selected Direct download it will go to the sourceforge where plugin can be downloaded as shown below:

Be careful while extracting the zip files to the ~/eclispe folder.

1.Open with the Archive manager and drag features folder and plugins to the eclipse folder individually as given below:

1.1.Inside the Archive Manager you will see “.” folder, double click it and go to the features folder and select the folders as shown below and drag it to eclispe/features folder:

1.2.Similarly inside the Archive Manager, go for the plugins folder and select the folders/files as displayed  below and drag it to eclispe/plugins folder:

Steps to write down AVR programs on Eclipse IDE.

1.Open the eclipse executable as a root user, issue the command on the prompt as shown below:
1.Open Applications > Accessories > Terminal
2.Execute the command given below:
thinklabs@thinklabs:~$ sudo ~/eclipse/eclipse

3.It will popup the page as shown below:

2.Create a new project go to file menu > New > C Project

NOTE: If it doesnot display this “AVR GCC Toolchain plugins” than there AVR Eclipse plugin is missing, try to install it as given in the above section steps to install AVR Eclipse plugin.

3.Write a new project name and click on next
4.It will ask for selection of CPU name and its frequency and click on finish.

4.Goto file menu > new > c source file and save it
5.write down the code given below

6.select the active build configuration as Release
Project menu > Build configurations > set active > 2 Release

7.Now goto the project menu > Build All
You can see that inside release folder executable binary is generated as shown below:

Steps to burn your program on uNiBoard v 1.1

Now if you want  to load the executable on uNiBoard v 1.1, you will need to setup the avrdude programmer.
1.Goto the properties window of the project by right click on project and properties.

2.Select AVR>Avrdude tab it will display window as shown below:

3.Click on Edit and follow the steps given below:
1.Configuration name as uNiBoard
2.In programmer Harware select USBasp.
3.In override default port -P   USB.
4.Click on OK button to save the configuration.

4.Select programmer configuration as uNiBoard and click on Apply  button and OK button.

5.Now you can burn the program by selecting AVR menu > Upload project to Target Device.

TRI ISP (Beta)

December 26th, 2009

The 4 step guide to program your P89v51RD2 controller using TRI ISP

Step 1: Port Settings

Port Number: Select the serial communication port of your PC to which the target device is connected. Most present day IBM compatible PCs have a single serial communication port with an address of COM1.

untitled1.JPG

Speed: Select the burning speed. (Preferably 9600)

untitled.JPG

Step 2: Device Settings

Select the target device. (The TRI ISPBeta version supports only P89v51RD2.)

untitled2.JPG

Step 3: Load Hex File

The Hex File can be loaded either by clicking the ‘Browse’ button and selecting the Hex File or directly typing its path.

untitled3.JPG

Or

untitled4.JPG

Step 3: Burn

Once the Hex File is loaded, click the ‘Burn’ button and reset your target device. The burn status will be displayed on the progress bar and once the progress bar indicates that the process is completed, reset the target device.

untitled5.JPG

To Download TRI ISP Click Here : http://www.triindia.co.in/download/TRI ISP.MSI

Simple Conductivity sensor to detect metals

December 26th, 2009


SocialTwist Tell-a-Friend

Conductivity Test

In order to detect the presence of conductors,the simplest test is the Conductivity Test. Conductivity of a substance is defined as ‘the ability or power to conduct or transmit heat, electricity or sound’. Here what we use is the ability to transmit electricity. When an electrical potential difference is placed across a conductor, its movable charges flow, giving rise to electric current. We would be using this property of conductors to complete the circuit connections as shown below. The material being a conductor completes the circuit and the LED glows.If the material is an insulator, the circuit will not be completed and the LED would remain off thereby indicating presence of an insulator.

Bull in the Ring

December 26th, 2009

Work D

Work Done By- Pranav Ramkrishnan, Std.12th

Objective:

This is an extremely simplistic, yet interesting application using the i-Mach kit to make something that can do real and useful work. The basic aim of this task is to build and program an autonomous robot that can detect objects within its surrounding environment and having detected the object, the robot must push the object out of the arena. However the robot must at all times remain within the arena, just as a bull must remain within the bull fighting arena. Imagine if the bull left the ring, it would result in chaos!

This problem statement adapted in this task is one that has been used in several international robotic competitions and events at high school and college levels , however it has never been attempted with the i-Mach kit, hence giving us opportunity to explore the boundaries of this kit.

To make a robotic application, we shall be using metal cans, as objects and design an arena which is black and has a white boundary around it.

Description of the Robot:

The structure of this robot was made using the mechano parts provided in the i-Mach kit. It was important to design a framework which is both sturdy and compact. Before going into the explanation of the physical structure, here is a list of sensors used to make this particular version of the “Bull”:

· 3 Obstacle Sensor – used to detect the metal can (object), the arrangement of these sensors has been discussed below.

· 2 Line sensors – used to sense the edge of the arena (white) so that the robot does not go out of the arena.

Here is a picture of “Bull” and the design as been explained below:

7.JPG

Figure 1. “The Bull”

Explanation:

Obstacle Sensors:

Sensor2, Sensor3 and Sensor4 are all obstacle sensors, that are used to detect the presence of the object, in close proximity to the robot. In order to make sure that the robot is able to read an object from all angles, the sensors are placed, one facing forward – so that if an object(metal can) is in front, the robot will charge towards it and then push it out. Two more obstacle sensors were placed on the two sides of the robot (left and right) so that if the robot as no object in front of it, but one on either sides, it must be able to detect it, turn to the respective side and then charge forwards to push the can out of the arena.

Line Sensors:

Sensor6 and Sensor6 are line sensors.The placement of line sensors is fairly obvious. The sole purpose of the line sensors is to give a feedback (HIGH) when the sensor is over a white surface and a LOW feedback when the sensor is over a black surface. It is interesting to consider why only two line sensors were placed, one front and back and why no more line sensors were place on either sides of the robot. Well, the answer to this is that the robot will be only pushing the metal can from the front. So Sensor6 is the main line sensor that will be detecting the edge. Sensor5 is an extra sensor, which is used so that in case the robot reversing and moves towards the line, it detects the line so that the robot can move forward. So since the robot will not be moving sideways, there is no need to place anymore line sensors on the side, like we placed obstacle sensors on the side as well.

Now coming to the Physical design:

51.JPG

Figure 2:

In order to build a stable robot, one must keep the robot as low as possible, also since this has a specific function to push an object, the robot must have a grabbing mechanism. Shown in Figure 2, this particular robot can only hold a specific size of obstacle, although is the object is bigger then the robot could still push it forward (of course, provided the motors used can support the load!). While building this grabbing mechanism, one must also remember to protect the sensors from impact with the object. One can make the grabbing mechanism longer and wider, but if that is done, the robot is going to start leaning forward, and may not be as stable as before (centre of gravity will shift forward). Further, the robot will become a lot slower, and generally speaking bulls are fast animals!!

42.JPG

Figure 3: “The Bull” at work

Algorithm:

The algorithm logic used to program this robot is fairly easy to comprehend.

Points to keep in mind while reading this algorithm:

Ø Line sensor is ON over a white surface and OFF over a black surface

Ø Obstacle sensor is OFF when an object is in front of it and ON when there is no object in front of it.

So the algorithm logic is as follows:

1. Move forward.

2. If Sensor6 is ON, then go back, turn around and move forward (this is detecting a white line and then moving away from it)

3. While moving forward check if Sensor2 is OFF, if Sensor2 is OFF continue going forward, until line.

4. While moving forward check if Sensor3 is OFF, if Sensor3 is OFF, then stop and keep turning to the right until Sensor2 is OFF (this means the object is now in front of the robot). Then move forward with the metal can to the edge.

5. While moving forward check if Sensor4 is OFF, if Sensor4 is OFF, then stop and keep turning to the left until Sensor2 is OFF, then move forward.

6. If Sensor5 is ON, then move forward (white edge is behind the robot and it has to move forward).

PROGRAM:

BEGIN

{

FOREVER

{

IF(SENSOR6 IS ON) // Forward Line Sensor detecting a white edge.

{

RIGHTMOTOR(FORWARD,100); // Inspite of detecting the white edge the robot

continues forward for 250 milliseconds to ensure

LEFTMOTOR(FORWARD,100); // that the object has been completely pushed

out of the arena.

WAIT(250);

RIGHTMOTOR(0,0); // Stops for 500 milliseconds

LEFTMOTOR(0,0);

WAIT(500);

RIGHTMOTOR(BACKWARD,100); // then comes backward for 1 sec, to avoid

the line

LEFTMOTOR(BACKWARD,100);

WAIT(1000);

RIGHTMOTOR(FORWARD,100); // takes a differential right turn (turning on the

spot) for 1.5 seconds,

LEFTMOTOR(BACKWARD,100); // this is approximately 180 degree on full

batteries.

WAIT(1500);

}

IF(SENSOR6 IS OFF) // Case when the robot is in the arena, that is on a black

surface, the robot moves forward.

{

RIGHTMOTOR(FORWARD,100);

LEFTMOTOR(FORWARD,100);

IF(SENSOR2 IS OFF) // Conditions while moving forward

{

RIGHTMOTOR(FORWARD,100); // Case 1 – Object in front of the robot, the

robot continues forward, until the white

edge.

LEFTMOTOR(FORWARD,100);

}

IF(SENSOR4 IS OFF)

{ // Case 2 – Object on the left side.

RIGHTMOTOR(0,0);

LEFTMOTOR(0,0);

WAIT(500);

WHILE(SENSOR2 IS ON)

{

RIGHTMOTOR(FORWARD,100); // Turning differentially to the left while

Senso2 reads the object

LEFTMOTOR(BACKWARD,100);

}

RIGHTMOTOR(FORWARD,100); // Pushing the object out after turning.

LEFTMOTOR(FORWARD,100);

}

IF(SENSOR3 IS OFF)

{

RIGHTMOTOR(0,0); // Case 3 – Object on right side

LEFTMOTOR(0,0);

WAIT(500);

WHILE(SENSOR2 IS ON)

{

LEFTMOTOR(FORWARD,100); // Once again turning differentially until

Sensor2 reads the object

RIGHTMOTOR(BACKWARD,100);

}

RIGHTMOTOR(FORWARD,100); // Pushing the object out of the arena.

LEFTMOTOR(FORWARD,100);

}

}

IF(SENSOR5 IS ON) // Behind line sensor detects the white edge. The robot

moves forward to avoid edge. No pushing from the back.

{

RIGHTMOTOR(FORWARD,100);

LEFTMOTOR(FORWARD,100);

}

}

}

END

Here is the Video link to have a glimpse of what the bull in the ring is exactly upto:

http://www.youtube.com/watch?v=SSl5xa6xDNM

Further Development (Food for Thought):

Although this robot is successful in accomplishing its task, that is to push away the metal cans from the arena without leaving the arena, there are possibilities for development and enhancement:

Physical/ Structural:

1. One can think about making a lifting mechanism instead of a gripping mechanism, something like a crane or a forklift.

2. The Robot can be used as a arena cleaner if can be made faster and stronger, so that it can even clean bigger areas.

3. Design an arm such that the robot can lift objects of different dimensions.

Abilities:

1. One could program the robot to pick up an object, come to a particular spot and drop it.

2. Instead of picking up every single object from the arena, the robot can be programmed in such a way that it only selects a particular type of object.

3. This can be further expanded into thinking about sorting out random objects in an enclosed arena into sorted groups.

Education means…

December 26th, 2009

SocialTwist Tell-a-Friend

More over robotics and embedded systems, an aspect that obviously concerns all of us as citizens of a developing nation is the purpose of education. Do we as knowledge donors or seekers comprehend what education has to offer? More than an article, this is meant to be an open discussion to reaffirm the fact that we understand simple but long forgotten goals of the education system and in the process also discover a few which need to be addressed given the current situation. The views presented in this article are not personal and have been influenced by varied personalities and scenarios.

Being unbiased: Mr. Yashwant Kanetkar, the author of many popular C programming books, was once asked in a seminar, “What made your programing skills so strong?” to which he replied, “My mechanical engineering background”. Yes, unlike what you might presume, intellects are not a result of their academic background, but a consequence of pursuit of what they felt might be appropriate for them. Mr. Kanetkar further justified his words by saying that, him being from a mechanical background gave him an edge over all his fellow colleagues (from an IT background) who would fear asking certain questions which they felt would make the audience doubt their past learnings. It is truly the presence of such an educational system which allows choice and provides exposure to experiences that helps the students realize a life-long career path for themselves.

Being enterprising: Being enterprising is more about being responsible, questioning the obvious, challenging long-established practices, existent processes and tools rather than floating a business. I have heard many students saying, “After I graduate, I would like to pursue research….”, whereas the truth is that once you are an employee you cannot afford to research amidst busy work schedules and prolonged delivery deadlines. Your formative years of education are also the most conducive years for innovation which can be exemplified from the fact that the Linux operating system or the Google search engine were all academic projects once upon a time.

Being the change: The country at this point needs technocrats but we seem to encounter bureaucrats more often. Bureaucracy is a complex beast to deal with, since most of the times it is introduced in the process of being systematic, consciously or unconsciously. It is these challenging issues that education teaches us to counter by inculcating values like patience and analysis. Enabling you to view things in a broader perspective is also something that education strives to achieve. As a matter of fact, understanding the way an OS kernel manages hardware resources may help you manage resources in your company though it doesn’t sound that obvious. At the same time applying management practices like six sigma to your software project can help make your software defect free.

Linus Torvalds (needless to say, author of Linux OS), in his book “Just for fun” has put forth a three point philosophy for the purpose of life (which I feel applies cut-copy-paste to education as well), which constitutes,

Survival: Education, directly (formal education) or indirectly (by means of exposure and experience) empowers us to survive in this world with cut-throat competition. All other goals can be addressed only after this primary goal is met, since without survival everything else would be null and void. In a way, it would be correct to say that education means enabling yourselves to live in a world that works on the Darwin’s theory of “Survival of the fittest”.

Social order: Very few of us would deny the fact that the best of friends that we have made during our lifetime are within our academic years, who also become an integral part of our social circle. We seldom realize that things that bind us together are too trivial. At times, these might also be negative things like hatred towards a common subject. Whether it be these negative things or positive things (like the GNU project, which happens to be the largest collaborative project ever), the social bonds that result have to be attributed to education.

Entertainment: This one might raise many an eye-brows but education does bring in entertainment and vice-versa. As an organization with the philosophy, “excite-entertain-educate” we have observed that it is very much possible for education and entertainment to go hand in hand (a trend which can be marked in our workshops); its just that at times education becomes the cause while entertainment becomes the effect and vice versa.

At this point you might wonder what we are trying to arrive at, but the fact is that the purpose was never to conclude; it was to make you “think”.  So, if you have  started thinking already, we would love to hear your viewpoint.

References: http://ideaforge.blogspot.com/

Pune (COEP) iTRIx Workshop Photogallery

December 26th, 2009

Nagpur (YCCE) iTRIx Workshop Photogallery

December 26th, 2009

The Modified Flood Fill Simulator

December 26th, 2009

SocialTwist Tell-a-Friend

Abstract =>

This article will first discuss the Flood Fill algorithm, modified flood fill’s d

SocialTwist Tell-a-Friend

Abstract =>

This article will first discuss the Flood Fill algorithm, modified flood fill’s description and implementation will be built on that. After the boring theory session, the actual C implementation of the algorithm will be discussed and a sample simulator program is provided at the end of this article.

It should be noted that the algorithm and some of the pictures used in this article have been taken from ‘micromouseinfo’ website,

http://www.micromouseinfo.com/introduction/floodfill.html

http://www.micromouseinfo.com/introduction/mfloodfill.html

Prerequisites =>

This article requires the reader to have some basic knowledge and understanding about the following topics

  1. Basic logical constructs of C like if-then-else, while, for etc.
  2. Understanding of bitwise operators in C.
  3. Implementation of Stack using arrays.
  4. Simple 1D array manipulations.
  5. Writing subroutines in C and macros.

It is advised that before putting up any question on the forum regarding doubts about the software implementation of the Modified Flood fill algorithm, the reader goes through some C-language tutorial like the one given here,

http://www.lysator.liu.se/c/bwk-tutor.html

The Flood Fill Algorithm =>

The best way to understand the flood fill algorithm is the water-in-the-maze analogy. This is how it goes,

Suppose you start pouring water in the center square of the maze (I would love to know who actually tried it first). The water will ‘flood’ the center of the maze and then will start flowing in all the adjacent squares which are ‘not separated by a wall’. If I mark the first square, that is the center, as 0 and mark the next square(s) where the water goes as 1 and keep on increasing the number as the water ‘floods’ the maze, I’ll get something like this

Starting from the center square

The water is now flooding the maze, and I am numbering the squares in ascending order. That is, water reached the square numbered 4 before reaching the square numbered 5 or 6 or 7.

Floods in the Maze!!!

Completely flooded!

Done flooding, with water! (You got a dryer or something?)

Now taking the bottom left square as the starting point, if I follow the numbers in descending order, you can see that I will reach the center through the shortest path! Amazing….yes….hard to digest….YES!

This was my reaction when I first got the hang of flood fill.

Flood Fill can be understood in another manner, something that I call the ‘potential difference’ analogy. Water is still used here [:-)] !

Suppose there are two squares A and B. I put A at a higher potential than B and pour a glass of water in A. It is obvious that the water will reach the square B taking the shortest path, given there exists a path (i.e. no wall present) between A and B.

Above point is shown at a larger scale in the following picture and this should clear any doubts in your mind regarding this algorithm (hopefully).

Flood Fill Potential Difference Analogy

It should be noted here that this illustration has no connection with the ones shown before. Here also, it is easy to see if squares are chosen in ascending order of their potential from the starting square, the center can be reached by the shortest path.

This algorithm has a relatively simple implementation in the software. Two arrays should be maintained in the memory, one for keeping the flood fill numbers and the other for keeping the wall information of the maze. Every time the mouse enters a new square, it stops and checks for the walls, runs the flood fill algorithm, decides where to go depending upon the information given by the flood fill and moves on till it finds the center. Needless to say, this is not a great approach, firstly because your mouse is stopping at every square and secondly, you are flooding the maze from the center every time. This is where the modified flood fill kicks in.

The Modified Flood Fill Algorithm =>

The modified form of flood fill is nothing different from the original one, just that we don’t flood the whole maze every time. It changes only those flood values which need to be changed. Have a look at the link given below,

http://www.micromouseinfo.com/introduction/algorithm.html

This is a very good demonstration of modified flood fill for maze solving.

Algorithm Formulation =>

Before I start describing the various parts of my modified flood fill simulator, we need to formulate the various parts of our algorithm in simple English language.

This part has been taken from micromouseinfo.com.

Whenever we enter a cell, we check for the walls and update the wall map accordingly.

Update the wall map:

Is the cell to the North separated by a wall?
Yes -> Turn on the “North” bit for the cell we are standing on and
No -> Do nothing

Is the cell to the East separated by a wall?
Yes -> Turn on the “East” bit for the cell we are standing on and
No -> Do nothing

Is the cell to the South separated by a wall?
Yes -> Turn on the “South” bit for the cell we are standing on and
No -> Do nothing

Is the cell to the West separated by a wall?
Yes -> Turn on the “West” bit for the cell we are standing on and
No -> Do nothing

Now we need to call the modified flood fill to flood only that part of the maze which is required. The cell values are updated according to the following rule,

If a cell is not the destination cell, its value should be
one plus the minimum value of its open neighbors
.

When the cell values violate the above rule, they need to be updated.

Update the distance values (if necessary)

Make sure the stack is empty

Push the current cell (the one the robot is standing on) onto the stack

Repeat the following set of instructions until the stack is empty:

{
Pull a cell from the stack
Is the distance value of this cell = 1 + the minimum value of its open neighbors?

No -> Change the cell to 1 + the minimum value of its open neighbors and
push all of the cell’s open neighbors onto the stack to be checked
Yes -> Do nothing
}

The stack empty check is not required in the program presented in this article.

The wall map is updated, required part of the maze is also flooded now what? Guess we need to make the right move.

Decide which neighboring cell has the lowest distance value:

Is the cell to the North separated by a wall?
Yes -> Ignore the North cell
No -> Push the North cell onto the stack to be examined

Is the cell to the East separated by a wall?
Yes -> Ignore the East cell

No -> Push the East cell onto the stack to be examined

Is the cell to the South separated by a wall?
Yes -> Ignore the South cell
No -> Push the South cell onto the stack to be examined

Is the cell to the West separated by a wall?
Yes -> Ignore the West cell

No -> Push the West cell onto the stack to be examined

Pull all of the cells from the stack (The stack is now empty)
Sort the cells to determine which has the lowest distance value

Move to the neighboring cell with the lowest distance value.

After making the move, the above process is repeated again and again till the mouse reaches the center/runs out of gas/stops to say ‘Hi!’ to you/stops for a photograph/bangs into the wall!

The Modified Flood Fill Simulator =>

I know you were waiting for this, the ‘real thing’!

The simulator is divided into two parts, the ‘.c’ file which implements the algorithm and the header ‘.h’ file which provides the graphics and basic front, left and right movements. At this point you might think that the main program is the most important thing, but you must understand that the header file is a general purpose file which can be used to implement any higher level maze solving algorithms.

The main program file, ‘Modified Floodfill_TRI.c’ has three routines,

  1. The ‘main’ routine
  2. The ‘step’ routine
  3. The ‘floodfill’ routine
  1. The ‘main’ routine

This is where the action takes place. ‘main’ is responsible for maze mapping, calling the floodfill routine to flood the maze and then calling the step routine to make a move.

The maze is mapped according to the algorithm given above.

  1. The ‘step’ routine

This function is the implementation of the above ‘Decide which neighboring cell has the lowest distance value’ algorithm.

  1. The ‘floodfill’ routine

This is where modified flood fill takes place. It takes the maze’s cell number as an argument and floods the maze assuming that the given cell number is the destination.

The ‘MAZE.h’ header file deals only with the graphics and I must clearly state here that it has not been written by me. It has the following functions that you are supposed to know,

  1. void movestraight(int)

This function makes the mouse on screen go straight the number of squares mentioned in the argument when calling.

  1. void turnleft()

This makes the mouse point to its left direction. If you call the movestraight(1) function after calling turnleft(), the mouse will move into the square in its left.

  1. void turnright()

This makes the mouse point to its right direction. If you call the movestraight(1) function after calling turnright(), the mouse will move into the square in its right.

You should note that the left and right directions are relative to mouse and not yours’ left and right, don’t get confused.

  1. void show_maze()

Calling this function would display the maze on the screen. This should be done in the start of the main().

  1. int sense(int)

This function has three arguments, FRONT, LEFT and RIGHT. It returns a high(i.e. ‘1’) if there is a wall in the given direction. Basically this is the sensor of your virtual mouse on screen.

  1. int hori_walls[sizemaze+1][sizemaze] and int vert_walls[sizemaze][sizemaze+1]

These two variables contain the maze’s wall information. Putting a ‘1’ builds a wall, ‘0’ removes it. I have provided two actual competition mazes for you. One was used in a competition in the USA in 1982 and the other was used in Japan in 1991 (yes, we are far behind them). The design has been taken from Peter Harrison’s micromouse site,

http://micromouse.cannock.ac.uk/maze/samples.htm

Watch out for that Japanese maze, it is the best I have ever seen. Also, you can build your own test maze.

Before going through the simulator program, you need to understand a few things about this implementation,

  1. I have tried to make things as simple as possible(with few exceptions of course!), thus the implementation is not very efficient in terms of memory consumption and execution speed, mainly because of my 2.4Ghz machine with 1Gb RAM. You are probably going to implement this on a 16MHz 2Kb thingy (ATMega32), so take this program as a reference only.
  2. The maze has been mapped as a 1-dimensional array to maintain simplicity and has been visualized as shown below

The Maze, as perceived by my virtual mouse

In the implementation, cell number 119 has been taken as the destination cell. This happens to be the bottom left cell of the maze’s center.

  1. The directions have been taken like this

Directions with respect to maze

It is pretty evident that if the mouse is facing north in the cell number ‘x’ and it moves straight one cell, it will find itself in the cell number ‘x+16’.

If the mouse is facing west in the cell number ‘x’ and it moves one cell to its left, it will find itself in the cell number ‘x-16’. You can work out for other directions and movements in a similar way.

  1. The maze’s wall information is stored in the variable ‘wallmap[256]’. The maze’s dimensions is 16×16, representing it by a one dimensional array would require 256 memory locations.
  2. A single wall is represented in the following manner

[BIT7] |V| [BIT6] |0| [BIT5] |0| [BIT4] |0| [BIT3] |W| [BIT2] |S| [BIT1] |E| [BIT0] |N|

Here, V stands for visited. ‘1’, cell is visited, unvisited otherwise. W stands for the wall in cell’s west direction. Here, the west is the maze’s west not the mouse’s west. S, E and N have similar meanings.

  1. The current direction of the mouse is represented as follows

[BIT7] |0| [BIT6] |W| [BIT5] |0| [BIT4] |S| [BIT3] |0| [BIT2] |E| [BIT1] |0| [BIT0] |N|

These directions refer to the absolute maze’s directions. For example, if the mouse is facing east, i.e. the 2nd bit current direction is ‘1’, then the mouse’s left is maze’s north and its right is maze’s south.

You need to go through this direction part again and again until you get the hang of it otherwise you won’t be able to understand a major part of the program.

In this format when I change the direction of my mouse, I simply rotate the direction bit left or right. This is done every time after I make a move in the maze. See the program to get what I am trying to say.

7. The unsigned char wallflood[256] variable holds the flood fill numbers (or the potential values) of the squares. This variable is initialized with values assuming that there are no walls in the maze.

8. There is a variable in the program called cell_count, this variable was declared solely for debugging purposes and has no use in the current program. You can surely put it to some good use.

9. Rest of the code is very heavily commented (that’s my habit, a good one) and is pretty much self explanatory given you have gone through the theory part and you have a good command in C.

10. Please go through ‘Read Me.txt’ before running the simulator on your PC.

Final Remarks =>

First things first, flood fill algorithm of any kind is pretty inefficient. Your mouse will take a long time to reach the center and come back for a speed run. But yes, you will reach the center and complete the problem statement which might be enough for you to be the champion!

There is a reason why I like that Japan competition maze, the shortest path in it is not the fastest one! Yup, this is possible! Here, you will see, flood fill’s performance is horrible. Here, something you need to know about the pedigree of flood fill. Flood Fill Algorithm has been derived from Kruskal’s Algorithm which happens to be a kind of greedy algorithm. Kruskal’s Algorithm finds a minimum spanning tree (i.e. the shortest path in the maze) for a connected weighted graph (which is The Maze). I know I am speaking too much! It does not assigns costs to the paths, that is, a turn takes more time than a straight and hence, ‘costs’ more. Kruskal’s Algorithm doesn’t cares about this.

A simple idea to work around this problem could be like this,

1. After coming back to the start for a speed run, the mouse stops and calculates the fastest path.

2. Check all the cells that the mouse has visited.

3. Out of those cells, figure out how many paths lead to the center.

4. The path involving minimum turns will be the fastest path.

Here I have a made the important assumption that your mouse does not makes diagonal runs. If it does, then the problem is much more complex than you think and you better opt for A* (pronounce A star) or Dijkstra’s Algortihm (pronounce diaofoasdfsdfet [:-)]  ).

All the Best for the Techfest 20xx…….and Happy microMousing!

Read Me

Maze.h

Modified Floodfill.c

How to use an LCD module?

December 26th, 2009

LCD or Liquid Crystal Display is nowadays fast becoming a preferred choice for an interface device due to its ease of use,cheap rates and value for money performance.
They are available in various specs 16X1 16

LCD or Liquid Crystal Display is nowadays fast becoming a preferred choice for an interface device due to its ease of use,cheap rates and value for money performance.
They are available in various specs 16X1 16X2 20X2 etc�
The first number denotes the number of characters/line and second denotes the number of lines.

The most widely used LCDs are based on the HITACHI HD44780 controller.
It has 16 pins arranged in the following configuration:
1 � Vss
2 � Vcc

3 � Vee
4 � RS
5 � R/W
6 � EN
7 � DB0
8 � DB1
9 � DB2
10- DB3
11 � DB4

12 � DB5
13 � DB6
14 � DB7
15 � LED+
16 � LED-

* DB0-DB7: Data Pins
* RS: 1 � Data 0 � Command
* R/W: 1 � Read 0 – Write
* EN: To be Pulsed when to execute any operation

* Vee: Contrast Adjust Pin

We will be using the LCD in 4 bit mode. This amounts to using 7(3 control signals and 4 for data) bits for controlling the

LCD instead of the normal 11.
In 4 bit mode the DB4-DB7 data lines are used for writing data. The upper nibble of data is sent first and then the lower

nibble of data is sent. In 8 bit mode the whole byte is sent at once.

LCD command library (Courtesy Team TRI):

LCD_INIT()
Initializes the LCD in 2 line 4 bit mode with blinking cursor.

LCD_WRITE(�X�)

Used to write any character X to the LCD.

LCD_STRING(�Xplore Robotics�)
Used to write a string on the LCD (max 16 characters in length)

LCD_CMD(X)
To give commands to the LCD. X can be as follows
PUTLINE1 � Places cursor on line1
PUTLINE2 – Places cursor on line2
DISPON � Turns display on

To place the cursor on a particular character box it is addressed as follows:

Command = LCD_CMD(0b1XXX XXXX);
where xxx xxxx is the address of character in binary.

Note: LCD row 1 address starts at 0×00 and row 2 starts at 0×40

Eg: To put cursor on 3 character line 1
LCD_CMD(0×83);
To put cursor on 5 character line 2
LCD_CMD(0xC5);

LCD_CLEAR()
Clears LCD screen.

Sample Program:
#include”REG52MOD.h”
#include�LCD.h�

void main (void)
{
LCD_INIT();
LCD_STRING(�Hello World�);
while(1){}
}

No prizes for guessing what THIS program is supposed to do!!!!

Let�s move onto something higher

#include”REG52MOD.h”
#include�LCD.h�

void main (void)
{
LCD_INIT();
LCD_STRING(�USING�);
LCD_CMD(PUTLINE2);

LCD_STRING(”LCD”);
delay(100);
LCD_CLEAR();
LCD_CMD(0×83);
LCD_STRING(”IS”);
LCD_CMD(0xC5);
LCD_STRING(”COOL”);
while(1){}
}

Having fun aren�t we???

I think I should end this tutorial here and leave you with things to experiment .Some good pages to visit for inside

information about the working of an LCD are

http://www.myke.com/lcd.htm
http://www.geocities.com/dinceraydin/lcd/index.html (you�ll find a nice cool LCD simulator on this page)

SOLAR ROLLER out of basic Electronic Components

December 26th, 2009

SocialTwist Tell-a-Friend

Solar Roller

Work Done By-SANDEEP GILL

Wanna build your first simple solar roller using discrete and easily available electronic components(R,C,diodes etc.). Here is where you begin. Solar Roller is a beam-dragster robot that utilizes sunlight as a source of energy. Mostly in all solar competitions this being quite a popular event, wherein two solar bots are placed side by side on a track and they have to travel a distance of 1 meter in shortest time using light source coming from overhead high watt bulbs. So, let’s try and build a simple solar roller.

Check out these links for problem statements of the solar roller competitions

http://techfest.org/nexus/photoroller/

http://www.robotgames.net/robotgames/pdf/2002%20solar%20roller.pdf

Component List:

1 Solar Panel- 4 V, 90 mA

1 Storage Capacitor 0.047F, 5.5V

1 3V3 Zener diode

1 mini DC motor with sleeves

Two Transistors –2N2222A & 2N2907A

1 Resistor- 50 K

Two small wheels (taken from mechano parts) without rims

A foam board body design

Construction Details:

1. Body design: Cut a piece of foam board in a rectangular shape and attach two small wheels at the front side. The wheels are screwed to the foam board via 90degree clamps with an axle passing through them.

untitled2.JPG

2. Attaching the Motor

Mini DC Motor Mini DC motor

Put on a sleeve onto the motor and attach it to the rear side of the foam body with the help of a mechano strip bended at an angle of 45-60 degree to touch the ground so that it is as close as possible to centre of body.

untitled3.JPG

This is how the whole body will look:

untitled.JPG

3. Solar Engine:

solar-cel_zd.JPG

Working: This is a Zener based SE. This design uses a Zener diode as means of determining the trigger voltage. The reverse bias operating voltage of the Zener is used as means of triggering point in the circuit. You can also use LED’s or diodes in series to accomplish the same trigger voltage. For further readings:

http://www.beam-wiki.org/wiki/index.php?title=Zener-based_Solar_Engines

http://faq.solarbotics.net/oscillate.html.

You could veroboard the circuit like this:

veroboard the circuit

Attach the solar engine to the centre of foam body with help of a double sided tape and connect the motor to the berg terminals.

Solar Engine

4. Attaching the Solar panel

Take out two wires from the solar panel for giving the supply to the solar engine.

Attaching the solar panel

Just place the solar panel at the rear side of the foam body with help of a rubber band or a double sided tape.

Attaching the solar panel

5. Complete Solar Bot:

Complete solar bot

 

Complete solar bot

Results: Testing our newly built solar roller under light gave us quite good results. The solar roller was working in longer bursts – less frequent rate mode i.e. travelling a distance around 25-30 cm during his burst cycles of 3-4 sec occurring every 15-20 seconds. The solar bot was placed on a table and driven by a source of 100W light bulb from a distance of 20-30 cm from the table. We took 3-4 readings holding the light bulb at varied distances from the table and the approximate time to travel a distance of 1meter varied from 47 seconds to a little more than a minute.

Further Modifications:

Mechanical design modifications: Though this design is quite light weight, there is a little problem with the roller it slightly keeps deviating from the straight track i.e. because of the front wheels are not properly locked and also the motor shaft is little offset from the centre (motor tilt angle is changed). So you could try building a design where in the motor is attached to an axle driving two idler wheels and you attach a third pint of contact via a skid or and idler wheel. Also try using even smaller wheels to cut down the torque even further.

Circuit modifications: 1. Try varying the trigger voltage by using a Zener of higher or lower value which will decide duration of bursts as well as their rate of occurring.

2. Try varying the storage capacitor value. Since we have already used a large capacitor you could test the circuit a smaller cap around 4700-10000 microfarad and work with shorter bursts – more frequent rates.

3. Try varying the feedback resistor will help in making the bot tolerant to motor variants & inefficiency, it also helps in decreasing the charge time of capacitor little bit.

4. Try varying the size or current ratings of solar panel. Higher current ratings will help in giving in more current for motor runs but the solar panel size is going to increase.

Further readings:

http://www.solarbotics.com/assets/documentation/solarbotics_solarspeeder2_kit_may022007.pdf

http://library.solarbotics.net/apocrypha/pix/solaroller_mechanics.gif

http://library.solarbotics.net/apocrypha/pix/solaroller_circuits.gif

http://www.robotgames.net/RobotGames/Event_Rules/2002-BEAM-solaroller.html

http://www.beam-online.com/Robots/Galleria_other/solarollers.html