Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1] 2   Go Down
Author Topic: Motor Controller with ATMega168  (Read 1164 times)
0 Members and 1 Guest are viewing this topic.
Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello;

I'm a retired art teacher making a laptop electric spinning wheel for one of my high school art teachers, now in a wheel chair. I've never done anything with electronics before starting this project, but have always wanted to. When the opportunity presented itself, I was eager to dig in. I've been following the directions for the Electric Eel Wheel http://www.dreamingrobots.com/ElectricEelWheel/BuildersGuideElectronics_v1200/ by Maurice Ribble.

The URL above lists all the recommended parts to build the PCB, including an ATMega168 which I seem to have ordered just before it was retired. My custom PCB just arrived today, and I'm anxious to dig in.  So, in reading here on the Arduino site and elsewhere around the web, as well as in watching tutorial videos on YouTube, I get the idea that a USB connection is used to connect to my PC. There is some confusion in my mind about that, however, in that Maurice includes no USB connection, and Sparkfun Electronics https://www.sparkfun.com/products/8846? says:

Quote
To get this chip working with Arduino IDE, you will need an external 16MHz crystal or resonator, a 5V supply, and a serial connection.

I presume the serial connection is typically be made by USB?  My question then is, given what I've purchased so far, can I install his Arduino program on the ATMega168 http://www.dreamingrobots.com/ElectricEelWheel/files/electricEelWheel.pde?  If so, can someone point me to a tutorial, or give this lay person directions? If not, well, what might you do in my shoes?
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

when you buy a chip like the 168 (which is not retired, its just not most popular) unless it specifically says it has a bootloader, and cost nearly twice as much, its a blank chip. Think of it like a desktop computer with a blank disk in it, its just going to sit there and do nothing untill something tells it otherwise.

To get the bootloader on there, you need a programmer, and if you have a programmer you dont really HAVE to have a bootloader. The bootloader is just a little code that gets loaded when the chip first gets power, listens for a magic code over the serial port, and if it gets it programs the chip with your program, if it doesnt it just starts up whatever in there. (and yes it requires conversion to connect to a com port or a usb port on a pc, its not standard RS232)

Programmers range in cost and features from "make your own" if you already have an arduino, to a couple bucks on ebay, to over 100$ for development boards.

If I were you I would get something like an USBASP which runs 2-20 bucks, once you have that burn the bootloader (a simple menu option) which gives you serial programability and sets the chips fuses (options) for you. Again you dont have to use the bootloader, but you do have to set the fuses or else stuff is not going to work right ... and a couple clicks vs a big line of text in a command window you might as well install it.

edit: ack, just noticed you got the one with the bootloader if you bought it from sparkfun. In that case you can use the programmer above or you can get an FTDI cable / breakout board to program over USB (also available though sparkfun)
« Last Edit: January 25, 2013, 09:08:57 pm by Osgeld » Logged


Offline Offline
Faraday Member
**
Karma: 70
Posts: 2989
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe (others may want to confirm this) you can use an ATMEGA328 on your project board.
You could then purchase an Arduino UNO (which has a 328) use it as your design platform.
You upload your compiled code from the Arduino IDE software using an USB cable.
Next you would remove the 328 from the UNO and plug it into the 28 pin socket on your project PCB.
I would recommend buying a few extra 328s (with boot loader) just in case you damage one.

I compiled your electricEelWheel.pde sketch, it was 2,748 bytes. The 168 has 16 Kbytes and the 328 has 32 Kbytes.

There are many other places on the NET also:
https://www.adafruit.com/products/123
https://www.adafruit.com/products/50

Good for you for wanting to get into this stuff.
You may find this interesting http://tronixstuff.wordpress.com/tutorials/
« Last Edit: January 25, 2013, 09:35:40 pm by LarryD » Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yea 328p's and 168p's are interchangeable, you just get more ram and rom with the 328
Logged


Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My garsh; thank you both very much. I've been bouncing back and forth between eBay, Mouser, and SparkFun in order to better understand the direction you gave me, and slowly, illumination ramps. The only bit that I'm having a time with, Larry, is when you said, "I compiled your electricEelWheel.pde sketch, it was 2,748 bytes. The 168 has 16 Kbytes and the 328 has 32 Kbytes". I guess I'm not sure how to interpret that unless it was to suggest another good reason to upgrade the microchip? Well, I think I will, and I also think I'll get an extra one or two just in case.

