week8_emb_programming.html 31.5 KB
Newer Older
jeffreyalexn's avatar
jeffreyalexn committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Week 8</title>
    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Theme CSS -->
    <link href="css/clean-blog.min.css" rel="stylesheet">
    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-custom navbar-fixed-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header page-scroll">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    Menu <i class="fa fa-bars"></i>
                </button>
                <a class="navbar-brand" href="index.html">HOME</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
           <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="index.html">Home</a>
                </li>
                <li>
                    <a href="about.html">About Us</a>
                </li>
                <li>
                    <a href="assignments.html">Assignments</a>
                </li>
                <li>
                    <a href="machine.html">Machine</a>
                </li>
            </ul>
        </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

    <!-- Page Header -->
    <!-- Set your background image for this header on the line below. -->
jeffreyalexn's avatar
jeffreyalexn committed
64
    <header class="intro-header" style="background-image: url('img/post7.jpg')">
jeffreyalexn's avatar
jeffreyalexn committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                    <div class="post-heading">
                        <h1>Embedded programming</h1>
                        <h2 class="subheading">
                            Week 8</h2>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- Post Content -->
    <article>
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">

                    <header>
                        <h3>CHECK LIST </h3>
                        <blockquote>
                            <p><b>Group assignment</b></p>
                            <ul>
                                <li> compare the performance and development workflows
                                    for other architectures</li>
                            </ul>
                        </blockquote>
                    </header>
                    <hr />
jeffreyalexn's avatar
jeffreyalexn committed
95
                    <h3>Embedded System</h3>
Camilo Ortiz's avatar
Camilo Ortiz committed
96
                    <P style=text-align:justify>An embedded system is a microprocessor-based computer hardware system with software that is designed to perform a dedicated function,
jeffreyalexn's avatar
jeffreyalexn committed
97
98
                        either as an independent system or as a part of a large system. At the core is an integrated circuit designed to carry out computation
                         for real-time operations.</p>
jeffreyalexn's avatar
jeffreyalexn committed
99

jeffreyalexn's avatar
jeffreyalexn committed
100
101
                         <P style=text-align:justify> Complexities range from a single microcontroller to a suite of processors with connected peripherals and networks; from no user interface
                         to complex graphical user interfaces. The complexity of an embedded system varies significantly depending on the task for which it is designed.</p><br>
jeffreyalexn's avatar
jeffreyalexn committed
102
103
104
105
                        <span class="image"><img src="img/w8/4-ATtiny85.jpg" alt="" height="300"/></span></p>
                        <br>

                    <h3>Microprocessor VS Microcontrollers</h3>
Camilo Ortiz's avatar
Camilo Ortiz committed
106
                   <h4>What is Microcontroller?</h4>
jeffreyalexn's avatar
jeffreyalexn committed
107
108
109
110

                        A microcontroller is a chip optimized to control electronic devices. It is stored in a single integrated circuit which is dedicated to performing a particular task and execute one
                         specific application.

Camilo Ortiz's avatar
Camilo Ortiz committed
111
                        It is specially designed circuits for embedded applications and is widely used in automatically controlled electronic devices. It contains memory, processor, and programmable I/O.
Camilo Ortiz's avatar
Camilo Ortiz committed
112
                   </p>
jeffreyalexn's avatar
jeffreyalexn committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
                   <span class="image"><img src="img/w8/MicrocontrollerMicroprocesser.jpg" alt="" height="300"/></span></p>

                   <h4>What is a Microprocessor?</h4>
                    A microprocessor is a controlling unit of a micro-computer wrapped inside a small chip. It performs Arithmetic Logical Unit (ALU) operations and communicates with the other devices connected with it.
                        It is a single Integrated Circuit in which several functions are combined. </p>
                        <br>

                        <table border="0">
                            <strong>KEY DIFFERENCES</strong>
                            <tr>
                                <td width="60%" bgcolor="#81d8d0">
                                   <ul>
                                    <li>Microprocessor consists of only a Central Processing Unit, whereas Micro Controller contains a CPU, Memory, I/O all integrated into one chip.</li>
                                    <li>Microprocessor is used in Personal Computers whereas Micro Controller is used in an embedded system.</li>
                                    <liMicroprocessor uses an external bus to interface to RAM, ROM, and other peripherals, on the other hand, Microcontroller uses an internal controlling bus.></li>
                                    <li>Microprocessors are based on Von Neumann model Micro controllers are based on Harvard architecture</li>
                                    <li> Microprocessor is complicated and expensive, with a large number of instructions to process but Microcontroller is inexpensive and straightforward with fewer
                                         instructions to process.</li>
                                   </ul>
