A Tiny Programmer for ATtiny Microcontrollers With Arduino UNO : Part2-Newer ATtinys
by TedySto in Circuits > Arduino
1540 Views, 3 Favorites, 0 Comments
A Tiny Programmer for ATtiny Microcontrollers With Arduino UNO : Part2-Newer ATtinys
I continue what was written in the article:
https://www.instructables.com/A-Tiny-Programmer-for-ATTINY-Microcontrollers-With/
with the description of a device capable of programming microcontrollers from the newer generation ATtiny series.
As is natural, the microcontrollers in this series have evolved, offering more program memory space and RAM, more GPIOs, increased work speeds, generally superior performance.
As in the case of the older series, they can be programmed in the Arduino IDE environment (C++), a friendly and well-developed programming environment.
But the physical way of programming is different, hence the need for another shield that will be attached to the Arduino UNO and a new ATtiny Core.
This is what we propose to do here, a matter of great interest, especially since the widely used TL866, XGecu T48, T56 programmers do not have the possibility to program this series of newer ATtinys.
Supplies
All electronic components are in current production and can be purchased from here and PCBs can be ordered from here. These can be purchased from other places, there are many sites specialized in this.
For those who have the technical possibilities to make PCBs, they can be made on their own, according to Step4 instructions.
The Evolution of the ATtiny Series. What We Need to Know About the New ATtinys.
To see the evolution of the ATtiny series over time, in terms of performance and complexity, the following link is very useful:
https://en.wikipedia.org/wiki/ATtiny_microcontroller_comparison_chart
Here we can see how from a clock speed of 2MHz, 1KB Flash, 5 GPIOs and no other facilities (ATtiny11) we reached a clock speed of 20MHz, 32KB Flash, 3072 bytes SRAM, 256 bytes EEPROM, 22 GPIOs and other facilities ( ATtiny3227).
We can consider that the newest series of microcontrollers of this kind starts from ATtiny202.
This newer series has some features common to all microcontrollers, of interest for the construction of this programmer:
- All devices are in SMD technique, THT technique is not used here.That is why it is necessary to use adapter sockets from SMD to THT, as will be seen below.
-All devices are programmed on a single pin, using UPDI (Unified Program and Debug Interface protocol).Thus we have a simpler, safer and faster programming interface.
The notation of the microcontrollers in this series can provide us with some important information about their characteristics.
The generic notation is of the type:
ATtinyFFSC
where: FF-is the flash memory program size in KBytes
S-the series to which the device belongs and which refers to the amount of SRAM,
EEPROM and others.
There are series 0,1 and 2, the performance of the device increasing as it belongs to a
higher series.
C- case, that is the encapsulation type of the device.
Example 1: ATtiny1604 16KB flash, series 0 (1024 bytes SRAM), case SO150-14
Example 2: ATtiny3216 32KB flash, series 1 (2048 bytes SRAM), case SO300-20
In this Instructables we propose the programming of 2 types of microcontrollers: ATtiny1604 and the series it belongs to and ATtiny3216 and the series it belongs to (ATtiny3217 has not been tested yet).
Using appropriate sockets or adapter boards, all the microcontrollers that are included in the ATtinyCore can be programmed.
Schematic Diagram
Our little programmer is physically realized as a shield that connects to an Arduino UNO through 1 to 1 connectors.So the configuration of the J1...J4 connectors is identical to that of the Arduino UNO connectors.
The supply with +5V is done at J3 pin5 and its presence is signaled by LED D1.
C2 is power supply decoupling capacitor.
C1 is connected to the Reset pin of the Arduino UNO and has a role in the correct initialization of the program.
The actual programming of the microcontroller is done on its Reset pin, from D6 of the Arduino UNO via R2 of 4.7K (UPDI-Unified Program and Debug Interface protocol, only one pin).
From the datasheets given below, it can be seen that the physical location of the Vcc, GND and Reset pins is the same for ATtiny 1604 as for ATtiny3216, which simplifies the use of the programmer.
List of Components, Materials, Tools.
The list of components for the shield, as given by the program according to which it was made, is:
1;"ZS1";"ZIOSock 28p";1;"ZIPSock"
2;"R2";"R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal";1;"4K7"
3;"R1";"R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal";1;".33K"
4;"C1";"CP_Radial_D5.0mm_P2.50mm";1;"10uF/6V"
5;"C2";"CP_Radial_D5.0mm_P2.50mm";1;"47uF/6V"
6;"D1";"LED_D5.0mm";1;"LED"
7;"J1";"PinHeader_1x10_P2.54mm_Vertical";1;"Conn_01x10_Male"
8;"J2, J3";"PinHeader_1x08_P2.54mm_Vertical";2;"Conn_01x08_Male"
9;"J4";"PinHeader_1x06_P2.54mm_Vertical";1;"Conn_01x06_Male"
To these are added:
-PCB executed as in Step4.
-Arduino UNO (R3).
- Tin and tools for soldering with tin.
- Adapter sockets SMD to THT as in Photos 3.1 and 3.2. They are labeled as shown, the project of the labels can be found in the project from Step4.
-Digital multimeter.
-Pliers for cutting component terminals.
Making PCB. Assembling the Device.
The device is made according to a project in KiCad, which can be found in full at the address:
https://drive.google.com/drive/folders/1mG2xlCjkRWDJH23CI1i06lfsHlsNydN6?usp=share_link
The program allows you to make your own PCB (photo, PnP, etc.) or order it from the factory.
I made the PCB on my own, but everyone will do according to their possibilities.
After making the PCB, we proceed to its assembly, which can be done according to the project in KiCad but also according to Photos 4.1, 4.2 (top view) and 4.3, 4.4 (bottom view).
Visually check the correctness of the assembly and with the digital multimeter the continuity of the tracks and that there are no short circuits.
Finally, we will mount the shield on the Arduino UNO as in Photo4.5.
After connecting the assembly to the PC (USB cable), we visually check the lighting of the LED on the shield. The presence of +5V voltage will be measured (digital multimeter).
Upload Software on Arduino Uno
In order for the Arduino UNO to function as a programmer for this type of microcontroller, a specific software must be uploaded. This is "jtag2updi" and we can find it at:
https://github.com/ElTangas/jtag2updi
The file is downloaded from here in the form of an archive.
It is unzipped and a folder named "jtag2updi-master" is obtained.
For uploading to Arduino, you need a little attention: opening the previous folder, you get what you see in Photo5.1.The "source" folder is renamed "jtag2updi", see Photo5.2. Opening this folder we get what is seen in Photo5.3. Double click on jtag2updi of type ".ino" from here, it is called Arduino IDE and we see as in Photo5.4.
This sketch will be uploaded to the Arduino UNO. Even if it is empty, it contains several split files that can be seen at the top of the Arduino IDE.From Tools we will choose "Board: Arduino UNO" and "Programmer: AVRISP mkII", see Photo5.5. Then we will compile and get "Done compiling". Now it is possible to "Upload" sketches on Arduino UNO.
The jtag2updi folder can be obtained ready processed from the link in Step4.
Upload New ATtinyCore on Arduino IDE.
In order to be programmed with the Arduino IDE, the ATtiny microcontrollers must be recognized by it. For this, some software sequences will be introduced in the Arduino IDE that will allow the Arduino programming environment to recognize microcontrollers in the form of "Boards". These are the "ATtiny cores".
In the case of these newer ATtinys, the software that must be included in the Arduino IDE is called "megaTinyCore".
The software will be installed online, from the address:
http://drazzy.com/package_drazzy.com_index.json
For this, we follow the path:
Arduino IDE-->File-->Preferences-->Additional Boards Manager URLs. Here the above address is entered from the keyboard-->OK.
We can also use Copy -->Ctrl + V.(Copy-->Paste not working).-->OK. A good Internet connection is required. See Photo6.1.
Now onto the path Arduino IDE Tools-->Board-->Boards Manager. In the table that appears, scroll until we find megaTinyCore -->Install. Installation may take some time. See Photo 6.2.
After it is done, in Tools --> Board --> megaTinyCore will appear. Here we will find ATtiny1604, ATtiny3216 and the families they belong to, as well as others. See Photo 6.3.
The desired microcontroller is selected and the programmer is ready to work!
Programming ATtiny1604
This is the "Pin map" that allows us to program this microcontroller under the Arduino environment:
ATtiny1604 pin......................................Arduino IDE reference
- Vcc
2....................................................D0
3....................................................D1
4....................................................D2
5....................................................D3
6....................................................D4
7....................................................D5
8....................................................D6
9....................................................D7
10..................................................UPDI
11..................................................D8
12..................................................D9
13..................................................D10
14 .GND
The pin map is not complete, it only has an illustrative role for the present example. Each pin of the microcontroller can have other functions, defined by the program.
A program that flashes an LED at pin 5 of ATtiny1604 looks like this:
void setup() {
// initialize D3 (ATtiny pin 5) as an output.
pinMode(3, OUTPUT);
}
void loop() {
digitalWrite(3, HIGH); // turn the LED on
delay(1000); // wait for a second
digitalWrite(3, LOW); // turn the LED off
delay(1000); // wait for a second
}
It can be seen that pin 5 of ATtiny1604 is considered D3 (see pin map); is declared output, then raised to 1 logic for aprox. 1 s, lowered to 0 logic for aprox.1 s, after which the cycle repeats.
To program a chip with this sketch, using this programmer, we will connect it to the PC, insert the desired chip into the ZIP socket in the appropriate position , open the Arduino IDE and copy the above program. Then: Arduino IDE-->Tools-->Board-->megaTinyCore-->ATtiny1604, Chip: ATtiny1604. From here, choose the working frequency of the internal oscillator (typically 16MHz), the working port with the PC, possibly other options and then upload sketch from Arduino IDE.
Important! In ArduinoIDE-->Tools-->Board-->Programmer must be "jtag2updi".
The check is done by connecting to pin 5 of the microcontroller a series LED with R=330 ohm, with the cathode towards the ground, powering the assembly with 5V. Can use a breadboard. The LED should blink.
Programming ATtiny3216
This is the "Pin map" that allows us to program ATtiny3216 under the Arduino environment:
ATtiny3216 pin......................................Arduino IDE reference
1.Vcc
2.............................................................D0
3.............................................................D1
4.............................................................D2
5.............................................................D3
6.............................................................D4
7.............................................................D5
8.............................................................D6
9.............................................................D7
10...........................................................D8
11...........................................................D9
12...........................................................D10
13...........................................................D11
14...........................................................D12
15...........................................................D13
16...........................................................UPDI
17...........................................................D14
18...........................................................D15
19...........................................................D16
20.GND
The pin map is not complete, it only has an illustrative role for the present example. Each pin of the microcontroller can have other functions, defined by the program.
A program that flashes an LED at pin 5 of ATtiny3216 is identical to the previous one.
Upload to Arduino UNO is done identically, choosing, obviously, in Boards, ATtiny3216.
The check is done by connecting to pin 5 of the microcontroller a series LED with R=330 ohm, with the cathode towards the ground, powering the assembly with 5V. Can use a breadboard. The LED should blink.