Society of Robots - Robot Forum

Software => Software => Topic started by: Hawaii00000 on June 26, 2010, 04:37:28 PM

Title: AVR Studio 4: error
Post by: Hawaii00000 on June 26, 2010, 04:37:28 PM
I'm having some trouble with AVR Studio 4. I'm just working on getting my brand new Axon going but AVR Studio 4 quits when I create a new project an click "Finish." Is this because I moved the WinAVR files?
Title: Re: AVR Studio 4: error
Post by: dellagd on June 26, 2010, 07:18:14 PM
have you tried reinstalling AVR Studio 4?

It cant hurt
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 26, 2010, 08:05:12 PM
I got it now. You have to let the WinAVR install in the default place. Now to compile...
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 26, 2010, 09:03:42 PM
Its not compiling for me... here's the settings I have. Anyone know what went wrong?


(http://i487.photobucket.com/albums/rr231/Hawaii00000/toolbar.jpg)



















































Title: Re: AVR Studio 4: error
Post by: dellagd on June 27, 2010, 07:05:53 AM
Error messages?

Did you follow the 'getting started' section in Webbot lib EXACTLY?
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 27, 2010, 10:06:42 AM
Yeah I'm following the Axon "getting started" the best I can but getting plenty of errors.
Title: Re: AVR Studio 4: error
Post by: dellagd on June 27, 2010, 11:25:15 AM
What were the error messages?

Can you please post your code?
Title: Re: AVR Studio 4: error
Post by: Webbot on June 27, 2010, 06:39:32 PM
Also are you using Project Designer or just writing the code and configuring AVR Studio by hand?

Definitely need to see error messages and as 'dellagd' says a copy of your code would help track down your mistakes
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 27, 2010, 10:10:08 PM
It works with Webbot's sample "hello world," but not with the photovore code. Maybe I'm just copying the wrong code.
Title: Re: AVR Studio 4: error
Post by: Webbot on June 28, 2010, 06:17:11 AM
I recently fixed a problem in the photovore code - which came about as one of the included files hand changed name.
Check your code against the latest in the online docs at http://webbot.org.uk/WebbotLibDocs/object.jsp?id=27787 (http://webbot.org.uk/WebbotLibDocs/object.jsp?id=27787)
Title: Re: AVR Studio 4: error
Post by: dellagd on June 28, 2010, 06:21:38 AM
using Admin's photovore code will not work because it is not adapted to webbot lib.
programming with webbot lib uses a different format.

(You must use Webbot's photovore code)
Title: Re: AVR Studio 4: error
Post by: Webbot on June 28, 2010, 06:58:12 AM
My previous post makes the assumption that you are using the Photovore code that comes in the WebbotLib manual
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 28, 2010, 09:32:40 AM
I'm using the code in the Axon "getting started" tutorial which is all set up with WebbotLib so it should be the right code.
Title: Re: AVR Studio 4: error
Post by: Webbot on June 28, 2010, 11:38:54 AM
I'm still not sure if you mean the one on the Society Of Robots website written by Admin - or the one in the WebbotLib documentation (ie the PDF or on my website at http://webbot.org.uk/WebbotLibDocs/object.jsp?id=27787 (http://webbot.org.uk/WebbotLibDocs/object.jsp?id=27787))

If its Admins code then I cant help you - and vice versa. So please clarify.

Also - unless you say exactly what error messages you are getting then its hard for anyone to help you.
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 28, 2010, 03:58:39 PM
Admin converted his Axon "getting started" tutorial to webbotlib. Here's the link: http://www.societyofrobots.com/axon2/axon2_setup1.shtml (http://www.societyofrobots.com/axon2/axon2_setup1.shtml)
I can try and check the code today.
Title: Re: AVR Studio 4: error
Post by: Webbot on June 28, 2010, 04:50:29 PM
Phew - after all these posts we finally get to know where your source code comes from.

Now all we need to know is what error you are getting - which I think we've asked for 3 times already so far. This is request number 4.
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 28, 2010, 07:36:56 PM
Sorry webbot
Here the code (different form the coding your earlier link):
Code: [Select]
/*************************************************************************
AXON AND AXON II CODE FOR WEBBOTLIB

Authored by John Palmisano of SocietyofRobots.com
in collaboration with Clive Webster of WebbotLib.

For more information, see:
http://www.societyofrobots.com/axon
http://www.societyofrobots.com/axon2
http://sourceforge.net/projects/webbotavrclib

2009

intended use for Axon and Axon II

instructions:
Read comments for explanation of all code.

appInitHardware() is for initiating the Axon.

appControl() is where your code goes. It is similar to control.c
for the original Axon code.

See hardware.h for defining your external hardware.
See sys/axon2.h in WebbotLib to change which pins are input and output.
*************************************************************************/


//allows for printing with features, but uses more memory
#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

//additional math capabilities
//#include <math.h>

//WebbotLib includes
//#include "sys/axon.h" //use for original Axon
#include "sys/axon2.h" //defines your MCU (change to axon.h if you use the original Axon)
#include "servos.h" //use for servos
#include "a2d.h" //use for ADC
#include "rprintf.h" //use for UART
#include "i2c_master.h" //use for I2C
//#include "buffer.h" //use for GPS and other serial stuff

//user includes
#include "hardware.h"


// In my initialising code - pass the list of servos to control
void appInitHardware(void)
{
//initialize UART ports (see hardware.h to change baud/names)
uartInit(GPS_UART, GPS_BAUD); //UART0
uartInit(USB_UART, USB_BAUD); //USB
uartInit(WIRELESS_UART, WIRELESS_BAUD); //UART2
uartInit(OTHER_UART, OTHER_BAUD); //UART3

// declare USB for output
rprintfInit(USB_ACTIVATE);

// Initialise the servo controller
servoPWMInit(&bank1); //use PWM to control servos (must use PWM pins!)
//servosInit(&bank1, TIMER1); //use software PWM to control servos (can use any pin)

// Initiate Sensors (examples commented out)
//accelerometerInit(accm3d2);
//compassInit(hmc6343);
//gyroInit(idg300);

}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
rprintf("\nAxon Initiated.\n\n");
return 0;
}


//the larger this number, the more likely your robot will drive straight
#define threshold 8

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{

servosDisconnect(&bank1);//turn servos off

delay_ms(100);//button debounce delay

rprintf("\nPush Button to Start\n");

while(!button_pressed());//wait for button to be pressed

servosConnect(&bank1);//turn servos on

delay_ms(100);//button debounce delay

while(!button_pressed())//exit code if button is pushed
{
update_sensors();

if(lightLeft > lightRight && (lightLeft - lightRight) > threshold)
{
// go left
act_setSpeed(&left_wheel,DRIVE_SPEED_MIN);
act_setSpeed(&right_wheel,DRIVE_SPEED_MAX);

led_put_char(1);
}

else if(lightRight > lightLeft && (lightRight - lightLeft) > threshold)
{
// go right
act_setSpeed(&left_wheel,DRIVE_SPEED_MAX);
act_setSpeed(&right_wheel,DRIVE_SPEED_MIN);

led_put_char(3);
}

else
{
// Go forwards
act_setSpeed(&left_wheel,DRIVE_SPEED_MAX);
act_setSpeed(&right_wheel,DRIVE_SPEED_MAX);

led_put_char(2);
}

//print out detected difference
rprintf("Sensor Difference: %d\n", lightLeft - lightRight);

delay_ms(30);//slow control loop down to prevent crazy robot oscillation
}

return 20000; // wait for 20ms to stop crazy oscillations (long story)
}

and here's the errors:
(http://i487.photobucket.com/albums/rr231/Hawaii00000/errors.jpg)
Title: Re: AVR Studio 4: error
Post by: Webbot on June 28, 2010, 07:51:29 PM
Your errors are caused by the first one ie that it cannot find 'hardware.h'

I think you've failed to add hardware.h as described in Step 6 of http://www.societyofrobots.com/axon2/axon2_setup1.shtml (http://www.societyofrobots.com/axon2/axon2_setup1.shtml)
Title: Re: AVR Studio 4: error
Post by: dellagd on June 29, 2010, 06:37:38 AM
if you have it, make sure it is in the same folder as the rest of your code (the .c file, excluding the webbot-lib stuff).
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 29, 2010, 09:06:09 PM
I did this-
Quote
Now, right click 'Header Files' and left click 'Add Existing Source File(s)...'. Add hardware.h from the photovore example folder.
I think that's what you mean.

if you have it, make sure it is in the same folder as the rest of your code (the .c file, excluding the webbot-lib stuff).


So have to save the whole thing in the same folder as the hardware.h? 
Title: Re: AVR Studio 4: error
Post by: dellagd on June 30, 2010, 06:21:04 AM
not webbot lib, but all the unique code (not from webbot lib) must be contained in the same folder with the AVRstudio file as well.
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 30, 2010, 11:15:38 AM
Problem solved! :D Thanks for the help Webbot and dellagd. I appreciate you time.
Title: Re: AVR Studio 4: error
Post by: dellagd on June 30, 2010, 04:44:48 PM
did what I said solve it? just for others it would be nice to say what fixed it.
Title: Re: AVR Studio 4: error
Post by: Hawaii00000 on June 30, 2010, 04:54:01 PM
did what I said solve it? just for others it would be nice to say what fixed it.

Yes, putting the hardware.h in the same folder as the rest of the files solved it.