Camilo Ortiz's avatar
Camilo Ortiz committed
132

jeffreyalexn's avatar
jeffreyalexn committed
133
                                </td>
Camilo Ortiz's avatar
Camilo Ortiz committed
134

jeffreyalexn's avatar
jeffreyalexn committed
135
                            </tr>
Camilo Ortiz's avatar
Camilo Ortiz committed
136

jeffreyalexn's avatar
jeffreyalexn committed
137
138
139
140
141
142
143
144
145
146
147
148
                        </table>

                        <h3>Types of Microprocessor</h3></p>

                        <h4>Important types of Microprocessors are:</h4>
                        <ul>
                            <li>Complex Instruction Set Microprocessors</li>
                            <liThe Application Specific Integrated Circuit></li>
                            <li>Reduced Instruction Set Microprocessors</li>
                            <li>Digital Signal Multiprocessors (DSPs)</li>
                            <li>Types of Microcontroller</li>
                        </ul>
Camilo Ortiz's avatar
Camilo Ortiz committed
149

jeffreyalexn's avatar
jeffreyalexn committed
150
151
152
153
154
155
156
157
                         <h4>Here are important types of Microcontroller</h4>
                        <ul>
                            <li>8 bit Microcontroller</li>
                            <li>16 bit Microcontroller</li>
                            <li>32 bit Microcontroller</li>
                            <li>Embedded Microcontroller</li>
                            <li>External memory Microcontroller</li>
                        </ul>
Camilo Ortiz's avatar
Camilo Ortiz committed
158

jeffreyalexn's avatar
jeffreyalexn committed
159
                <hr>
Daniela Felix's avatar
Daniela Felix committed
160
161
                <header>
                    <h3>PROGRAMMING THE ATTINY 1614</h3>
Camilo Ortiz's avatar
Camilo Ortiz committed
162

Daniela Felix's avatar
Daniela Felix committed
163
                </header>
Camilo Ortiz's avatar
Camilo Ortiz committed
164
                <p>Download and install Arduino IDE
Daniela Felix's avatar
Daniela Felix committed
165
166
167
                    <a href="https://www.arduino.cc/en/software">from this site</a>. <br>
                    The Arduino Software (IDE) allows to write programs and upload them to the board.
                </p>
Camilo Ortiz's avatar
Camilo Ortiz committed
168
169
                <p>In order for Arduino IDE to recognize a board connected to the PC, it is required to install the
                    corresponding core for that board's microprocessor. This way, when the board is plugged in, Arduino IDE
Daniela Felix's avatar
Daniela Felix committed
170
                    will detect it and the corresponding port will show under Tools > Port ready to be selected.<br>
Camilo Ortiz's avatar
Camilo Ortiz committed
171
172
                    We used a 3rd party hardware package, so it is first necessary to add the URL of their Boards Manager
                    JSON file in: File > Preferences > Additional Boards Manager URLs. The URLs point to JSON index files
Daniela Felix's avatar
Daniela Felix committed
173
                    that Arduino IDE uses to build the list of available installed boards.<br>
Camilo Ortiz's avatar
Camilo Ortiz committed
174

