ATtiny + Arduino Questions - Page 1
Forum section: electronics / beginners

author: Superkryptonite
author_rank: Contributor
timestamp: January 26, 2015, 03:05:20 am
content: Hi people!I'm very new at electronics design, etc...only know basic components and do some work on HVAC systems which have very basic electronic circuits...I just bought a Hakko 888 Digital as my first soldering iron...and now am looking into tiny soldering projects that I can use to get a feel for it!I saw thishttp://www.makershed.com/products/tiny-cylon-kit#and have always been really curious about how they actually PROGRAM those little chips...then came across this:http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/Would it be possible to re-program that ATtiny on the MakerShed board using the Arduino to have different LED configurations that I'd like? ie. Can I use the steps listed in the 2nd link to modify the coding on the ATtiny in the first link?Thanks!Elliott

author: Psi
author_rank: Super Contributor
timestamp: January 26, 2015, 03:13:54 am
content: Yes, the arduino IDE does support the ATTiny13 used in the first link.see herehttp://playground.arduino.cc/Main/ArduinoOnOtherAtmelChipsHowever the settings will be a little different and maybe the connections to the IC as well. (Because the 2nd link is for a ATtiny85/ATtiny45)The ATTiny13 is a very limited chip, it wont be able to store much code before its full. Flashing LEDs and simple logic is about all its good for.Keep in mind that once you re-program the tiny-cylon you wont be able to go back to the original code.The chip will be erased and you wont have the original code to put it back on. You will have to write your own code or it will be forever useless.

author: Superkryptonite
author_rank: Contributor
timestamp: January 26, 2015, 03:18:17 am
content: Quote from: Psi on January 26, 2015, 03:13:54 amHey thanks for the reply!Okay cool. So I guess there's no way the Arduino can read the code that's on the chip currently...hmmmm...Are there any other cool little kits that you could recommend a beginner? I looked around the web quickly and only found a few things.

author: Psi
author_rank: Super Contributor
timestamp: January 26, 2015, 03:21:54 am
content: Quote from: Superkryptonite on January 26, 2015, 03:18:17 amUsually companies will LOCK the chip to stop people stealing their code.If the chip is locked then the only thing you can do is erase it.If the chip isnotlocked then youcanread the code out (and put it back later).But keep in mind your reading out machine code and not human code. You can read it out and write it back later as much as you want but this code is not something you can physically read and look at how it works like you can with arduino code)So it depends if the ATTiny13 in the cylon kit is locked or not.(It probably isn't locked because it's so simple i doubt they would bother trying to secure it)

author: Superkryptonite
author_rank: Contributor
timestamp: January 26, 2015, 03:34:59 am
content: Quote from: Psi on January 26, 2015, 03:21:54 amGreat! Thanks so much for your time.

author: MacAttak
author_rank: Unknown
timestamp: January 26, 2015, 05:15:51 am
content: If you are somewhat comfortable with the coding side of things, you could always just use bare chips on a breadboard and program them directly to do what you want. The bare chips are cheap from digikey - you could get a handful from tiny13 up to much bigger chips to play with (just be sure they are DIP package) for just a few dollars. You need very few parts on a breadboard to get the chip running, plus maybe some LEDs and buttons and photoresistor etc to play with. And of course a small power source - a regulated bench supply is great, but a cheap battery pack and 5v regulator works fine too.For programming, you would need a real programmer module though (the "Arduino as ISP" is a hack to do this). You could use an AVRISP like this one ($34):http://www.atmel.com/tools/AVRISPMKII.aspxOr, if you use a JTAGICE3 ($99:http://www.atmel.com/tools/jtagice3.aspx) then you can also actuallydebug the code while it's running on the chip. This can be very useful when getting started because you can set breakpoints and step through the code slowly, inspect variable values, etc.Going that route you also wouldn't be using Arduino software anymore. You would use Atmel Studio, which is free. Atmel Studio (using one of those programmer modules) can also download/upload raw HEX files directly (the hex file is what the code compiles into).

