go_away

Author Topic: $50 robot upgrade microcontroller to ATMega328P  (Read 755 times)

0 Members and 1 Guest are viewing this topic.

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
$50 robot upgrade microcontroller to ATMega328P
« on: July 16, 2012, 04:32:21 AM »
After finishing up the $50 robot, I wanted to go through the the upgrades in mentioned in the tutorial.

First one that made sense to me is the upgraded micro controller, since I would rather do that before any of the others.

Instead of buying the ATmega168, I bought the ATmega328P since I was making an order from spark fun for the UART parts and they only had the 328P and not the 168.

So I got my parts yesterday and I am following Admin's tutorial.

I create a new project and copy all of the photovore_v1 files over, in this new project I specify the 328P.

I modify the makefile for this micrcontroller, I also modify the makefile to use timerx8 instead of timer

The last part of the tutorial mentions:

"The global.h file should also be modified since it contains a F_CPU define, depending on if you use the makefile to overwrite that value or not."

So I open up the global.h file and here is the code for the F_CPU files:

// CPU clock speed
//#define F_CPU        16000000                     // 16MHz processor
//#define F_CPU        14745000                     // 14.745MHz processor
//#define F_CPU        8000000                     // 8MHz processor
//#define F_CPU        7372800                     // 7.37MHz processor
//#define F_CPU        4000000                     // 4MHz processor
#define F_CPU        3686400                     // 3.69MHz processor
#define CYCLES_PER_US ((F_CPU+500000)/1000000)    // cpu cycles per microsecond

I was a bit surprised by this because I thought the ATmega8 was a 16MHz processor, so I would have expected that one to be uncommented, not the 3.69MHz processor line.

So I did not do anything with this and decided to rebuild all and program.

I rebuilt all and it wet fine, I did have a warning about a SIG_ADC but it still worked.

I then program and it programs successfully.

Once programmed the LED light is turning on, but nothing is happening at all with the servos.

This was working perfecty with the ATMega8, and I verified by swapping the chips again.

I went through all the code and searched the forums, I am now stuck.

Anyone have any ideas here on what I need to do? Is this the F_CPU code, or something else maybe? Maybe the SIG_ADC warning?

When I looked up the SIG_ADC warning I found a post by Admin that said to try to include signal.h, I did that in my SOR_utils.h file, and it would not build because I do not have the signal.h file.

Any ideas where I can get it, or how to build it?

Any help would be appreciated.

Thx.
« Last Edit: July 16, 2012, 04:40:56 AM by ErikY »

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: $50 robot upgrade microcontroller to ATMega328P
« Reply #1 on: July 16, 2012, 01:37:01 PM »
You could use WebbotLib
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: $50 robot upgrade microcontroller to ATMega328P
« Reply #2 on: July 16, 2012, 02:21:00 PM »
You could use WebbotLib

Webbot, thanks. I am going to check out the library right now.

I had been trying to hold off as I wanted to learn to do things more myself before leaning on your library, but I am just struggling too much with this stuff.

Thx, it looks really amazing. I will be sure to donate should I use it.

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: $50 robot upgrade microcontroller to ATMega328P
« Reply #3 on: July 17, 2012, 03:54:01 AM »
Webbot, I actually was able to figure out the problem and I have my code working now with the 328P.

I still plan to use your library, but I am going to hold off a little bit longer until I can do a bit more on my own, I am stubborn.

If anyone else stumbles upon this, or if Admin wants to include it in the tutorial, I don't think the 328P will work with the code as is from the Atmega8, as the ADC interrupt has a different name. If anyone is interested, let me know and I will post the code change required.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: $50 robot upgrade microcontroller to ATMega328P
« Reply #4 on: July 18, 2012, 06:29:03 PM »
That's fine - glad you sorted out your problem.

Main reason for suggesting WebbotLib is that it is actively supported.

Admin is a guru of everything 'non-software' and so doesn't really have the time to support his old libraries. In fact he tends to use WebbotLib now rather than his own libraries.

So bear in mind that you are working with something deprecated. So whilst it works for you then great - but when it doesn't then you're kinda on your own - but then 'hey' you
Quote
want to be stubborn
.

Of course the cheesy response is: if you want to be stubborn and do it yourself then why are you using any library !?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: $50 robot upgrade microcontroller to ATMega328P
« Reply #5 on: July 18, 2012, 07:42:09 PM »
That's fine - glad you sorted out your problem.

Main reason for suggesting WebbotLib is that it is actively supported.

Admin is a guru of everything 'non-software' and so doesn't really have the time to support his old libraries. In fact he tends to use WebbotLib now rather than his own libraries.

So bear in mind that you are working with something deprecated. So whilst it works for you then great - but when it doesn't then you're kinda on your own - but then 'hey' you
Quote
want to be stubborn
.

Of course the cheesy response is: if you want to be stubborn and do it yourself then why are you using any library !?

All very valid points.

I am kind of struggling through a few things right now, mostly converting code that works on the ATmega8 to the ATmega328P.

In order to get things working, I am forced to learn about vectors, and things like that.

So, while your right, I am not starting from scratch, I am being forced to work through some things that are giving me an education.

I definitely understand and appreciate what you have put together, and honestly, I cannot wait to get started with it because I want to start really building things.

I just want to learn a bit more on my own, or at least somewhat on my own first.

 


Get Your Ad Here

data_list