Daniela Felix's avatar
Daniela Felix committed
175
176
177
178
179
180
                       <span class="image"><img src="img/w8/s8_arduinoIDE1-min.jpeg" alt="" height="300" /></span>
                       <span class="image"><img src="img/w8/s8_arduinoIDE2-min.jpeg" alt="" height="300"/></span>
                       <span class="image"><img src="img/w8/s8_arduinoIDE3-min.jpeg" alt="" height="300"/></span>
                        <span class="image"><img src="img/w8/s8_arduinoIDE4-min.jpeg" alt="" height="300"/></span>
                        <span class="image"><img src="img/w8/s8_arduinoIDE5-min.jpeg" alt="" height="150"/></span>
                        <span class="image"><img src="img/w8/s8_arduinoIDE6-min.jpeg" alt="" height="300"/></span>
Camilo Ortiz's avatar
Camilo Ortiz committed
181

Daniela Felix's avatar
Daniela Felix committed
182
                </p>
Camilo Ortiz's avatar
Camilo Ortiz committed
183
184
                <p>The following site shows step by step how to <b>Make the UPDI Programmer</b> to be able to upload code
                    to the attiny series using the IDE and an Arduino board.
Daniela Felix's avatar
Daniela Felix committed
185
186
187
                    <a href="https://www.electronics-lab.com/project/getting-started-with-the-new-attiny-chips-programming-the-microchips-0-series-and-1-series-attiny-with-the-arduino-ide/">
                        <b>Click here </b></a>
                </p>
Camilo Ortiz's avatar
Camilo Ortiz committed
188
                <p>To transform the Arduino board to a UPDI programmer, we will use the UPDI Arduino sketch created by <i>ElTangas</i>.
Daniela Felix's avatar
Daniela Felix committed
189
                    The sketch converts ATmega328(p)-based Arduino’s, like the Arduino UNO, Nano, and Pro mini, into a UPDI programmer.</p>
Camilo Ortiz's avatar
Camilo Ortiz committed
190
191
                <p>There are two steps to do this. The first step involves <b>transforming an Arduino board to serve as the
                    UPDI programmer</b> while the second part shows <b>how to connect the Attiny to the programmer and
Daniela Felix's avatar
Daniela Felix committed
192
193
194
195
196
197
198
199
                    the Upload process</b>.</p>
                <h4><b>1. Transform an Arduino to a UPDI programmer</b></h4>
                <ol>
                    <li>Close all instances of the Arduino IDE to avoid errors.</li>
                    <li>Download and extract the <b><a href="https://github.com/SpenceKonde/jtag2updi">UPDI programmer sketch</a></b> <br></li>
                    <li>Open the jtag2updi folder after extracting the download. It is important that all the files extracted to be in the same folder.<br>
                        <span class="image"><img src="images/8-embedded_prog/s8_programmer_sketch-min.jpeg" alt="" height="200" /></span></li>
                    <li>Open the sketch jtag2updi.ino and upload it to the Arduino board you will like to use (in this case Arduino UNO).
Camilo Ortiz's avatar
Camilo Ortiz committed
200
                        When you open the code, the .ino file will appear empty and that is fine as all the code is contained in the other files
Daniela Felix's avatar
Daniela Felix committed
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
                        in the same folder as the .ino, but the empty .ino is needed so they can be compiled by the IDE.<br>
                        <ul>
                            <li>Tools> Board > Arduino AVR boards> Arduino Uno</li>
                            <li>Tools> Port> COM4 (Arduino uno)</li>
                            <li>Tools> Programmer AVR ISP>AVR ISP</li>
                            <li>Tools> Programmer jtag2updi> jtag2updi</li>
                        </ul>
                                <span class="image"><img src="img/w8/s8_updi1-min.jpeg" alt="" height="300" /></span>
                                <span class="image"><img src="img/w8/s8_updi2-min.jpeg" alt="" height="300"/></span>
                                <span class="image"><img src="img/w8/s8_updi3-min.jpeg" alt="" height="300"/></span>
                                <span class="image"><img src="img/w8/s8_updi5-min.jpeg" alt="" height="300"/></span>
                    </li>
                    </ol>
                    <h4><b>2. Connecting the Attiny and uploading</b></h4>
                    <p>Connect the ATiny to the Arduino as shown in the schematics below:<br>
                        <span class="image"><img src="img/w8/s8_MinimalConnectionsUPDI-min.png" alt="" height="300" /></span></li></p>
