xmega start project general

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
i have to make a project for a lesson to my university with the xmega128a1 and a (low g), 3-Axis Analog Output Acceleration Sensor.
I use stk600 as development board and avrstudio 4.18sp3 and winavr 2100110. So i have to make gcc code and i want to connect the sensor which will send 3 analog signals to the avr.Then the avr i want to send them to my pc,maybe in the form of a document file (.txt)containing the various values.
I don't know where to start writing my code..

Is any one who could help me with that?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start here:

int main()
{
while(1);
}

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
Start here:

int main()
{
while(1);
}

:D :D

i don't mean so start.. i mean which peripherials i should use (adc,usart,i/o etc) which registers i have to care about..something like these..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use i/o and take care about R16.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
Use i/o and take care about R16.

if you really want to help give me extented information
thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

$9995. Idiot's discount already applied.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start with an 'algorithm'. This is a description of the code that can be written into any language. I use the Warnier-Orr method because it is less cluttered and more straightforward than the common IBM_symbol_flowchart method.

Code does three things:
1) it executes instructions (or functions) one right after another from the beginning to the end.
2) it loops through a sequence of identical instructions for a specific number of times.
3) it chooses between two paths of instruction depending upon an external condition that the processor will use to determine the correct path.

IBM flowcharts use rectangles, diamonds, and circle shapes that are connected by lines for the three alternatives. Warnier-Orr uses braces and page positioning for the same expression. It starts broadly on the left side of the page and goes into increasing detail towards the right side.

Either way, map your program in detail and 'walk through' it multiple times assuming a wide range of possible input values. Write lightly in pencil so that you can erase large sections of algorithm design and rewrite improvements in the same paper space. This stage of the program development is supposed to be messy.

The time that you 'waste' doing an algorithm is almost always regained in the amount of debugging that you DON'T have to do were you to simply begin the program by writing code. This strategy is taught in all programming schools and is (eventually) adopted by all programmers writing non-trivial applications in any language.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
$9995. Idiot's discount already applied.

what did you mean???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have to use an XMega?
There are some issues regarding its ADC, and there are far more examples out there for the Mega and Tiny series, both of which could be used for this project.

That said, what have you done with the XMega thus far?
You need to start with the basics: Flash an led.

Next you need to set up the USART for serial communications with the PC. The XMega's USART connects to the Max232, (or equivalent chip), which then sends RS-232 to a PC. I don't recall if the STK600 has a USB port for the User to use, or just for programming. You can read what the uC sends to the PC using a terminal program on the PC, (Hyperterminal, etc.).

You need to connect a pot, (variable resistor), to the XMega's ADC input and study the data sheet closely to learn how to read an analog input voltage, (0-3V), convert the ADC reading to a voltage, and either display it on an LCD, or send it to the PC to display.

Then you need to connect the Accelerometer(s) to the ADC inputs, read them, and send the data to the PC.

Lots of steps to take on one at a time, then put it all together. Taken one step at a time the project will be much easier.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

giwrgos wrote:
what did you mean???
I mean you've already got your $5 off :D

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
Start with an 'algorithm'. This is a description of the code that can be written into any language. I use the Warnier-Orr method because it is less cluttered and more straightforward than the common IBM_symbol_flowchart method.

Code does three things:
1) it executes instructions (or functions) one right after another from the beginning to the end.
2) it loops through a sequence of identical instructions for a specific number of times.
3) it chooses between two paths of instruction depending upon an external condition that the processor will use to determine the correct path.

IBM flowcharts use rectangles, diamonds, and circle shapes that are connected by lines for the three alternatives. Warnier-Orr uses braces and page positioning for the same expression. It starts broadly on the left side of the page and goes into increasing detail towards the right side.

Either way, map your program in detail and 'walk through' it multiple times assuming a wide range of possible input values. Write lightly in pencil so that you can erase large sections of algorithm design and rewrite improvements in the same paper space. This stage of the program development is supposed to be messy.

The time that you 'waste' doing an algorithm is almost always regained in the amount of debugging that you DON'T have to do were you to simply begin the program by writing code. This strategy is taught in all programming schools and is (eventually) adopted by all programmers writing non-trivial applications in any language.

