Author Topic: programming the atmel avr mcu in c  (Read 3344 times)

0 Members and 1 Guest are viewing this topic.

Offline harrypotterjkwTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
programming the atmel avr mcu in c
« on: October 09, 2007, 11:59:27 AM »
hey guys please help me program the atmel avr atmega8 or mega16 in c
please (if you know of any ) give me a link to a good (free e book) tutorial on the same.

Offline harrypotterjkwTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: programming the atmel avr mcu in c
« Reply #1 on: October 11, 2007, 09:50:35 AM »
PLEASE ...

this is a really urgent situation.
i have read admin's 50 $ robot tutorial.
i want to make 2 robots autonomous where a part of the task of the robot is to follow a white line.
i need help in the following areas:
 
 1. i want to program the mcu in c but dont know much about how to prog. avr mcu in c (though i know c). so please give a link to a very good c programming tutorial for the atmel avr atmega family...
 
 2. in the 50$ robot tutorial admin asked to download avrstudio 4 but when ever i try to run any prog in it ,it shows that it i dont have GCC.
  i use win xp. how do i get GCC?
  another thing, first avrstudio 4 is used to write the c prog. and then to compile it right? as a result we get 3 files one of which is a .hex file right?
then we open the .hex file using pony prog and then using the avr stk serial port dongle programmer to upload the prog into the mcu memory right?
 
 3. how do i use geared dc motors in my line following robot (that is how do i interface it with the mcu, and the prog part and the circuit)

 4. how do i interface infrared detectors (i am using them instead of the photoresistors since the former are more sensitive) with the mcu, and the prog part and the circuit diagram...

 5. and finally also help me with the stepper motors just like the dc motors.


     ok i am sorry for asking so many questions (may be because i am an absolute dumb person or may be because i am a completely beginner in this field) but pease please help me its urgent i have got to complete this robot within half a month.

   finally you can simply help me with my problems 1 3 4 and 5 by simply giving me a link to a very good (for beginners) e book (i would appreciate free e books) on c programming the atmel avr atmega 8 or mega16 and the involved circuit diagrams.


   so please help me....

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,666
  • Helpful? 169
    • Society of Robots
Re: programming the atmel avr mcu in c
« Reply #2 on: October 11, 2007, 06:22:26 PM »
Quote
i want to program the mcu in c but dont know much about how to prog. avr mcu in c (though i know c). so please give a link to a very good c programming tutorial for the atmel avr atmega family...

http://www.societyofrobots.com/robotforum/index.php?topic=1014.0
Also, look at my code and try to reverse engineer it. Lastely, read the datasheet for the microcontroller ;D
(its a bit overwhelming at first, just take it a little at a time)

Quote
in the 50$ robot tutorial admin asked to download avrstudio 4 but when ever i try to run any prog in it ,it shows that it i dont have GCC.
  i use win xp. how do i get GCC?

its included when you install WinAVR (at the top of the tutorial)

Quote
as a result we get 3 files one of which is a .hex file right?

the one with the .hex extension :P

Quote
then we open the .hex file using pony prog and then using the avr stk serial port dongle programmer to upload the prog into the mcu memory right?

yeap

Quote
3. how do i use geared dc motors in my line following robot (that is how do i interface it with the mcu, and the prog part and the circuit)

I recommend just sticking with the servos. But to interface a motor, you will need a motor driver. Just search this forum/google for it.

Quote
4. how do i interface infrared detectors (i am using them instead of the photoresistors since the former are more sensitive) with the mcu, and the prog part and the circuit diagram...

http://www.societyofrobots.com/schematics_infraredemitdet.shtml

Quote
5. and finally also help me with the stepper motors just like the dc motors.

hmmmm I dont recommend bothering with steppers right now, they can be challenging for a beginner. Just stick with the servos ;D

If you have further questions dont forget to search the forum first, most questions have been asked already :P

Offline harrypotterjkwTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: programming the atmel avr mcu in c
« Reply #3 on: October 16, 2007, 02:28:40 AM »
Quote: hmmmm I dont recommend bothering with steppers right now, they can be challenging for a beginner. Just stick with the servos ;D


...the problem Admin is that servos here (india) are very expensive Rs650 was the cheapest that i could find.
i want to keep my budget under Rs.1000 (1$=Rs39.50) for the entire robot.
 so i m left either with stepper or the dc with h bridge. but i dont trust the dc motors as they can be very fast and annoying and thus the robot can easily go off line, and even if you use low freq. PWM then too usefull battery power is wasted.

 question that i have already searched the forum for and am not answered is:

  1.in case of a 5 wire unipoler stepper motor why do we need to use a controller. we can easily control it this way:

      plug the common wire to +12V and the 4 control wires to any four ports of mcu. (say PC0...PC3 of atmega16) and then code accordingly, say to roll forward one complete rotation...
     
      DDRC=0x00;     //config portc as output port
      int array[]={0b01111111,0b10111111,0b11011111,0b11101111}; //current flows while port bit=0
      int i,j;
       for(i=0;i<200;i++)                              //200x to complete 200x1.8 deg= 360 deg complete rot.
          for(j=0;j<4;j++)                            //4x to complete 1.8 deg step angle
             PORTC|=array[j];
                               
     
       ...so is it right or have i got something wrong?


2. there seems to be some problem with your photovore + sorutils source code, my avrstudio 4 dosn't seem to have a header file called "a2d.h". even when i copy pasted your a2d.h and a2d.c in the include folder of winavr the problem seems to persist. so i cannot seem to interface and use the ADC ports (PORTA) of mcu to take my sensor readings.

 

  PS>I have almost finished doing the entire ckt diag. of the robot.(in pen and paper off course,its always convinient the old fashioned way)  and would probably finish the program very shortly. I dont have any of the hardware yet but hopefully would get all  my parts by mid nov 07. before that happens  i intend to put in paper and then in this post  all the nitty gritty of the final product (ckt diag, algo, prog, actual physical diag) and have it approved by the ADMIN and possibly the other members (if they are kind enough) for any possible mistakes....am on a very tight budget...can't afford  a mistake and retry.

   

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,666
  • Helpful? 169
    • Society of Robots
Re: programming the atmel avr mcu in c
« Reply #4 on: October 16, 2007, 04:56:52 AM »
So for you #1 . . . although your controller can provide the proper signal, it cannot provide enough power to your stepper. You would need a MOSFET on each signal line to amplify current. A stepper driver however has all of this built in, and only requires two of your output pins (freeing up the rest for something else).

For #2 . . . did you install WinAVR? I think you are missing gcc . . .

Quote
can't afford  a mistake and retry
welcome to robotics ;D

 


Get Your Ad Here

data_list