Camilo Ortiz's avatar
Camilo Ortiz committed
217
                    <p>It is important to be aware of the Arduino Uno pinout as well as the attiny, so in order to prevent mistakes this is the
Daniela Felix's avatar
Daniela Felix committed
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
                        pin (Arduino) to pin (Attiny) connection:<br>
                        <span class="image"><img src="img/w8/s8_arduino-UNO-pinout-min.jpg" alt="" height="300" /></span><br>
                        <div class="table-wrapper">
                            <table>
                                <thead>
                                    <tr>
                                        <th>Arduino</th>
                                        <th>Attiny</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>GND</td>
                                        <td>GND</td>
                                   </tr>
                                    <tr>
                                        <td>5V</td>
                                        <td>VCC</td>
                                    </tr>
                                    <tr>
                                        <td>D6</td>
                                        <td>UPDI</td>
                                    </tr>
                                </tbody>
Camilo Ortiz's avatar
Camilo Ortiz committed
242

Daniela Felix's avatar
Daniela Felix committed
243
                            </table>
244
                        </div>
Daniela Felix's avatar
Daniela Felix committed
245
246
247
248
249
250
251
252
253
254
255
256
                            <p>Also add:<br>
                                <ul>
                                    <li>4.7Ω resistance</li>
                                    <li>10uf capacitor</li>
                                </ul>
                            </p>
                            <p>This is the result so far,<br>
                                <span class="image"><img src="img/w8/s8_schematic-min.jpg" alt="" height="200" /></span>
                                <span class="image"><img src="img/w8/s8_schematic2-min.jpg" alt="" height="200" /></span>
                            </p>
                            <hr>
                            <h4>CODE THE ATTINY</h4>
Camilo Ortiz's avatar
Camilo Ortiz committed
257
                            <p>Open or write the code you would like to upload.For this exercise I used the code provided by Adrian on this
Daniela Felix's avatar
Daniela Felix committed
258
259
260
261
262
263
264
                                week, which is avaliable <a href="http://fabacademy.org/2020/labs/leon/students/adrian-torres/week08.html"></a><b>Here</b><br>
                                <span class="image"><img src="img/w8/s8_adrian_code-min.jpeg" alt="" height="200" /></span><br>
                            </p>
                            <p>This was the result:<br>
                                <video src="img/w8/s8_code1.mp4 Video 2021-03-22 at 11.14.18 PM.mp4" width="320" height="240" controls>
                                    Video not supported </video><br>
                            </p>
Camilo Ortiz's avatar
Camilo Ortiz committed
265
                            <p>From Adrian's code I changed some information, for example white leds weren't avaliable at the lab so
Daniela Felix's avatar
Daniela Felix committed
266
267
268
                                I placed blue ones, and also changed the time between them turning on. This was the final code I used:<br>
                                <pre><code>
//Daniela Felix - Fab Academy 2021 - Fab Lab ZOI
Camilo Ortiz's avatar
Camilo Ortiz committed
269
//tiny1614
Daniela Felix's avatar
Daniela Felix committed
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
//
//Original code:Neil Gershenfeld 12/8/19
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge this project. Copyright is retained and
// must be preserved. The work is provided as is; no
// warranty is provided, and users accept all liability.
//
const int ledPin1 = 3;//first light
const int ledPin2 = 6;//white light
const int ledPin3 = 7;//white light
const int ledPin4 = 1;//red light
const int ledPin5 = 2;//red light
const int buttonPin = 0;// button pin
int buttonState = 0;//initial state of the button
int i = 0; //variable intensity led