thanks for your time, these advices may help me to do my project easier - better..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Do you have to use an XMega?
There are some issues regarding its ADC, and there are far more examples out there for the Mega and Tiny series, both of which could be used for this project.

That said, what have you done with the XMega thus far?
You need to start with the basics: Flash an led.

Next you need to set up the USART for serial communications with the PC. The XMega's USART connects to the Max232, (or equivalent chip), which then sends RS-232 to a PC. I don't recall if the STK600 has a USB port for the User to use, or just for programming. You can read what the uC sends to the PC using a terminal program on the PC, (Hyperterminal, etc.).

You need to connect a pot, (variable resistor), to the XMega's ADC input and study the data sheet closely to learn how to read an analog input voltage, (0-3V), convert the ADC reading to a voltage, and either display it on an LCD, or send it to the PC to display.

Then you need to connect the Accelerometer(s) to the ADC inputs, read them, and send the data to the PC.

Lots of steps to take on one at a time, then put it all together. Taken one step at a time the project will be much easier.

JC

Yes i have to use xmega and not tiny or mega..
i allready flash leds and setup io(i know how to write a code on winavr about ports and see the out to the leds) i also have use and usart but with codevision not with winavr..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use atmel AVR1300 sample codes as a starting point.

Ozhan KD
Knowledge is POWER

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

electronic.designer wrote:
Use atmel AVR1300 sample codes as a starting point.

it doesn't help me more i think that the information to create from the begining a function about adc_setup the " xmega a manual "(chapter 25 - adc) has anything i want -and maybe more and difficult things but that is also and my big problem, about that manual..- so if anyone knew what exactly i have to read about the xmega,i will be glad if he will notice them to me..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

XMEGA part of the AVR Software Framework:
http://asf.atmel.no/xmega/readme.html
Use the ADC driver with the board file for STK600.
ADC example two (offset and gain calibration) could be used as a start for your application.
I'd recommend an XPLAIN so you could work on most of this project at your residence unless you're on-campus.
Sensor board could be designed to connect to either XPLAIN or STK600.

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
XMEGA part of the AVR Software Framework:
http://asf.atmel.no/xmega/readme.html
Use the ADC driver with the board file for STK600.
ADC example two (offset and gain calibration) could be used as a start for your application.
I'd recommend an XPLAIN so you could work on most of this project at your residence unless you're on-campus.
Sensor board could be designed to connect to either XPLAIN or STK600.

Can i use codes for stk600 from here?or these are only for xplain? http://asf.atmel.no/xmega/driver...

the hardware is from the university so i can't buy something more...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

giwrgos wrote:
Can i use codes for stk600 from here?or these are only for xplain? http://asf.atmel.no/xmega/driver...

the hardware is from the university so i can't buy something more...

ASF can be used for Xplain or STK600. w.r.t. ADC driver, another forum member did not like its quality so you may have to improve it.

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
giwrgos wrote:
Can i use codes for stk600 from here?or these are only for xplain? http://asf.atmel.no/xmega/driver...

the hardware is from the university so i can't buy something more...

ASF can be used for Xplain or STK600. w.r.t. ADC driver, another forum member did not like its quality so you may have to improve it.

There are many many codes if i try to use ADC example two (offset and gain calibration) i have to make and the extra *.h files right?

some of them:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

and then i should put them in the folder of my project?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

but and for the *.h i have to create for each one at list an other *.h... am i right?isn't it too difficult through that way to setup the adc? about adc i thought that the only thing that i have to do is just to creat a function with the corect register's setup.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You decided to go with the ASF instead of the application note. Now live with it.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ArnoldB wrote:
You decided to go with the ASF instead of the application note. Now live with it.

i didn't decide to go with ASF i just been intrested to that way.. so you think that isn't an easy way?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can your professor require a state of the art MCU, dev. brd. for this assignment and yet you have no idea how to start ? You must have taken other MCU classes before now ( or the prof. has high expectations for a 1st course!! ) ?

