Author
Topic: $50 robot using atmega16 (Read 3833 times)

So I made the necessary connections that reflect the atmega 8 chip onto the atmega 16 already. I am using a STK500 board, so I did not build the onboard programmer as the guide said. My question is based on the changing of the code. This is what I have tried so far for the SoR_utils.h

//*********SIMPLIFIED FUNCTIONS**********//functions to make coding easier for a beginner//but could cause port mixup confusion for intermediate usersvoid LED_on(void){PORT_OFF(PORTB, 0);//turn LED on}void LED_off(void){PORT_ON(PORTB, 1);//turn LED off}void servo_left(signed long int speed){PORT_ON(PORTD, 1);delay_cycles(speed);PORT_OFF(PORTD, 0);//keep offdelay_cycles(200);}void servo_right(signed long int speed){PORT_ON(PORTD, 1);delay_cycles(speed);PORT_OFF(PORTD, 0);//keep offdelay_cycles(200);}//***************************************Still no go. Am I supposed to change anything else (setting wise in programming software/code), or any other files? Also when I check the pins, I am just checking for 5 volts on the legs used right?

did u actually connect the servos to the changed pins , did u see the makefile and changed the mcu name to atmega16 instead of atmega8, did u use the correct name of the programmer in the makefile, did u define the correct speed of ur microcontroller in the makefile???

//*********SIMPLIFIED FUNCTIONS**********//functions to make coding easier for a beginner//but could cause port mixup confusion for intermediate usersvoid LED_on(void){PORT_OFF(PORTB, 0);//turn LED on}void LED_off(void){PORT_ON(PORTB, 1);//turn LED off}void servo_left(signed long int speed){PORT_ON(PORTD, 1);delay_cycles(speed);PORT_OFF(PORTD, 0);//keep offdelay_cycles(200);}void servo_right(signed long int speed){PORT_ON(PORTD, 1);delay_cycles(speed);PORT_OFF(PORTD, 0);//keep offdelay_cycles(200);}//***************************************Still no go. Am I supposed to change anything else (setting wise in programming software/code), or any other files? Also when I check the pins, I am just checking for 5 volts on the legs used right?

first of all the turn off led and turn on led are messed up interchange the codes , also if u are turning on the 1st pin of portb why do u turn off the 0th pin of portb , this is a mistake turn off the 1st pin of portb instead

2nd

in the left servo code ur turning on the 1st pin of port d and turning off the 0th pin of portd , that doesnt make any sense if u turn on pin 1 then turn off the same pin why do u turn off another pin???

Regarding the LED then Admins code is CORRECT. Check the circuit diagram. One end of the LED is connected to +5v and the other (via resistor) to the port. So you need to set the port low/off in order to make the LED come on, and set the port hi/on to turn the LED off.

Regarding the F_CPU question then there is an issue with Admins original makefile. Although he defines the variable F_CPU as per the previous attachments it is NOT passed to the compiler (ie it has NO effect at all so the fact that you may have it set to the wrong value doesn't matter as its not used)!

NB This is for an atmega8 - so you will need to check what clock rate an atmega16 runs at. I dont have one but check the atmel website specs if in doubt.

Next you will need to edit the 'global.h' file that Admin created. Since the makefile didn't used to do anything with the F_CPU info then he set it up again in 'global.h'. Now the makefile is correct then you can delete the following lines from 'global.h' since the value of F_CPU is passed in from the makefile.

#ifndef F_CPU#error Your makefile doesn't define the processor clock speed in F_CPU#endifThis means that the compiler will generate an error if you forget to define F_CPU in the makefile, or you use Admins old version that doesn't pass it in.