void setup() { //declaration of inputs and outputs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);// we read the state of the button
if (buttonState == HIGH) { //if we press the button
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
Camilo Ortiz's avatar
Camilo Ortiz committed
300
delay(2000);
Daniela Felix's avatar
Daniela Felix committed
301
digitalWrite(ledPin4, HIGH);
Camilo Ortiz's avatar
Camilo Ortiz committed
302
digitalWrite(ledPin5, HIGH);
Daniela Felix's avatar
Daniela Felix committed
303
delay(2000);
Camilo Ortiz's avatar
Camilo Ortiz committed
304
digitalWrite(ledPin1, HIGH);
Daniela Felix's avatar
Daniela Felix committed
305
delay(5000);
Camilo Ortiz's avatar
Camilo Ortiz committed
306
digitalWrite(ledPin1, LOW);
Daniela Felix's avatar
Daniela Felix committed
307
308
309
delay(1000);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
Camilo Ortiz's avatar
Camilo Ortiz committed
310
311
312
delay(2000);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
Daniela Felix's avatar
Daniela Felix committed
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
delay(1000);

}
else {  //if we don't press the button
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
}
}
                                    </code></pre>
                            </p>
                            <p>This was the result:<br>
                                <video src="img/w8/s8_code2.mp4" width="320" height="240" controls>
                                    Video not supported </video>
                            </p>
                            <p>Verify the code to ensure that there is no error, then go to Tools> Board, and scroll down till you see the ATtiny you are working with on the list and select it.<br>
                                <span class="image"><img src="img/w8/s8_verification-min.jpg" alt="" height="300" /></span>
Camilo Ortiz's avatar
Camilo Ortiz committed
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
                            </p><br>
                            <header>

                      <h3>PROGRAMMING THE ATTINY 44A</h3>
                      </header>
                      <p  class="description">
    										I put two leds in this board to make a blinking led while the other can be activated pressing the button. To program the ATtiny44 I use the USBtinyprogrammer did it in week 4 and Arduino IDE.
    										The following information are the steps to do it.
    									</p>
    									<p  class="description">
    										An important thing to know is that I did not need to upload the bootloader to upload the code to the HelloWorld board so I will skip this part. First you have to download the ATtiny Microcontrollers library, to do it use this
    										<a href="">link</a> where you will find the libraries and the instructions to do it.
    									</p>
    									<img src="img/w8/libraries.png" alt="" >
    									<p  class="description">
    										Once you have the configuration as the image above, please notice that the clock you use depends on two things:
    										<ol>
    											<li>If you have an external crystal/ceramic resonator.</li>
    											<li>If you have burn the fuses to use an external crystal/ceramic resonator.</li>
    										</ol></p>
    										<p  class="description">
    										So if you haven't burn the fuses that means that you are using the internal resonator. I notice this because the blinking timing was not the expecting miliseconds and also because the serial comunnication was not right.
    										Be sure you are setting the right clock in arduino IDE to make things work as expected.
    									</p>
    									<p  class="description">
    										So then you should press the upload button and after waiting some time have the code upload to your board, if you have an error message you have to find wich element it's caussing the problem.
    										I recomend to check some things:
    										<ul>
    											<li>Firts check the setting in Arduino IDE are correct, the PORT where your programmer is connected have to be selected
    												<ul><li>mac OS users should also verify if the device is being reconized clicking on About this mac  --> System Report</li></ul></li>
    												<img class="Img med" src="img/w8/usbReconized.png" alt="" />
    											<li>Be sure the programmer works well, even a loose USB connection can cause the problem.</li>
    											<li>Verify the ISP connection is correct.</li>
    											<li>Verify the cables you are using are good.</li>
    											<li>Check your board, this include soldering, right design, right components, continuity and so on.</li>
    											<li>Try to discard items so you reduce the possible problems list. </li>
    											<li>If you are sure you can program other board with the same programmer and the same enviorment and also check your board and think it's okay you should replace your micro,
    													it could be setting wrong fuses and now it's not enable to communicate anymore until you do a <a href="https://sites.google.com/site/wayneholder/attiny-fuse-reset">fuse reset.</a></li>
    										</ul>
    									</p>
    									<p  class="description">
    										The program I did is a Blink wothout delay. The delay instruction make the microcontroller stop "thinking" while the delay time is going on. That means it can't perform any other action as
    										read sensors, communicate or anything. For this reason you can use this code that replace the delay() and allows the micro keep working on other instructions. In this case I use a blinking LED
    										and whe you press the button another led turns on, but also I decide to try the serial communication in the same code.
    									</p>
    									<p  class="description">
    										Now on purpose of serial communication. This is how it looks when the baud rate/ clock setting is not correct.
    									</p>
    									<img src="img/w8/baud9600.png" alt="" >
    									<img src="img/w8/Serialbad.png" alt="">
    									<p  class="description">
    										As you can see the baud rate on Serial.begin it's not the same as the Serial Monitor on Arduino IDE but it should be, also the symbols are not correct. Here is where I read the clock information in the
    										datasheet I wrote before in this page. So changing the clock to: 1Mhz internal clock in arduino IDE it kind of work but still with problems.
    									</p>
    									<p class="description">
    										Here I decide to burn the fuses to use the external 20Mhz ceramic oscilator integrated in my board.
    									</p>
    									<img  src="img/w8/At2.jpg" height= 400em alt="">
    									<img  src="img/w8/fuses.png" alt="">
    									<p class="description">
    										Then try again the communication. Change in Arduino IDE to external 20Mhz clock upload the program and check.
    									</p>
    									<img src="img/w8/serialOK.png" alt="">
    									<p class="description">
    										The communication are being stablished in the corect baud rate, in the first line there is some noise, that noise could be cause because I'm usig the arduino as a bridge to connect with serial to the computer,
    										that is not the problem, the problem could be the horrible cables in the connection.
    									</p>
    									<img src="img/w8/conexions.jpg" height=600em alt="">
    									<p class="description">
    										This time I didn't have female wires so I have to use that wires and I think that can be the problem.
    									</p>
    									<h2>Hello World Results</h2><br>
    									<img  src="img/w8/BlinkNoDelay.mp4" alt="">
    									<p class="description">
    										This example can be very usefull on a lot of projects, you can learn more obout it searching the explanation of the blinking without delay to more details, and of course you will find the original files at
    										the end of this page.
    									</p>
    									<h3> Original Files </h3><br>
    									<ul>
    										<a href="Original Files/BlinkWithoutDelay_Serial.ino"> <li>Arduino - Blink without delay serial - Code</li> </a>
    									</ul>