author: MacAttak
author_rank: Unknown
timestamp: January 26, 2015, 05:18:47 am
content: Also, be sure to download and read the datasheet for the chip you want to tinker with. They are jam-packed with useful information on how to program the chips and how to use the various features like ADC, PWM, etc. The ATtiny13 datasheets are here:http://www.atmel.com/devices/ATTINY13.aspx(I would use the "complete" version which contains much more information on programming the chips).

author: zapta
author_rank: Super Contributor
timestamp: January 26, 2015, 05:41:31 am
content: You may want to take a look at digispark, similar chip but with USB and it's arduino ide compatible. It's open source so the boot loader is available.

author: Superkryptonite
author_rank: Contributor
timestamp: January 26, 2015, 10:14:08 am
content: Quote from: MacAttak on January 26, 2015, 05:15:51 amThanks a lot. I am comfortable with the coding side of things...just confused as to how the coding actually controls things I add onto the chip! Are those chips stuck being used for sensors only (photoresistors, LED's, whatever)? Or could I make something really complex using these chips? I have no idea what I have in mind just thinking out loud.Where can I get more information about how these chips WORK? Are they just called microcontrollers? Like how do they turn the code into physical electircal connections? Are there tiny relays inside or whatever that decide to give voltage to pins when the program says to, etc?Off to YouTube I guess :p

author: Mechatrommer
author_rank: Super Contributor
timestamp: January 26, 2015, 10:44:28 am
content: Quote from: Psi on January 26, 2015, 03:21:54 amBut keep in mind machine code is made by human. anything made by human can be read by human (with adequate diligence)

author: zapta
author_rank: Super Contributor
timestamp: January 26, 2015, 03:50:04 pm
content: QuoteNot if the compiler threw away some of the information in the source code written by the human. You can try guessing but this is not reading.

author: MacAttak
author_rank: Unknown
timestamp: January 27, 2015, 04:06:22 am
content: Quote from: Superkryptonite on January 26, 2015, 10:14:08 amA microcontroller is not much different from any other programmable processor. There is a lot of overlap between the two, and places where the lines get blurred.You can write fairly complicated code to run on a microcontroller, but usually it has some purpose to interact with the real world (using sensors and effectors).A microcontroller typically has flash ROM inside of the chip package - not a huge amount, but enough to store a program - so the chips usually don't need any external storage to "boot" from like a desktop computer does. The code is already loaded into the chip's ROM when it turns on, and it just starts running as soon as power is supplied. A microcontroller (unlike a microprocessor in a desktop/laptop) typically does *not* run an operating system. Your code is the only thing running on the chip - so things like threading, virtual memory, etc are irrelevant. This also means that code running on a microcontroller has deterministic timing - you can count on a timer firing at exactly the right moment - which is necessary when performing high-speed processing.Microcontrollers also typically have general-purpose I/O ports. These are generally banks of pins grouped in sets of eight. This is because an 8-bit processor has 8-bit wide memory registers, which the chip can map as "ports" to the outside world. When you toggle a "pin" you are really flipping one single bit of an 8-bit port.Those pins are typically capable of sourcing/sinking just enough current to light up a small LED. So in practice, you would usually buffer the output using external transistors. So no, there are no "tiny relays" inside - just some low-power solid-state circuitry that is just powerful enough to drive an external transistor or LED.Microcontrollers (talking about 8-bit ones, like the AVR series you are toying with) are made in many different configurations... from the really low-power TinyAVR chips ("ATtinyXX") to much bigger MegaAVR chips like you see on an Arduino (and some even bigger than that). They all work the same, but the bigger ones run at faster clock speeds, have larger memory banks, and have more (and more advanced) peripherals. For example an ATtiny13 will only have a couple of PWM outputs and ADC inputs while a MegaAVR may have many of those plus things like USB, Serial, SPI, etc. But all those features comes at the cost of a higher price for the chip and higher power usage. An ATtiny can run on a tiny coin cell for a while, while a ATmega will not.