Watched 1/2 a dozen videos looking for this information. All of them had too much extra, irrelevant information, and never got to the point. Found you. Liked. Subscribed. Awesome.
I have been searching for this tutorial everywhere and this is the best one in the net. very clear and detailed explanation. Thank you so much for spending time doing this tutorial. looking forward to see more.
You can buy little clip on heat sinks that help quite a bit in some cases. I picked up a handful of them for like 50 cents a piece. They just pinch on, but you can screw them on as well. Hope that helps. Otherwise, just use a lower supply and don't try to draw more than is recommended. That seems to work well for me. I haven't actually burned any regulators, but I was using a 12V reg to power a ton of IR LED's and it got pretty hot. It was rated to 1.5A and the LED's didn't draw near as much
I notice that several people are asking about programming the chip without first having a boot-loader in the chip. It's possible, but you need some extra hardware. Specifically, you need a USB-to-RS232 converter (unless you have an old PC with a genuine RS232 port). These are easily found and cheap to purchase off somewhere like eBay. I believe you also need a small value capacitor (I forget the exact recommended value but I know it's very low, such as 10pF). Refer to 11:40 when the picture comes up to show you how to connect the original Arduino shield to the chip and instead connect the pins from the RS232 converter, with TX on the board to RX on the ATMEGA chip and vice-versa. GND also should be connected from the converter board to the unprogrammed ATMEGA chip. There will generally be a 5V supply from the converter board and this can be used to power the ATMEGA during programming. If you're using a genuine RS232 port, then you'll still need to connect GND but you'll have to power the chip separately since genuine RS232 ports don't have a power supply line. The next connection is from the DSR pin on the RS232 converter board through the capacitor to pin 1 (the reset pin) on the ATMEGA. Connect the USB cable from your computer to the USB port of the converter board and wait for it to be recognised by the computer. Now you load up the Arduino software and under "Tools" first select the COM port which the converter board created as part of its installation, then under "Tools" select the board as "Arduino/Genuine Uno". Finally, also under "Tools" select "Burn Bootloader" and you should end up with a chip which you can program "just like a bought one" ;) I haven't actually tried the above. I'm just passing on and summarising what others have said. I'm wondering why there needs to be a capacitor in the DSR line but I've been told it's needed, so I passed the info along verbatim.
Your instruction is extremely clear! Your video is informative, and very helpful. One of the best explanations I have seen in a long time. Keep up the good work! :)
I actually just solved this problem on mine. in my case, I was not using the correct capacitors and I believe the crystal was not oscillating (hence, a sync issue). This error will also occur if the TX line is not properly connected (that is, you can reproduce the error on a working circuit by disconnecting the TX line). In my instance, I did not have a 22pF capacitor handy but I used a 68pF and it worked.
Great video as always, but I have a question/possible correction. You say that changing out the 16MHz crystal for a 20MHz crystal won't affect the rate of the LED blinking, but shouldn't it? When the C code is assembled to machine language, it has to be defined in terms of clock cycles (at least, that's been my experience with other uC's). Since you didn't upload new code to the uC, wouldn't it still be running the same number of cycles per delay, resulting in a faster LED blink rate?
Thanks for this very well done video. A comment: The digital pin 13 hasn't a resistor in serie. There is a (LED with a resistor in serie) in parallel to the digital pin 13. Using a LED connected between pin 13 and Ground is stressing the ATmega328 output driver. The LED can withstand more than 40 milliamps and will survive but a series resistor is recommended.
If the ATmega chip is overclocked then the sketch *will* run faster. So the LED will blink faster. The Arduino main library has been tuned so it waits for close to exactly 1 second. If you put in a slower/faster crystal/resonator, then the LED *will* blink slower/faster. If you're interested, use an oscilloscope and check.
That was interesting... I heard stories of how twisting wires prior to soldering makes micro resistive paths... but I still thing its hard to put the wire in the hole if I dont twist it.
It gets hot enough alright. It depends on how high your supply voltage is and how much current your circuit is drawing but ideally you should keep the supply voltage as close as possible to the delivery voltage. If the supply is 10V and the regulator regulates to 5V and you deliver 100mA, (P=VI) the 5V difference x 0.1A = 1W of heat, think how hot a 100W bulb gets! Most voltage regulators shutdown if they get too hot, but they can be still very uncomfortable to touch.
Very helpful. I don't even use my uno anymore. And I believe my TTL serial cable will eliminate the need for the uno for programing the microcontroller. Question: Can I use your power supply to make a 3.3 as well, like at the same time. Just use a 12V source and adjust the caps accordingly so that it is more like the UNO?
Excellent work!!! Do have oher presentation in where you have one Arduino in the breadboard and the other in the Shield and you program the one in the breadboard as the slave...? In any case this video was very good!!!...Wow...2011 and it is still as good!!!
I'd say the servo made the regulator quite hot as they draw a fair amount of current. The heat shouldn't have had any effect on your 328 as the 7805 usually has a thermal shutdown. I'm also not sure how you could have damaged the 328 with a servo as they don't require any additional circuitry to work, just share the GND/+5V line with the servo and run the yellow wire to one of your Arduino PWM outputs. The only thing I can think of is that you somehow shorted the 328 and drew a large current.
I must challenge the claim you made at 8:50 regarding the same blink rate when running at 16 vs 20 MHz. I do not agree with your claim, and would argue that the increased clock speed causes the LED to blink faster. Perhaps there is something I missed, but I also timed the blink rate in your video and recorded a noticeable increase.
but how increased clock speed will change the blink time?? I have set it to 1sec and the MCU will understand that 1sec for any speed of clock. the program uploading speed may become faster but it cannot change that 1sec delay.
As far as I can tell from the chip block diagram, there is no real-time clock in the chip. Timing appears to be calculated from the system clock, so there is a divide-by-16,000 somewhere and that gives you a millisecond. Clock pulses come 25% more often at 20MHz, so what you expect to be one second is 0.8s.
Excellent video. I think I found a very small mistake in the notes at 11:43. Instead of "Reset must be connected directly to PIN2 (not before the switch)", it should be: Reset must be connected directly to PIN1 (not before the switch).
Great video thanks Derek. Other videos have used the FTDT board to re-program the Atmega chip, but I love the idea of keeping a board aside to do this. I'd like to make up some 'Arduinos' on perf/vero board for cheap alternatives for projects, this helps greatly cheers.
Great! This series will be my next challenge eheheh! But I have a question, can I still use the RX and TX pins as IO's and use that way of programming the atmega?
Hi. You did a great tutorial here. I have a question. If I want to burn a bootloader onto a blank ATmega328, can I just simply remove the ATmega chip from my Arduino, insert a blank chip, upload the ArduinoISP sketch and then Burn Bootloader using Arduino as ISP?
google bit-101 Pull-up and Pull-down Resistors...there's a pretty good explanation from the blog owner...it's a subtle (at least for me, another noob) concept that prevents a floating state in the circuit, by using resistors as a means of forcing ground(low)/vcc(high) when the circuit is broken, but preventing a short circuit when there's a connection. Hope I'm correct, and HTH :)
You've mixed up the meaning of AREF. It's either the VCC and then AREF connected VIA A CAPACITOR to the GROUND (not VCC) or another source of reference voltage. Saying it's no harm to connect AREF to VCC directly is very error prone when the 2 voltages mix up and give you strange A/D conversions.
Derek, nice vid. Um, at 11:45 your slide says to connect RESET to pin 2 before the switch, but the picture shows pin 1. Other than that, this is a great video. It got me understand what I was doing wrong.
I'm pretty unsure but it has do something that servo using highest power or improper power supply which is why it destory 328p. Every servo have specs require of power using. Another reason RealationGames might put into wrong place of chip. I'm a helicopher RC repair.
Can you show, uploading a sketch using a ftdi instead of using arduino board,,ftdi breakout board and atmega chip can be left connected instead of connecting and disconecting arduino uno.......Great tutorials..schematics a great help
avrdude: stk500_getsync(): not in sync: resp=0x00 i have been having this problem for a while did all the steps you have said the led is blinking just cant seem to use the TX and RX to upload . great video very helpful !
From taking stuff apart I noticed that the metal side of the voltage regulator is sometimes connected to a heatsink or perhaps even with thermal paste thus the top screw hole.
Barış Sami EDREN u need to have the help of LED Series/Parallel resistors connection ,u can find on www.resistorguide.com/resistor-for-led/ kershoves law .....and this is a calculator directly to a no. Without laws: ledcalc.com/ it sounds that it depend on which color of led u use in which wave length and which V*f is used relative to the wave length used so u can find a table of wave lengths for led colors with its V*f numbers on www.electronics-tutorials.ws/ and u can directly calculate the value without need of V*f (led) or V*S (battery)or I*f(led) which is mainly 20 maph for most leds
Not also did my regulator got hot, but it burned out my 328p-pu MCU. Why is that? I was controlling servo with it. I got the servo supply from the same power rail, and servo PWM from the MCU. I'd like to know what I did horribly wrong so I won't burn out another chip. I used 9V input to the regulator.
that was definitely a great video, I didn't know you could do that. super cool!!! a question for Master Derek, can you retrieve a program/sketch from an arduino or from the chip. thanks mike
Theres a way to get the compiled hex from the chip using avrdude command line codes but it was not humanly readable sketch... I wanted to know if theres a way to detect bootloader or make a bootloader checker circuit tool to find out which chips are used or not. Maybe you can make a custom bootloader/compiler to preserve sketch info save that to data flash?
This is an excellent video and one of the best, most concise explanations of this process. There is only one question unanswered. What if you don't have, or don't want to use the Arduino carrier board to program the chip, but you have a USB to TTL adapter available? Given how common these adapters are, it's easy and cheap to have one around for programming various micro-controllers. How would you go about doing so with this setup? (eg www.adafruit.com/product/70 )
I wish I had come across this about three weeks ago. I would like to ask, do you only need to provide 5v to the breadboard or also 3.3v. In my setup I am going to use a PCB AMS1117 and I have both 3.3v and 5v, and this is what I am planning on using for the power circuit and because I don;t want to use an Arduino at all, I was going to use the lower part of my board for a FTDI.
It doesn't actually (though you can query F_CPU). In Arduino, that counting is handled by wiring.c library function "Micros" (which get added, to become Millis and Delay). Unfortunately, the way Micros is written, it only works properly with frequencies that divide evenly into 64 (8, 16). 64/20=3.2. At 20MHz, Micros outputs an unsigned long integer, meaning that it drops 0.2 with each cycle of the clock and it takes longer than expected, to achieve the desired count. The workaround is to create an If Else for the 20MHz case and simply count clock 'ticks'. Then, use (float)micros() * 3.20 to calculate the actual microseconds in your main program. Microsecond delay, because of the way it is calibrated, is actually accurate.
The 20MHz crystal will make the LED flash slightly faster, unless you tell the Arduino there's a 20MHz crystal there. When you burn a bootloader onto a blank chip (as would have happened to the chip shown, prior to leaving the factory) you burn "fuses" into the chip that tell the chip what frequency of crystal is connected, or whether the chip should use the internal clock.
I'll rephrase... Because of the way it is handled, Microsecond delay does not suffer the same 0.2us per clock cycle offset as the Micros, Millis and Delay functions. It is roughly as accurate at 20MHz, as it is at 16MHz (within about 0.4 seconds per day).
Hi, great tutorial, why did U use 20mhz after programming? I'm new to arduino programming and making my own board witch is working partially, I'm using GSM and breadbord arduino, and it's only sending first SMS, don't know why is not going to loop after On Arduino board is working perfectly Thanks!
I love this video. I want to do some simple circuits for a model train layout and want to be able to tweak them as far as leds flashing rates and so.Using the arduino boards usb brings the cost down to about 3 or 4 dollars per circuit. just the cost of a ATMEGA328P-PU Microcontroller (2 dollars) and a crystal and some caps (50 cents) and they are tweakable Thanks
I have constructed this same circuit on the Breadboard. I am programming the standalone Atmega328P with the Arduino. I am getting this error while uploading the code: Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes. Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes. avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x01 Problem uploading to board. See www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
I saw that when you installed the 20mHz crystal that you oriented it a particular way. Was that just so we could read it? or was that because the crystal has a polarity preference?
Ok, it might sound stupid but I have this question: can we have a number of Atmega chips and connect them parallel to the TX-RX rail? My expectation is merely to upload a program to a number of chips at once.
+pangpengmaster Maybe you could search for parallel programming arduinos. I do remember someone having set up the Raspberry Pi as a mass Arduino programmer but I don't remember any details.
Can I burn my bootloader so I can use any atmega328 like this? It would be much cheaper and more convenient if I could just buy blank chips at the local store.
I think you did not connect diode to your servo to stop the current from loading back when you stop the servo . let me know if you solve it or you find the exact reason .
why are you connecting VCC twice the Arduino is powered via USB and your bread board is powered though the 7805 regulator they only need a common GND all I do is jump RX TX and Reset and it works fine
hey can you show how to drive it with internal 8 mhz oscillator!? I got an USBtinyISP and want minimal setup as can for my project. can't take a ATTiny for it.
Do i need to remove the chip always before programing the micro controller or only in this tutorial you mean ? i am new in this and trying to understand . so in case i want to program another chip. shall i remove it or i can keep it ?
The website says to remove the chip. I wonder if you can program two chips if there is one in the slot. Technically if you dont want to use breadboards you can leave the chip in the shield. So far thats all I am doing. Im trying to learn first. Also if you dont have the shield theres a way to program your chip to act as ArduinoISP and you wouldnt have to risk damaging your shield thing. Im trying to learn that too. It has to do with the bootloader and burning it. If you get a cheap arduino nano atmega328p it seemed to upload sketch right out of the package via usb. So long as right chip and connection port is selected in my case tty/usb
how do you determine what components (value or type of capacitor, resistor, crystal) to use ? Please tell me if I should learn something first. I am new to this and i don't know where to search.
Crystal oscillator depends on the chip itself.usually the one Arduino uses 16mhz. For caps 22pf is enough to give the crystal enough pressure to start oscillation. Resistors 100-470 ohms are good to be current limiting resistors
well Done , super explanation. I'm a bit confused because i've read that the arduino (forum.arduino.cc/index.php?topic=2429.0) should be powered with 9 to 12 volts. ? I have a project proto typed using an Arduino uno powered from my laptop through usb. I'm hoping to transfer the project to a PCB with a atmel 328 pu chip with bootloader on board. I want to switch 12 v LED assemblies and a buzzer. now i will use transistors to switch the LED assemblies etc. which will have an independent 12 v supply through the collector . I will use the base of the transistor to switch but will the 5 v power supply or 9 to 12 v supply be a better option? any thoughts on this will be greatly appreciated.
What about those 10 components in the left of the breadboard? Why do you need them? Cannot just feed 5V and GRD to the arduino directly from the power supply?
The power supply switch helps a lot and the bootloader is only run at start from end of program memory section from what i learned today it is only invoked on reset button press or fresh start. But that part is what allows you to upload sketches using avrdude aka arduino IDE
Why does the ATMega IC chip need multiple GND and VCC pins if that is all that the pins are used for? Whats the point? Is there an actual reason for this?
The multiple grounds can be useful in board design, but on that chip there is only 2. Also, the AVcc is not actually just a Vcc pin, it is used for various analogue circuits I believe. Anyway, hope this was helpful in some way or another!