You both also have my gratitude for not having sent me to buy a pre-made Arduino board. This is a lot more interesting, and I feel much more a part of the project by building the board, and learning about it, even if I'm merely following a recipe.

Osgeld, my apoloies for not having mentioned the bootloader. I don't fully understand what that means (I do a little), but I had read, and seen enough to know that it was important, and I intended to include it in my topic subject line.

Finally, Osgeld suggests the USBASP, while Larry recommends a Arduino UNO (could you point me to something that looks like you mean, there are a number of things that come up when I search for that). Do these two approaches accomplish the same thing? Does one have an advantage over the other?

ETA: Drat. Sorry, Larry; the first time I looked at those two links, I didn't catch what I was seeing.
« Last Edit: January 25, 2013, 11:52:15 pm by Dave_Burrows » Logged

Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Found these with good prices:

Arduino Uno R3 http://www.ebay.com/itm/Arduino-Uno-R3-/300823638330?pt=LH_DefaultDomain_0&hash=item460a7c713a

(Arduino-Compatible) UNO R3 MEGA 328 for Arduino IDE Software USB Cable 01052 http://www.ebay.com/itm/Arduino-Compatible-UNO-R3-MEGA-328-for-Arduino-IDE-Software-USB-Cable-01052-/281052236490?pt=LH_DefaultDomain_0&hash=item417004caca

USBasp AVR programmer Atmel arduino microcontroller http://www.ebay.com/itm/USBasp-AVR-programmer-Atmel-arduino-microcontroller-USB-ASP-ISP-USA-/181065759451?pt=LH_DefaultDomain_0&hash=item2a285c3adb
Logged

Offline Offline
Faraday Member
**
Karma: 70
Posts: 2989
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The only bit that I'm having a time with, Larry, is when you said, "I compiled your electricEelWheel.pde sketch, it was 2,748 bytes. The 168 has 16 Kbytes and the 328 has 32 Kbytes".
The 2,748 program will easily fit on both the 168 & 328      i.e.   2,748 < 16,384 and << 32,768.

Quote
Finally, Osgeld suggests the USBASP, while Larry recommends a Arduino UNO (could you point me to something that looks like you mean, there are a number of things that come up when I search for that). Do these two approaches accomplish the same thing? Does one have an advantage over the other?
Both methods will program the controller chip.  I was suggesting the UNO because its an all in one solution and I think easier to use for a beginner.
When you finish this project, i.e. program the controller and move it from the UNO to your Electric Eel Wheel hardware PCB, you will still have the UNO (and extra controllers chips you buy) to further your learning on the Arduino.
The UNO: is user freindly, cost efficent, has a removable 328 (you may want to make a standalone product later), you do your developement on the UNO and it has a built in USB to serial converter for uploading sketches. (you will need a USB printer cable).
Here is an introductory glimps that may be of some interest: http://www.gammon.com.au/forum/?id=11637

I just sent the links as examples to where you can purchase these items.  
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

usbasp is more of a soulution if you bought a blank chip from mouser or digikey with no other arduino ready hardware

since you got a bootloaded chip you can program it over serial (considering external conversion hardware like an FTDI chip)

the major advantage of using a programmer vs hooking up additional hardware to support serial programming is

 it cost less, and your programmer will work with any other project you see down the road
VS if you discover a bug, your end user can just plug it into a USB port and update easily without a programmer with a file sent via email

in then end they all do the same thing, burn your program to rom so the chip runs

Larry does have a valid point though, you could buy a premade arduino, plop your 168 in place of the stock 328p ,use that to program your 168p and move it over to your final target

then you just plop the 328p that came with the arduino  back in and move on to other projects/interests

if your even somewhat interested in arduino as a platform, I would buy an uno, once you have one you can program a pretty decent varity of chips, from 8 pin tinys to chips that have enough resources to emulate full blown computers from the early 80's
« Last Edit: January 26, 2013, 01:05:31 am by Osgeld » Logged


Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you again for all your helpful information. I have a lot of reading / watching to do, a decision to make, and another part to order.