Daniela Felix's avatar
Daniela Felix committed
413

414
415
416
417
418
419
420
421
422
                        <br><hr>
                        <h3>PROGRAMMING THE ATTINY45</h3>
                        <h4>Using the Arduino IDE</h4>
                        <p>To program the ATtiny45 chip with the Arduino IDE is important to install the ATtinyCORE, you can follow <a href="https://github.com/SpenceKonde/ATTinyCore/blob/master/Installation.md" target="_blank" rel="noopener noreferrer">this tutorial page</a> to install it. After that you should set the settings as shown on the next image.</p>
                        <img src="./img/w8/ss-arduino-tools-att45.png" alt="Setting use on the arduino IDE to program the ATtiny45" />
                        <p>Using this environment to develop is pretty straight forward. The main things are to set the appropriate board and clock settings from the <samp>tools>board</samp> menu, and then <samp>tools>chip</samp>, is also important to enable the LTO that makes the complied program smaller <samp>tools>LTO>enable</samp></p>
                        <p>Then you write your program as any other Arduino program, be aware that some functions will not work and also you have less flash and RAM memory to work with.</p>
                        <p>Compile your program and set your programmer inside the <samp>tools>programmer>USBtinyISP</samp> menu, make sure your programmer and board are connected, and finally upload your sketch to your microcontroller.</p>
                        <h4>Programming with PlatformIO</h4>
