go_away

Author Topic: ATmega644 (moved from misc)  (Read 4677 times)

0 Members and 1 Guest are viewing this topic.

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
ATmega644 (moved from misc)
« on: May 14, 2007, 05:47:04 PM »
Hehe, I think this would be better instead of hijacking the other thread in the Misc category..

wow this topic got way off . . . ummm . . . topic . . .

Quote
So my next project in mind is to create a simple microcontroller thingy with a ATmega644. I'm basing it off Admin's $50 robot, and some other tutorials I've seen online. If all goes well, I'll have something that will let me control servos and I/O from sensors relatively cheaply.
hey! so im programming at ATmega644 now actually! we should collaborate somehow . . . the $50 robot is actually based off of what I learned with the 644 :P
but i plan to have some really advanced/expensive features on it so its not the kind of thing beginners should ever attempt . . .

Hmm, what kind of stuff are you doing with the 644? I'm currently drawing a schematic that'll let me use it as a simple microcontroller with a separate power for servos. My idea is to come up with something like an Arduino, but with special PWM ports for servos (which will have the 3 socket thing for the servos and handle the separate power source), and other I/O ports for sensors..

So far (when I said I'm currently drawing the schematic, I meant it literally :P), I've gotten to this stage:
(Edit: removed old schematic)

I'll be adding in the rest of it later tonight probably.. I'm not an ECE major though, and I didn't take any ECE courses :-[ but I'll be asking my ECE friend to look through it once it's done and all. He's been very helpful so far with reading through the datasheets and explaining stuff to me ;D
« Last Edit: May 15, 2007, 05:05:09 PM by Somchaya »
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: ATmega644 (moved from misc)
« Reply #1 on: May 14, 2007, 06:02:21 PM »
Quote
what kind of stuff are you doing with the 644?
a lot:
wireless underwater uart data transmission
in-vitro reprogramming (bootloading)
3 axis accelerometer
current draw sensor
pressure sensor
2 axis gyro
digital compass
control of 21+ independent servos
and a blinky LED :P

Ive got about half of it working . . . probably the most advanced circuit and program Ive done for robotics yet . . .

Quote
I'm not an ECE major though, and I didn't take any ECE courses
You really should take a few ece classes. I took several as electives - very useful stuff! You should probably take intro to meche, too :P

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: ATmega644 (moved from misc)
« Reply #2 on: May 14, 2007, 06:57:25 PM »
a lot:
wireless underwater uart data transmission
in-vitro reprogramming (bootloading)
3 axis accelerometer
current draw sensor
pressure sensor
2 axis gyro
digital compass
control of 21+ independent servos
and a blinky LED :P

Ive got about half of it working . . . probably the most advanced circuit and program Ive done for robotics yet . . .
Oh wow! That's a lot :P I'm just intending to do some servo controlling and sonar + zigbee probably.

You really should take a few ece classes. I took several as electives - very useful stuff! You should probably take intro to meche, too :P
Hehe, I just graduated so it's not possible any more.. I kind of wanted to take ece and mech e courses, but somehow I could never find the time to fit them in..

Back to drawing the schematic!
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: ATmega644 (moved from misc)
« Reply #3 on: May 14, 2007, 07:09:31 PM »
Quote
Oh wow! That's a lot  I'm just intending to do some servo controlling and sonar + zigbee probably.
yea ive been working on it for like 6 months now . . . im using the easyradio . . . i chose it because lower the frequency means better underwater range . . . but i think our projects are really close . . .

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: ATmega644 (moved from misc)
« Reply #4 on: May 14, 2007, 07:53:25 PM »
Hmm.. sounds like it.. I'd really like to have a look at the circuit diagram you have ;D

I'm trying to figure out which pins support PWM.. I can't figure it out from the datasheet :P All I know is that there are 6 channels that do PWM, but not which 6 ???

I'm also working on a serial port to communicate with a PC. A couple of questions about it:
1. Is it just a matter of connecting the RX and TX to an 7404N inverter, then to a serial connector?
2. Do I need to worry about the voltage levels coming from the PC?
3. How will the software to read/write to the serial port be like?
« Last Edit: May 14, 2007, 08:14:56 PM by Somchaya »
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: ATmega644 (moved from misc)
« Reply #5 on: May 15, 2007, 02:32:47 AM »
Quote
1. Is it just a matter of connecting the RX and TX to an 7404N inverter, then to a serial connector?
2. Do I need to worry about the voltage levels coming from the PC?
use a MAX232 to solve both of these. it's a buffer chip designed for interfacing TTL UART voltages to RS232 voltages.
(there are a few other chips around that do the same thing but the MAX232 is the most common.)
Quote
3. How will the software to read/write to the serial port be like?
start off using hyperterminal at the PC end. (windows terminal software.)

dunk.

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: ATmega644 (moved from misc)
« Reply #6 on: May 15, 2007, 05:48:31 AM »
I'm trying to figure out which pins support PWM.. I can't figure it out from the datasheet :P All I know is that there are 6 channels that do PWM, but not which 6 ???

Here's your six PWM pins:

OC0A, OC0B
OC1A, OC1B
OC2A, OC2B

- Jon

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: ATmega644 (moved from misc)
« Reply #7 on: May 15, 2007, 05:09:41 PM »
Ok! I've come up with a schematic, which I hope will work.. ;D

http://somchaya.intuios.com/temp/schematic.png

Click the link above for the large, full-scale version:


Right now, besides the burning question: "will this work?" I have a minor problem.. For the capacitors I use, does the voltage rating matter?
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: ATmega644 (moved from misc)
« Reply #8 on: May 15, 2007, 06:15:12 PM »
You may find this helpful:
http://www.societyofrobots.com/robotforum/index.php?topic=606.0

(this was a question I had when I was wiring up my 644)

Quote
For the capacitors I use, does the voltage rating matter?

Yes. If unsure, just make sure the voltage rating is 2x the voltage expected.

Quote
"will this work?"

Without double checking every pin . . . here are my quick thoughts . . .

Put the .33uF cap on the out pin of the 5V regulator, otherwise it will just burn out the regulator faster when the cap is drained.

And Im guessing thats a 6V regulator on the 7.2V battery to power servos? BAD! It will overheat and stop working. Use a switching regulator, or a 6V battery. Expect each servo to drain ~.5A.

I am assuming that '20 Mhz' has a crystal and capacitors?

Lastely, on/off switches near your batteries is a must, and maybe a fuse too if you expect to drain high currents.

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: ATmega644 (moved from misc)
« Reply #9 on: May 15, 2007, 07:54:16 PM »
You may find this helpful:
http://www.societyofrobots.com/robotforum/index.php?topic=606.0

(this was a question I had when I was wiring up my 644)

Hmm.. I don't really understand that part, but I'll ask my ece friend to parse through it and explain it to me ;D

Quote
Put the .33uF cap on the out pin of the 5V regulator, otherwise it will just burn out the regulator faster when the cap is drained.

Hmm, do you mean switch the 0.33uF and 0.1uF caps, or add an additional .33uF to the out pin of the regulator?

Quote
And Im guessing thats a 6V regulator on the 7.2V battery to power servos? BAD! It will overheat and stop working. Use a switching regulator, or a 6V battery. Expect each servo to drain ~.5A.

Oh, the reason why I wanted to do this was because Whisk had issues with voltage dropping after running for a while. Will attaching a heat sink be sufficient? I was intending to put a heat sink on each of the voltage regulators.

Quote
I am assuming that '20 Mhz' has a crystal and capacitors?

Hmm, so the datasheet said the crystal was "series" and didn't have a capacitor listed, so I'm assuming it doesn't need one? Some other crystals by the same manufacturer had capacitances listed, but this one and a couple others didn't.. Here's the datasheet: http://www.ctscorp.com/components/Datasheets/008-0309-0_C.pdf

Quote
Lastely, on/off switches near your batteries is a must, and maybe a fuse too if you expect to drain high currents.

Yeap I was intending to have switches for the batteries. What amperage should I put a fuse at? Slightly higher than the max rating of the regulator, or double?
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: ATmega644 (moved from misc)
« Reply #10 on: May 15, 2007, 08:10:56 PM »
Quote
Hmm, do you mean switch the 0.33uF and 0.1uF caps, or add an additional .33uF to the out pin of the regulator?

the .33uF cap should be connected to the regulator output, not input pin.

Quote
Oh, the reason why I wanted to do this was because Whisk had issues with voltage dropping after running for a while. Will attaching a heat sink be sufficient? I was intending to put a heat sink on each of the voltage regulators.

a regulator will make it worse . . . regulators are very inefficient and will just waste energy. servo power doesnt need to be regulated anyway as long as you keep it below 6V. it sounds like the problem you were having is just your battery going low. what mAh was it rated at? try getting 2500mAh NiMH, that will last you a long while.

Quote
Hmm, so the datasheet said the crystal was "series" and didn't have a capacitor listed, so I'm assuming it doesn't need one? Some other crystals by the same manufacturer had capacitances listed, but this one and a couple others didn't.. Here's the datasheet: http://www.ctscorp.com/components/Datasheets/008-0309-0_C.pdf

unless you plan on doing heavily computational algorithms (such as vision or trig), i wouldnt bother with the crystal . . . ive never used or needed one. crystals will need capacitors, unless they come built in to the package.

Quote
Yeap I was intending to have switches for the batteries. What amperage should I put a fuse at? Slightly higher than the max rating of the regulator, or double?

way ahead of you:
http://www.societyofrobots.com/electronics_fuse_tutorial.shtml

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: ATmega644 (moved from misc)
« Reply #11 on: May 16, 2007, 02:32:13 AM »
Quote
Hmm, so the datasheet said the crystal was "series" and didn't have a capacitor listed, so I'm assuming it doesn't need one?

read section 7 of this pdf:
http://www.atmel-grenoble.com/dyn/resources/prod_documents/doc2593.pdf
section 7.2, 7.3 and 7.4 explain attaching capacitors with the crystal.

Admin has a point though, for lower speed projects it is often practical to use the internal RC oscillator. (it's built in to the AVR so you don't need an external Cristal.)

as for the regulator for the servos, in this project: http://www.societyofrobots.com/member_tutorials/node/25 i went with a switching regulator for the reasons Admin is talking about.
switching regulators are not nearly as inefficient but a little more complicated to set up (needing an inductor and more capacitors).
the switching regulator is the at bottom right of this diagram:
http://www.societyofrobots.com/member_tutorials/files/USB_servo.png

appart from these few things your circuit looks good. i see no reason why it wouldn't work.

dunk.

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: ATmega644 (moved from misc)
« Reply #12 on: May 18, 2007, 01:32:12 AM »
Okie, I've updated the schematic (http://somchaya.intuios.com/temp/schematic_2.png):

  • I removed the regulator for the 7.2V battery and changed it to a 6V battery. I suppose I can add in a regulator if/when the need arises.
  • I added a switch and fuse for each of the battery sources. The fuse ratings are just semi-random numbers for now, I haven't actually figured out what to put for each yet.
  • I added a 0.1 uF capacitor from AVcc to ground, and Aref to ground.
  • And I switched the 0.1 uF and 0.33 uF capacitors for the 5V regulator. I'm a little unclear about this part though. In the datasheet (http://www.st.com/stonline/products/literature/ds/2143/l7805c.pdf page 4 Figure 3), it shows the application circuit with 0.1 uF connected to the output pin, and 0.33 uF connected to the input pin.

Regarding the crystal:

For now, I left the 20 MHz crystal connected. If I don't use a crystal, do I just leave the pins unconnected, or do I short them? Regarding the capacitors for the crystal, it seems that a series crystal doesn't need external capacitors (http://www.foxonline.com/techdata.htm search for "Figure 3.0"), is that right?

So I was wondering, why not just add a crystal to make the IC go faster? ;D The internal clock goes at 8 MHz but a crystal can push it to 20 MHz, and extra speed for the cost of a crystal is worth it right? Power consumption goes up, but it shouldn't make too much of a difference right?

Regarding the regulator for servos power:

The trouble I had with Whisk was that a fully charged battery would give >6V (I think), which caused the speed to be slightly higher than when it settled to 6V or so after 1-2 runs. Since I used an open-loop timer, the changes in speed weren't a good thing ;D In this case, I probably won't be doing that so having a regulated voltage might not be important.

Also, I was looking at the switching regulators, and it seems that 5V is the closest I can get. 6V switching regulators don't seem to exist somehow.. Any ideas why?
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: ATmega644 (moved from misc)
« Reply #13 on: May 18, 2007, 03:37:40 AM »
Quote
For now, I left the 20 MHz crystal connected. If I don't use a crystal, do I just leave the pins unconnected, or do I short them? Regarding the capacitors for the crystal, it seems that a series crystal doesn't need external capacitors (http://www.foxonline.com/techdata.htm search for "Figure 3.0"), is that right?

it's possible you don't need the timing capacitors but i think it's unlikely.
i generally build to the microcontroller's datasheet specifications whenever possible and it tells you they are required.

it's still possible to use the internal regulator with a crystal attached. just enable/disable the relevant fuse bits.

Quote
So I was wondering, why not just add a crystal to make the IC go faster? Grin The internal clock goes at 8 MHz but a crystal can push it to 20 MHz, and extra speed for the cost of a crystal is worth it right? Power consumption goes up, but it shouldn't make too much of a difference right?

yea. there will be very little change in power draw.

Quote
Also, I was looking at the switching regulators, and it seems that 5V is the closest I can get. 6V switching regulators don't seem to exist somehow.. Any ideas why?

so 5V is a common regulator because so many ttl voltage components use 5V.
you can get variable voltage regulators that you set the voltage with a capacitor or resistor. one of these is probably your best bet.

dunk.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: ATmega644 (moved from misc)
« Reply #14 on: May 18, 2007, 07:23:25 AM »
Put a capacitor across your 6V battery, .33uF rated for 12V+ would work, but higher capacitance the better.

You probably wont need a fuse for the 9V battery. But if you do, 1A is way too high. A 9V couldnt (correct me if Im wrong) supply that much . . .

Quote
I added a switch and fuse for each of the battery sources. The fuse ratings are just semi-random numbers for now, I haven't actually figured out what to put for each yet.

You will find that finding small fuses is actually pretty hard . . . let me know what you find cause I might use it for a future project . . .

Quote
And I switched the 0.1 uF and 0.33 uF capacitors for the 5V regulator. I'm a little unclear about this part though. In the datasheet (http://www.st.com/stonline/products/literature/ds/2143/l7805c.pdf page 4 Figure 3), it shows the application circuit with 0.1 uF connected to the output pin, and 0.33 uF connected to the input pin.

hmmmm Im not sure why they did it that way . . . I personally would put both caps only on the output pin, but Im definitely not an expert . . . the reason is because if the cap is on the input and suddenly drained, all that power would go through the regulator all at once. If the cap is on the output pin, that sudden power surge will not go through the regulator . . .


as for switching regulators, I use this guy:
http://www.dimensionengineering.com/DE-SWADJ.htm

 


Get Your Ad Here

data_list