1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Arduino Programmer

Discussion in 'Arduino' started by AtomSoft, Apr 5, 2012.

  1. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Ok i want to make my own arduino boards but am kind of lost when it comes to programming it. I have a AVR Dragon so i know i can program a bootloader on it but the issue isnt that.

    I want to be able to program my stuff using the Arduino IDE and simple on board components like a serial to usb connector.

    Now im looking at the Arduino Uno schematic (r3) and need to know... does the ATMEGA16U2-MU(R) act only as a USB to UART device?

    If i replace this with something like a FTDI or CP2102 would i still be able to program the arduino?

    http://www.electro-tech-online.com/custompdfs/2012/04/Arduino_Uno_Rev3-schematic.pdf

    My main questions are...

    1. Does the ATMEGA16U2-MU(R) translate USB commands to program the AVR?
    2. Or Does the ATMEGA16U2-MU(R) translate the USB commands to UART for the MAIN AVRs bootloader to program itself?
     
    Last edited: Apr 5, 2012
  2. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Ok i just found this page:
    http://arduino.cc/en/Main/Standalone

    So does that mean as long as i have the bootloader in the AVR i can program it with any USB to UART ic? Or do i need to worry about the reset control still?
     
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    You can always buy the chips in quantity, with the bootloader already installed... This is the way "TinyClr" (.net) operated.. The chips weren't much more with the bootloader. Probably thinking about it... To program the chips with a bootlader was a lot quicker for them.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US

    Yeah thats the plan but i want to make a PCB some custom Arduino stuff. And i want to make sure all i need is a usb to usart cable...

    Oh wait! I have a Arduino here that means the chip has a bootloader already. Ill try to make my own usb to uart and test on that... wow silly me!
     
  6. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    Hi Jason,

    If you already have an arduino you can use that to load a bootloader to your new ATMEGA168 etc. Then all you need is a usb-ttl adaptor like this

    http://www.ebay.co.uk/itm/USB-2-0-T...uting_CablesConnectors_RL&hash=item45fc6f93a2

    for loading your sketch to your board.
    Note that older versions of arduino used a manual reset and newer versions use an auto reset, so that the new sketch runs automatically after loading. The usb-ttl adaptor linked above includes the reset line as well as the basic tx/rx used by the bootloader.
    I haven't used my arduino for a while so can't remember the exact settings in the arduino IDE you need to use when using non FTDI usb ttl adaptors.

    Regards,
    Leftfield95
     
  7. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Ok this is the dilemma now:

    Code (text):
    Binary sketch size: 1026 bytes (of a 32256 byte maximum)
    avrdude: stk500_getsync(): not in sync: resp=0x00
    Its a simple blink example but cant program it via Serial port... now what? I tried connecting DTR so Reset as well. But no go...

    What do i select as programmer? Or will this only work with FTDI usb to uart?

    If so how would i make my own driver for CP2102?
     
  8. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    I Actually sell something like that.
    http://atomsofttech.com/shop/index.php?route=product/product&product_id=97

    But its not working for this. I tried everything from settings in Device Manager to reversing the TX RX Pins.

    When programming i see the Uno reset but i still get the error and nothing is uploaded. So my idea or well my only option is to use the same IC as in the Uno: ATMEGA16U2

    But that seems to be out of stock everywhere but Digikey and cost almost $4 there. I guess its my only option so ... $4 it is :(
     
  9. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    Are you trying to program a sketch into your old bootloaded arduino chip from your aduino board, but using a diy serial interface and the chip on breadboard ?

    If so you need to tell the arduino IDE what type of board your trying to emulate ie "Arduino Uno", "Arduino Duemilanove", "Arduino Diecimila" this will tell it how to program the sketch.
     
  10. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    OK, I see you have an UNO based chip, unfortunately I have never used one of those.

    The older style Arduino that I have used were OK for programming via the FTDI or CP2102 chips, you could try programming an older bootloader onto your arduino chip something like the "Arduino Duemilanove".

    A couple of IDE files you may find interesting are boards.txt and programmers.txt they show how the IDE treats the various boards and what bootloader it expects for each.

    I think your BreadboardBuddy looks handy, it should work OK.
     
    Last edited: Apr 6, 2012
  11. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Ok thanks for the tip. I went into a directory: arduino-usbserial

    which has the source for the atmega16u2 part... do you think it would be hard to edit this code for a AT90USB162 ? I have 3 of those ICs on hand in TQFP but still worthy of a try. I never did any AVR coding that i can remember but i guess this is worth a shot. Also the AT90USB162 cost the same as a CP2102 so would be perfect!
     
  12. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
  13. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    I thought the UNO used an ATMEGA8 for its usb to serial convertor, I guess the latest revs have gone to the higher spec chip.

    As for modifying the code for an AT90USB162, I'm not sure, I don't like C at the best of times.

    My current setup as well as lots of Arduino Duemilanove clones, is to use one of these ;

    http://www.ebay.co.uk/itm/XINO-Basi...715?pt=LH_DefaultDomain_3&hash=item4ab5dcbe9b

    Which I use with the CP2102 board linked previously. But I use an older version of firmware on them, than the more upto date UNO use.
    The version I use seems to work OK, so I've never bothered with the newer stuff. I will try and dig out the boards later and have a play, probably 4 or 5 hours.

    But at the moment I have to go out.
     
  14. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Thanks and that little board is awesome!

    Ok Let me give you a example of what i want to do.

    Lets say you have a Arduino and Ethernet shield... I want to basically combine them into 1 PCB but still be able to program it like a arduino. Thats why im thinking about just spending the extra $1 and change for the ATMEGA16U2. And just program it with same firmware on arduino uno. This way its completely compatible.
     
  15. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    OK, I've managed to upload a sketch (i hate that word, Its a program people) using the onboard FTDI and an external CP2102 module, with both an UNO and Duemilanove bootloader onboard.
    I had no problems with any of the four combinations, you just have to make sure the COM port is set correctly, ie. baud rate and handshaking.

    The previous link I gave for the CP2102 module is wrong, this is the module I have, it has access to the DTR line, along with all the other handshake signals.

    http://www.ebay.co.uk/itm/USB-TTL-C...sGames_RadioControlled_JN&hash=item336f5382a8

    It looks like any USB to TTL serial adaptor should work, I am going to try this next.

    http://www.embeddedadventures.com/usb_to_serial_plt-1003.html

    I see what you're trying to do with the combined PCB, I think I've seen them already from a couple of sources, a DIY one is here.

    http://www.instructables.com/id/A-credit-card-sized-Ethernet-Arduino-compatable-co/
     
  16. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Thanks for all the info. Im going to retry this again. Can i ask if you could simply either tell me what Baud Rate and stuff it should be or a image.
     
  17. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    For the UNO bootloader is needs to be set at 115200.

    For the Duemilanove it needs to be 57600.

    Thats according to the boards.txt file, both are with hardware handshaking if you want the auto-reset to work.

    So if you try and upload with a serial link that cant do 115200 reliably on a UNO bootloader it may not work.
     
  18. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    All you need is TX RX and CTS

    And your usb to serial adapter to say I'm a com port for the uno

    The ATMEGA16U2 can do two things It's a USB bridge and a AVR programmer with right code loaded


    For loading code
    AND for programmer
    There auto baud rate you can set the port to most any rate.

    Mine is at 9600
     
    Last edited: Apr 6, 2012
  19. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Thanks Burt... Are you sure its CTS ? It resets ok with DTR but still has a sync issue. I tried adjusting the baud but no go :(

    How would my adapter say "im a com for uno" ? lol

    It shows up as COM3 which is correct but no go so far
     
  20. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    OMG lol i think i know the problem... its me being lazy. Instead of placing my IC from arduino on a breadboard i am trying it in the Uno board so the other IC is mixing or corrupting the data. I tried it from the UNO itself and it doesnt work with the UART pins being used. If i remove my USB to UART the UNO is programing as normal. So ill try it on a breadboard alone and write back soon.
     
  21. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    OMG forget it lol I tried a CP2102 and a MCP2200 both wont work. Ill just stick with the ATMEGA16U2
     

Share This Page