Commit 294007d6 authored by Camilo Ortiz's avatar Camilo Ortiz
Browse files

camilo w8

parent 908b8bb4
Pipeline #221053 passed with stage
in 10 seconds
#include <MillisTimer.h>
#include<SoftwareSerial.h>
const int rx=1;
const int tx=0;
SoftwareSerial Serial(rx,tx);
const int button=2;
const int red=3;
int redState=LOW;
const int blue=4;
int blueState=LOW;
int cont=0;
bool a= false;
int lectura;
int interval=500;
unsigned long prev_ms=0;
unsigned long current_ms=0;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(button, INPUT);
pinMode(tx, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
current_ms= millis();
lectura=digitalRead(button);
Serial.println(lectura);
Serial.println("hola");
if(lectura==HIGH)
{
digitalWrite(blue,LOW);
}
else
{
digitalWrite(blue,HIGH);
}
if(current_ms - prev_ms >= 500 )
{
prev_ms = current_ms;
if(redState==LOW)
{
redState=HIGH;
}
else
{
redState=LOW;
}
digitalWrite(red,redState);
}
}
......@@ -93,7 +93,7 @@
</header>
<hr />
<h3>Embedded System</h3>
<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,
<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,
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>
......@@ -103,12 +103,12 @@
<br>
<h3>Microprocessor VS Microcontrollers</h3>
<h4>What is Microcontroller?</h4>
<h4>What is Microcontroller?</h4>
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.
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.
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.
</p>
<span class="image"><img src="img/w8/MicrocontrollerMicroprocesser.jpg" alt="" height="300"/></span></p>
......@@ -129,11 +129,11 @@
<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>
</td>
</tr>
</table>
<h3>Types of Microprocessor</h3></p>
......@@ -146,7 +146,7 @@
<li>Digital Signal Multiprocessors (DSPs)</li>
<li>Types of Microcontroller</li>
</ul>
<h4>Here are important types of Microcontroller</h4>
<ul>
<li>8 bit Microcontroller</li>
......@@ -155,40 +155,40 @@
<li>Embedded Microcontroller</li>
<li>External memory Microcontroller</li>
</ul>
<hr>
<header>
<h3>PROGRAMMING THE ATTINY 1614</h3>
</header>
<p>Download and install Arduino IDE
<p>Download and install Arduino IDE
<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>
<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
<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
will detect it and the corresponding port will show under Tools > Port ready to be selected.<br>
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
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
that Arduino IDE uses to build the list of available installed boards.<br>
<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>
</p>
<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.
<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.
<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>
<p>To transform the Arduino board to a UPDI programmer, we will use the UPDI Arduino sketch created by <i>ElTangas</i>.
<p>To transform the Arduino board to a UPDI programmer, we will use the UPDI Arduino sketch created by <i>ElTangas</i>.
The sketch converts ATmega328(p)-based Arduino’s, like the Arduino UNO, Nano, and Pro mini, into a UPDI programmer.</p>
<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
<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
the Upload process</b>.</p>
<h4><b>1. Transform an Arduino to a UPDI programmer</b></h4>
<ol>
......@@ -197,7 +197,7 @@
<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).
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
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
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>
......@@ -214,7 +214,7 @@
<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>
<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
<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
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">
......@@ -239,9 +239,9 @@
<td>UPDI</td>
</tr>
</tbody>
</table>
<p>Also add:<br>
<ul>
<li>4.7Ω resistance</li>
......@@ -254,7 +254,7 @@
</p>
<hr>
<h4>CODE THE ATTINY</h4>
<p>Open or write the code you would like to upload.For this exercise I used the code provided by Adrian on this
<p>Open or write the code you would like to upload.For this exercise I used the code provided by Adrian on this
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>
......@@ -262,11 +262,11 @@
<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>
<p>From Adrian's code I changed some information, for example white leds weren't avaliable at the lab so
<p>From Adrian's code I changed some information, for example white leds weren't avaliable at the lab so
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
//tiny1614
//tiny1614
//
//Original code:Neil Gershenfeld 12/8/19
// This work may be reproduced, modified, distributed,
......@@ -297,19 +297,19 @@ buttonState = digitalRead(buttonPin);// we read the state of the button
if (buttonState == HIGH) { //if we press the button
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
delay(2000);
delay(2000);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin5, HIGH);
delay(2000);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin1, HIGH);
delay(5000);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin1, LOW);
delay(1000);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
delay(2000);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
delay(2000);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
delay(1000);
}
......@@ -329,15 +329,94 @@ digitalWrite(ledPin5, LOW);
</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>
</p>
</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>
<hr>
</div>
</article>
<!-- Footer -->
<footer>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment