PDA

View Full Version : [Question(s)] AVR Studio help - my first robot



grixxlee
02-27-2010, 01:27 PM
Hello, I am trying to program my first robot, a Pololu 3pi. I have downloaded and installed the AVR Studio and libraries. When i try to build the sample line following pid program I get several errors and I am not sure what I have done wrong. Any help will be greatly appriciated.
Thank you

the errors listed are

Build started 27.2.2010 at 13:40:03
avr-gcc -mmcu=atmega328p -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d -c ../test.c
../test.c:15:24: error: pololu/3pi.h: No such file or directory
../test.c: In function 'load_custom_characters':
../test.c:58: warning: implicit declaration of function 'lcd_load_custom_character'
../test.c:65: warning: implicit declaration of function 'clear'
../test.c: In function 'display_readings':
../test.c:86: warning: implicit declaration of function 'print_character'
../test.c: In function 'initialize':
../test.c:100: warning: implicit declaration of function 'pololu_3pi_init'
../test.c:104: warning: implicit declaration of function 'print_from_program_space'
../test.c:105: warning: implicit declaration of function 'lcd_goto_xy'
../test.c:107: warning: implicit declaration of function 'play_from_program_space'
../test.c:108: warning: implicit declaration of function 'delay_ms'
../test.c:117: warning: implicit declaration of function 'button_is_pressed'
../test.c:117: error: 'BUTTON_B' undeclared (first use in this function)
../test.c:117: error: (Each undeclared identifier is reported only once
../test.c:117: error: for each function it appears in.)
../test.c:119: warning: implicit declaration of function 'read_battery_millivolts'
../test.c:122: warning: implicit declaration of function 'print_long'
../test.c:123: warning: implicit declaration of function 'print'
../test.c:132: warning: implicit declaration of function 'wait_for_button_release'
../test.c:140: warning: implicit declaration of function 'set_motors'
../test.c:149: warning: implicit declaration of function 'calibrate_line_sensors'
../test.c:149: error: 'IR_EMITTERS_ON' undeclared (first use in this function)
../test.c:161: warning: implicit declaration of function 'read_line'
../test.c:183: warning: implicit declaration of function 'is_playing'
../test.c: In function 'main':
../test.c:203: error: 'IR_EMITTERS_ON' undeclared (first use in this function)
make: *** [test.o] Error 1
Build failed with 6 errors and 17 warnings...

billyzelsnack
02-27-2010, 02:12 PM
All/most of the errors are probably related to the first error..

error: pololu/3pi.h: No such file or directory

Make sure that the compiler can find that directory and that the file 3pi.h exists within it. The simplest quick fix is to put the absolute path directly into the #include. Once that is working you can take the directory out and put it into the compiler include path where it belongs.

grixxlee
02-28-2010, 12:13 PM
thank u so very much, that helped alot. I have it down to 1 error and 1 warrning now. Im not sure if i am missing a command code or what. Any suggestions?

c:\robot\lcd.h:31: warning: '__progmem__' attribute ignored - when clicked on goes to this line of code
void lcd_load_custom_character(const PROGMEM char *picture, unsigned char number);

c:\robot\OrangutanSerial.h:1:38: error: #include nested too deeply - when clicked on goes to this line of code
#include <c:\robot\OrangutanSerial.h>

The files are there were the path indicates, so am i missing a command or something simple. Please remember i am a noob to this and i do greatly appricate any and all help.
thanx
Grizzly

grixxlee
02-28-2010, 01:18 PM
I have it down to 1 error and 1 warrning now. Im not sure if i am missing a command code or what. Any suggestions?

c:\robot\lcd.h:31: warning: '__progmem__' attribute ignored - when clicked on goes to this line of code
void lcd_load_custom_character(const PROGMEM char *picture, unsigned char number);

c:\robot\OrangutanSerial.h:1:38: error: #include nested too deeply - when clicked on goes to this line of code
#include <c:\robot\OrangutanSerial.h>

The files are there were the path indicates, so am i missing a command or something simple. Please remember i am a noob to this and i do greatly appricate any and all help.
thanx
Grizzly

http://forums.trossenrobotics.com/ambience/misc/progress.gif

billyzelsnack
02-28-2010, 02:03 PM
I think you're going to need to post more for this one. My guess is that you have circular includes. One file including another file that eventual includes itself again. Do you have guards in your headers? Something like..

#ifndef MYFILE_H
#define MYFILE_H

//-- header stuff goes here

#endif

badcommandorfilename
02-28-2010, 04:52 PM
Actually, I can help with this:

warning: '__progmem__' attribute ignored occurs because you are passing an argument to a function which you have designated as type const char*, but which exists on the micro-controller's flash memory (not the ram).

I assume this is because "picture" is a BFO* array which lives in your flash memory until it's needed. However, the syntax you have used to in your declaration indicates that the pointer to the memory (ie, the const char *) lives in progmem.

The program is unable to copy values from flash directly to the stack without using a special latch register. What you need to do to fix it is to remove the PROGMEM from the declaration, and then reference your array directly using the & operator:

lcd_load_custom_character(&picture, sizeofpicture)

However, within the function you will now need to copy the array from flash memory to RAM. I don't know what compiler you are using, but avrlibc uses pgm_read_byte(char* byte). This needs to be done one byte at a time. Then you can operate on the copy of the array normally.

I actually wrote a short article (http://buildtherobot.blogspot.com/2010/01/byte-by-byte.html) about this ages ago.


*I'll tell you when you're older

DresnerRobotics
02-28-2010, 08:17 PM
Merged, these don't need to be separate threads. :)