Quote:
i mean which peripherials i should use
Well, which ones do YOU think should be used and why ?
Tell us, with the engr. education you have now, what do you think are the key steps to getting this done ? THis is a very important skill to have. Have you asked your prof. for any ideas ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

indianajones11 wrote:
How can your professor require a state of the art MCU, dev. brd. for this assignment and yet you have no idea how to start ? You must have taken other MCU classes before now ( or the prof. has high expectations for a 1st course!! ) ?
Quote:
i mean which peripherials i should use
Well, which ones do YOU think should be used and why ?
Tell us, with the engr. education you have now, what do you think are the key steps to getting this done ? THis is a very important skill to have. Have you asked your prof. for any ideas ?

My prof. uses codevision but for xmega we have only codevision 2.04.8a evaluation version and he had learned to me from there only io and usart by the wizard...very simple.. then he noticed that codevision isn't good because is the evaluation version so it don't be flexible..winavr is the only way.. but there you have to make code from blank.. and he said that i should find the way by my self..alone..without his help..

I don't if to use the last version (winavr20100110) is the best version for my avr (xmega128a1)..

my code i think that will be like this:

 #include 
#include 
#include 
#include 
....

#define F_CPU 2000000UL

//a funcτion about io

porta.dir=0xFF
portb.dir=0x00
......
 
//then a funcτion for the adc like this:

void adc_init(void ){ 
   ADC_CalibrationValues_Load(&ADCA); 
   ADCA.CH0.CTRL = 0x01 ; //single ended 
   ADCA.CH0.MUXCTRL = 10<<ADC_CH_MUXPOS_bp;  //input 10 
   ADCA.PRESCALER = 0x2;    // /16 
   ADCA.REFCTRL = 0x12;         //VCC/1.6, bangap ON 
   ADCA.EVCTRL = 0; 
   ADCA.INTFLAGS = 0x0F;   //clear intflags 
   ADCA.CTRLA = 0x01;    //enable ADC 
   ADCA.CTRLA = 0x05;    //start conv. 
} 
int getAD10(){ 
  int rslt; 
  while(!ADC_Ch_Conversion_Complete(&ADCA.CH0)); 
  rslt = ADC_ResultCh_GetWord(&ADCA.CH0); 
  ADCA.CTRLA = 0x05;    //start conv. 
  return rslt; 

//then a funcτion for the usart
void usart_init(void ){ 

??????

}

int main (void) 
{ 

while (1) 
{ 
the program for reading-convert and send with a text the information from the accelerometer. 
} 
}

these 2 below are that what i am looking for?
http://www.avrfreaks.net/index.p...
http://www.bostonandroid.com/exa...

may i want something more?(i think yes but i don't know what....)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

giwrgos wrote:
he said that i should find the way by my self..alone..without his help
That's cold !! You got a messed up prof. !! What's the part # for the 3-axis sensor ?

1) I suggest you get the USART fired up 1st. That way you can debug the ADC() ( especially since U need to look at THREE channels )and anything else to your PC. So look for that app on Atmel site ( i don't know the xmega UART ). Don't ding-aling around w/ hyperterminal; Bray's terminal is good.

2) THEN work the ADC() code. Use a pot. to simulate the sensor and change the wiper wire to each of the 3 planned channels.You need to find out if you can connect the sensor to the xmega w/o an I/F circuit or not. http://blog.frankvh.com/category...

3) If codevision wizard can get you some base uart() and ADC() code, do it and port it !
These are only suggestions.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
and then i should put them in the folder of my project?
There is a tutorial on managing large C pjts. that will help you alot.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hai
I am trying to interface the sensor (3-axis accelerometer)with stk600-atmega128rfa1.
but before this i tried to get the voltage reading from p0tentiometer through adc.
can i have step by step procedure

[warning folks - this is a cross post - search for other posts by this person to see what I mean. If you want to reply do so in the separate thread that exists here: http://www.avrfreaks.net/index.p... ]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
giwrgos wrote:
what did you mean???
I mean you've already got your $5 off :D

In case you haven't figured it out MBedder is the 'Don Rickles' of this forum. He is in charge of weeding out dumb questions. He also comes cheap compared to Dr. Black Jack.