423
                        <img style="width: 100%;" src="./img/w8/ss-plataformio-home.jpg" alt="Screenshot of the PlatformIO extension for VS code" />
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
                        <p><a href="https://platformio.org/" target="_blank" rel="noopener noreferrer">PlatformIO</a> can be installed via a VS code extension, then you can enjoy the benefits of using PlatformIO while having the power of VS code</p>
                        <p>Also, as VS code is more powerful you will get intellisense and code auto completion. Which is always nice and handy, to install it you must go to the extension tab and search for PlatformIO click on install.</p>
                        <p>You will have now an icon for the PlatformIO home, where you can create new project or import form the Arduino IDE. When creating the project you should select which chip you will be targeting and a root folder. In this case the ATtiny45.</p>
                        <p>On the project a file named main.cpp will be created, there you should put your code. You can write normal Arduino Code and C code. To compile and upload you can use the buttons that will be added to the bottom bar or the following commands:</p>
                        <ul>
                        <li><kbd>ctrl+alt+b</kbd> / <kbd>cmd-shift-b</kbd> Build Project</li>
                        <li><kbd>ctrl+alt+u</kbd> Upload Firmware</li>
                        <li><kbd>ctrl+alt+s</kbd> Open Serial Port Monitor</li>
                        </ul>
                        <p>Make sure your programmer is connected to the computer and the board</p>
                        <br>
                        <h4>Using C files</h4>
                        <p>You can use plain C to program you AVR chip, then use the <a href="https://www.microchip.com/en-us/development-tools-tools-and-software/gcc-compilers-avr-and-arm" target="_blank" rel="noopener noreferrer">AVR Toolchain</a> to compile it and generate a .hex file. That you finally upload using <a href="https://www.nongnu.org/avrdude/" target="_blank" rel="noopener noreferrer">avrdude</a>. To edit the code I use VS code, but you can use any editor.</p>
                        <h4>Using Makefiles!</h4>
                        <p>With this type of files used with the <a href="https://www.gnu.org/software/make/" target="_blank" rel="noopener noreferrer">GNU make</a> program you can automate a lot of the compile and uploading tasks of your project. I found this <a href="https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/" target="_blank" rel="noopener noreferrer">great tutorial</a> that makes a step by step breakdown of the Makefile and how it works.</p>
                        <pre><code>target: prerequisites
                            recipe</code></pre>
                        <p>The example above is a basic format for a make rule, you can chain this based on how to make the prerequisites.</p>
                        <code
                        >PROJECT=main.lightsensor <br />
                        $(PROJECT).hex</code
                        >
                        <p>You can also declare variables, on the previous example the project variable is used to name a file .hex with the variable value.</p>
                        <p>Is also a good practice to make a <samp>clean:</samp> recipe that will delete all the generated files and leave the directory clean</p>
                    <hr>
                </div>
            </div>
jeffreyalexn's avatar
jeffreyalexn committed
451
452
        </div>
    </article>
Camilo Ortiz's avatar
Camilo Ortiz committed
453

jeffreyalexn's avatar
jeffreyalexn committed
454
455
456

    <!-- Footer -->
    <footer>
Camilo Ortiz's avatar
Camilo Ortiz committed
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
      <div class="container">
          <div class="row">
              <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                  <ul class="list-inline text-center">

                      <li>
                          <a href="https://www.facebook.com/fablabzoi">
                              <span class="fa-stack fa-lg">
                                  <i class="fa fa-circle fa-stack-2x"></i>
                                  <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
                              </span>
                          </a>
                      </li>
                      <li>
                          <a href="https://www.instagram.com/fablabzoi/">
                              <span class="fa-stack fa-lg">
                                  <i class="fa fa-circle fa-stack-2x"></i>
                                  <i class="fa fa-instagram fa-stack-1x fa-inverse"></i>
                              </span>
                          </a>
                      </li>
                      <li>
                          <a href="https://gitlab.fabcloud.org/academany/fabacademy/2021/labs/zoi/site">
                              <span class="fa-stack fa-lg">
                                  <i class="fa fa-circle fa-stack-2x"></i>
                                  <i class="fa fa-github fa-stack-1x fa-inverse"></i>
                              </span>
                          </a>
                      </li>
                  </ul>
                  <p class="copyright text-muted">Copyright &copy; Fab Academy 2021 ZOI</p>
              </div>
          </div>
      </div>
jeffreyalexn's avatar
jeffreyalexn committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
    </footer>

    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Contact Form JavaScript -->
    <script src="js/jqBootstrapValidation.js"></script>
    <script src="js/contact_me.js"></script>

    <!-- Theme JavaScript -->
    <script src="js/clean-blog.min.js"></script>

</body>

</html>