Author
Topic: Help me with Microcontrollers! (Read 3456 times)

:)Hi,I am quite a newbee to robotics ( i have only made one BOT, a differential drive based 2 DC Motor driven wire controlled speed boat for a robotics competition in my college Techno India in Kolkata in India on March '07).There was an event in the competition called LINE FOLLOWER where you have to make an autonomous robot that follows a white patch of thick line on a black surface. I know that its done with the photoresistor thing to identify where the line is going to the left or to the right. This thing really fascinated me but unfortunately I could not participate in it because I had no knowledge of Microcontrollers which are the brains of these kind of robots.

I would like to add that I am a second year onto third year computer science engineering student and I have a background of BASIC ELECTRONICS and programming languages like GW BASIC, C, C++, and am going to learn Java soon in my 3rd year 6th semester. Thus I humbly ask you people to help me learn all about Microcontrollers (recently I have been surfing a bit about it and have learned the basics, but the real hitch is the ATTACHING THE MICTOCONTROLLER WITH THE DIFFERENT SERVOS AND THE OTHER SENSORS AND PROGRAMMING IT), so that I might be able to make my own LINE FOLLOWER by the end of January '08 so that I can take part in the college robotics compition.

The first edition of the college fest (technilcal fest) was held in March '07 for more information about the festvisit www.edg.co.in

Well, basically, a microcontroller is a CPU with embedded peripherals, ram and storage, so if you know how to program, getting into microcontrollers won't be too hard.

Of course writing programs in assembler is more complicated but for example, here are some simple routines for controlling servos in CCS C (for PIC microcontrollers):

let's say you want to move a servo to the left when you get a signal on certain pin, that will be a bit in a register. The compilers have aliases for this pins so you don't have to always remember that. For example, pin 2 will be PORTA.1 or PIN_A1 (constant).

then you make a routine like this: (very simple)

if(PORTA.1==1){for(i=0;i<10;i++){output_high(PORTB.1); // servo output pin = high. This varies from compiler to compiler, some are like PORTB.1=1 or in BASIC is something like high PIN3delay_us(1300); // Again, this varies from compiler to compiler, we are making a delay of 1500 uS (1.5 milliseconds)output_low(PORTB.1); // servo output pin = low. delay_ms(18); // 18 milliseconds delay for a total of 19.3 ms... this works ok on a 20ms servo but you can also use delay_us }}

Ok, so we just sent a 1.3 ms pulse 10 times if a pin (sensor) was on.

There are better ways to do this of course but you will have to learn that. (Like using Interrupts or a RTOS).

You can try getting some samples from Microchip (I recommend getting 18f1320, 18f1220 and any 28 pin like 2431 or 2580 since they are small but powerful and you can use the free C18 Compiler from Microchip). You will also need a programmer, but I think your college will have one somewhere if it's making robotics challenges.

One of the best ways to learn about microcontrollers and how they interface to sensors, servos, etc. is to buy a Parallax BOEbot. A complete BOEbot kit will provide you with all the hardware and electronics you will need. One of the best parts is the documentation which walks you through the entire process step by step. You can find out more at http://www.parallax.com/detail.asp?product_id=28132. You can download the documentation for free at http://www.parallax.com/dl/docs/books/edu/Roboticsv2_2.pdf. The software for the development environment is also free.

I think it is the best way to get started and develop a solid understanding of microcontrollers and robots. They also offer a bunch of other great tutorials including - What's a Microcontroller? - Understanding Signals - Basic Analog and Digital - Smart Sensors & Applications - Process Control - Applied Sensors

As u said S. Karim Parallax sell a kit named "Whats a microcontroller" The book u get included in this kit is also online in a free PDF file, im on a different computer now but i can send it to u, would u like that?

Yes, Parallax does offer a Stamps in Class curriculum called "What's a Microcontroller" as I noted in my response above. I did not suggest that curriculum as harrypotterjkw was interested in both robotics and microcontrollers. That is why I recommended the BOEbot curriculum instead.

Thanx guys for all that!as you see what i wanted to learn is the MCU broken down to the simple logic gates that make them workI already have a good understanding of the principles of BASIC ELECTRONICS that is gates , adders, MUX , decoders ADC, DAC and all that stuff and also a basic understanding of how RAM (both static and dynamic types) and ROM work that is the basic electronics behind their wirking.

And by the way as I am new to MCUs which MCU (I mean brand and type) would you people prefer me buying so that I might be able to reuse it again ( I know they are versatile, its the logic that you put that makes the difference, but what I mean is that which MCU should see me through demanding number crunching situations as well as provide adequate space in their EEPROMS and ROMS ,number of instruction lines that they can hold).

And bye the way thanx steve joblin for that link to BOE BOTI think its going to help me a lot Another question that I have is that 1) the chips are called MCUs,right? -then what are those green mother boards? are they the same thing that ADMIN has been teaching how to build in his "$50 robot tutorial"? 2) if so, then which is better (or say which way is it cheaper), to buy the assembler board (I think thats what its called) or to build one from scratch as ADMIN has shown in his tutorial.

Thanx guys for all that!as you see what i wanted to learn is the MCU broken down to the simple logic gates that make them workI already have a good understanding of the principles of BASIC ELECTRONICS that is gates , adders, MUX , decoders ADC, DAC and all that stuff and also a basic understanding of how RAM (both static and dynamic types) and ROM work that is the basic electronics behind their wirking.

And by the way as I am new to MCUs which MCU (I mean brand and type) would you people prefer me buying so that I might be able to reuse it again ( I know they are versatile, its the logic that you put that makes the difference, but what I mean is that which MCU should see me through demanding number crunching situations as well as provide adequate space in their EEPROMS and ROMS ,number of instruction lines that they can hold).

If you are on a tight budget you can try requesting free samples from Microchip (read the other post). The advantage of buying a preprogrammed MCU like a Basic Stamp from parallax is that they are easier to program (you only need a serial cable or usb cable depending on the model) and also that they have a free BASIC IDE for their controllers, but they are also more expensive.

harrypotterjkw: yes, MCU, Micro Controller Unit, Micro Controller, Micon are all different ways of saying the same thing. the MCU is all contained in a single chip. To use it, may require several other components (such as an EEPROM chip to store your program, resistors, capacitors, resonators, voltage regulators, and other components so it can accept your program as you download it from your PC to the EEPROM). Some chips have many of these components built inside the MCU chip (for example, a PICAXE-08M MCU only requires two external resistors and a regulated voltage source to download and run a program), while others like the Parallax BASIC Stamp requires many external components to download and run a program. The Parallax Stamp is actually a very tiny circuit board that contains all of these components. The circuit board is actually the size of some chips, about the size of a postage stamp, which is where it got it's name!

The confusion is that people refer to augmented microcontrollers (a microcontroller with lots of goodies attached to it) as just a microcontroller. I do it too, so it often results in this confusion . . .