This past summer, I wanted to do a small html / css project, and while I had messed around with both for years, it was usually with the crutch of an editor. I wanted to write the code for myself using a text editor. With the vast amount of information, examples, and tutorials on the web, it was not all that difficult to do, but it was time consuming. In the process, I learned...about divs, about connecting css to html, and about code. I'm hooked. This is starting the same way that did, so you were speaking right to me when you suggested I might want to move on to another project when this one is completed. So, one of the things I want to do is to see what can be done.
Logged

Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I spent a couple of hours yesterday soldering my PCB. No one should be allowed to have so much fun when they're by themselves. At this point, without the software for this motor controller, the motor comes on, and spins at full speed in a clockwise direction, even when the potentiometer is straight up. It'll be a little while before I can spend more money on this, but I've decided to get the genuine Arduino UNO R3 Dev. board. I'm going to use the open source Arduino software, and this is a small way of contributing something back.

If you have a couple of minutes, anyone, I covet your constructive criticism of my soldering, etc., especially when I can improve on what's been done:

http://www.meadowcroft-dyeworks.com/PCB%20001.jpg
http://www.meadowcroft-dyeworks.com/PCB%20002.jpg
http://www.meadowcroft-dyeworks.com/PCB%20003.jpg

Click on the image for a closer view.

edited to correct a misspelling
« Last Edit: January 27, 2013, 04:44:08 pm by Dave_Burrows » Logged

Offline Offline
Faraday Member
**
Karma: 70
Posts: 2989
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You did a great job soldering the PCB!
The push button, top RHS side pad, is lacking some solder flow through.
Note: you can use a Q Tip and Isopropyl alcohol to clean up any flux.
I suggest you put a red/white mark on top of the micro controller near pin 1 & on the PCB near pin 1 to remind you to plug the chip properly.
In the future, you may also want to keep the components as flush as possible to the board.
Good work.

Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Larry! You have a very supportive way about you that's uncommon in tech forums.

I can easily add a tiny bit more solder to the corner push button pad as you suggested. I see that in the image now that you point it out, and I can see it on the board with a magnifying glass now, too. 

I used a toothbrush with isopropyl as was suggested by the designer of this board. I gather by your having mentioned it that I didn't get it all. I'll study the enlargement to find and clean up the rest.

The marks at pin 1 of the micro controller are a good idea. I had been using the little notch, but the mark will be even easier to see.

Shoot. I intentionally kept some of the components away from the board just to try to keep them from getting too hot. With at least some of them, I think it won't be hard to drop them to where they should be. The resistors, and diodes are 3mm to 5mm above the PCB surface; should they be closer do you think? The crystal, and most of the capacitors should be easy to bring down.

Thanks very much again...those are some very helpful suggestions.
Logged

Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since several of the components of my project get hot, and since both it, and the motor it will control will be housed inside a wooden box, I'd like to put a 12V. PC box fan in that box as well.

Can my project board support the fan as it is, and if so can I make solder connections with it's leads somewhere?

I found that I could connect the leads to two of the pads at the AC connector, but of course, it's not switched there. Allowing the fan to run all the time the unit is connected to the power supply is an alternative that works just fine, but I would like to connect it in a way that is controlled by the power switch.
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

do the diodes get hot?

the motor IC (the big metal tab chip) can have a chunky heatsink attached, which may be enough to not need a fan
Logged


Washington, PA
Offline Offline
Newbie
*
Karma: 0
Posts: 32
A job worth doing is worth doing right
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The diodes get warm, but not hot.  The L298N, the larger of the two chips with a metal tab gets warm, but not at all hot. The ATMega168 also gets warm, but the 5V Regulator LM7805, the smaller chip with a metal tab gets hotter than is comfortable to touch in just a few seconds, and it stays hot while the PCB is connected to the power supply, even if it is switched off. Is that normal?

The wooden box is not entirely closed, either. There is an opening about 2" x 4" to accommodate the belt; the PCB is fairly close to that. Maybe I don't need a fan.
Logged

Pages: [1] 2   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: