lunes, 1 de agosto de 2022

4.- PROYECTOS

  You must choose between 3 projects.


1.- The easiest is the light traffic



2.- Secondly the Batman's car


 3.- Following the line




ACTIVITIES


Make your robot (one of these or whatever you want). Then prepare a presentation (less 15 minutes) explaining your project. You can use fotos,, videos or whatever you need.

3.- CONTROLADORA ARDUINO

     Last year we already used the ARDUINO card. This year we are going to use it in a more complex way. First we will use a basic digital output: the LED diode. It is a diode that illuminates when connected in direct polarization. Therefore it is a digital output. It is necessary to connect to the digital pins and define it as an output (OUTPUT). In order for the operation to be optimal, a 220 Ohm resistor must be connected in series with it, except for the PIN 13 that already has it incorporated. The entries will be different In practice 1 the input is time. That although it is a physical input the card itself has, internally, the corresponding sensor. In practice 2 we will use as a digital input a button (INPOUT) that will be connected in PIN 2 and that requires a resistance of 10K. In practice 3 an LDR is used as input. The LDR is a variable resistance with light. More light less resistance. So it is an analog input that should be connected in the analog pins with a resistance of 10K. The last practice is a traffic light and the control is done through the time input that does not require external sensor.




PRACTISEDESCRIPCITIONCIRCUIT

CONEXIONSPROGRAMMRESULT
LED flashingLED flashing in PIN 13


Práctise 1Video 1
Controlling a LED with a push button

When  the button is pushed, the LED lights


Práctise 2Video 2
Controlling a LED with a LDRIf you have poor light the LED lights


Práctise 3Video 3
Controlling light trafficYou have leds to control traffic


Práctise 4Video 4


       

2.- CONCEPTOS BÁSICOS

  The economy of our society is based on the laws of supply and demand in the market and in the productive system. Lowering production costs means reducing prices and making products accessible to more people. The highest cost in production systems is always labor. For this reason, the third industrial revolution is transforming our factories and automating processes. This means reducing labor to a minimum. But it also has a social and human cost. The workers of the future will not develop manual jobs all routine tasks will be replaced by robots. New workers should be able to take care of them. But what is a robot? Outside of what science fiction movies tell us as SUPERHUMAN, robots are simple machines and like any other they present circuits and systems.



Like any other machine, robots have two fundamental systems 1.- STRUCTURAL: That gives them physical form 2.- FUNCTIONAL: That allows to perform the task for which they have been manufactured. A robot can be defined as:
"Multifunctional machine and reprogrammable"
The great advantage of robots is that they can be reused with the same structure and that the same structure can perform different functions depending on the program they incorporate.         But let's start with the most elementary, the structure. From the structural point of view there are two types of robots 1.- MOBILE ROBOTS: A mobile robot is everything that moves. To do this, use legs or wheels. Traditionally it is said that the basic structure has 3 wheels and not 4. Although that is not really important. What is important is that mobile robots must overcome obstacles. And in that task the legs are superior to the wheels. However, larger wheels improve stability and help overcome obstacles.





2.- INDUSTRIAL ROBOTS: Industrial robots are used in warehouses and have a basic structure of links that resembles the human arm. In fact the links are named in the same way. Depending on the type of movement they can be Cartesian, cylindrical and spherica



If we differentiate between robot (capable of anwering from its environment) and automatism (whose task can not be modified), it is clear that the functional system of the robot is very complex. In addition to mechanical systems with a multitude of belts and gears, robots must have a sensorial system. This sensorial system must consist of sensors (inputs) and actuators (outputs). The answer to the environment can be done through a program. Therefore, in all there must be a controller card that will serve as an interface between the physical system and the computer in which a certain program is compiled. In this controller card can not miss 2 important elements 1.- The microcontroller: Electronic circuit that gathers all the functionalities 2.- Memory: In which the orders must be stored. It will be ROM and RAM. Depending on these elements, the controller cards are more or less relevant. There are many in the market. However, let's focus on the ARDUINO ONE. Among other reasons because it has FREE SOFTWARE and a collaborative platform. In addition to being very versatile and economical.

1.- SISTEMAS DE CONTROL

 Control and automations have helped the development of automated industrial processes. However, control systems have a high conceptual component that will be the subject of this teaching unit.

Let's start by defining some of the main components of such systems

1.- FLOOR Set of components and parts that have a certain objective
2.- PROCESS Set of operations that will have a certain purpose.
3.- SYSTEM Combination of components that act together to perform the control
4.- INTERRUPTIONS All unwanted signals involved adversely.
5.- INPUT OF MANDO Excitator signal of the system
6.- REFERENCE SELECTOR Item that is placed to have a reference.
7.- REFERENCE INPUT. Signal produced by the reference selector
8.- CONTROL UNIT. A unit that reacts with an active signal to produce the desired output.
9.-OUT Amount to be maintained
10.- OPEN LOOP CONTROL SYSTEM. System in which the output has no influence on the input.
11.- FEEDBACK ELEMENT. A unit that provides means to increase or decrease the output signal.
12.- ACTIVE SIGNAL. Difference between input and reference.
13.- CLOSED LOOP CONTROL SYSTEM. System in the output affects the input.

The control system regulates and controls the operation of an automation or process so that it works as intended.
We can represent an open loop control system with the following scheme:






In contrast, a closed loop control system can be represented by the following scheme:







In both system we differentiate a number of characteristic elements:

1.- SENSOR OR TRANSDUCTOR: Transforms the physical signal into an electrical signal
2.- COMPARATOR Compares the input signal with the reference signal
3.- CONTROLLER Depending on the signal that arrives decides if the actuator should be activated
4.- ACTUATOR: Changes the output so that there is no error to the input.


Control is one of the foundations of modern engineering. Its theoretical foundations involve knowledge of electronics and mathematics at a high level, since to simplify such systems are used Laplace transforms.

ACTIVITIES

1.- Classify the following systems in open loop and closed loop


Washing machine, fridge and programmed air conditioning

2.- Describe the elements that appear in each of the previous systems

2.- LAS FUNCIONES

En programación se utiliza el concepto matemático de función para compilar programas con C++. Además representan el ejemplo típico de programación modular, en el que cada parte desarrolla un determinado cometido. Analicemos el siguiente ejemplo

#include <stdio.h>
double supt();                                         Definimos la función




main(){
float base;
float altura;
printf("Calcularla superficie de un triangulo");
printf("Introduce la base del triangulo:  %f");
scanf("%f",&base);
printf("\n Introduce la altaura del triángulo:  %f");
scanf("%f",&altura);
printf("\n Superficie:   %lf", supt(base, altura));         Llamada a la función
scanf("lf", &supt);


}


double supt(float ba, float al)             Definición de los parámetros
{
double superficie;
superficie=(ba*al)/2;
return superficie;                  El valor dependiendo de los valores de los parámetros.

}


ACTIVIDADES

1.- Analice el ejemplo anterior y dibuje el correspondiente diagrama de flujo

2.- Diseñe y compile un programa que tenga una función capaz de calcular el volumen de un cilindro a partir del radio de su base y de su altura. 

1.- LOS ARRAYS

 Los arrays o vectores corresponden a un concepto matemático que tiene múltiples aplicaciones en el mundo de las ciencias y la tecnología. Por ello, su utilización en el campo de la programación se ha utilizado para resolver muchos problemas.

Si queremos representar un punto en el espacio podemos utilizar varios tipos de coordenadas. Las cartesianas son las más sencillas. Representan el punto a partir de las distancias en horizontal, vertical y altura con respecto del origen de coordenadas P(x,y,x). Este es el cocepto simple físico y matemático de vector o array. Generalizando dicho concepto se puede definir array como una colección de datos del mismo tipo que se referencian por medio de un nombre y que almacenan la memoria en posiciones contiguas. El número de datos corresponde a su dimensión. Pero en el campo de la programación los arrays no son simples vectores. En realidad son matrices con dimensión (número de columnas, n) y tamaño (número de filas, m). Siendo n su dimensión y n*m su tamño.  De esta forma los datos se almacenan en memoria desde la posición 0 hasta la (n*m)-1.
Hay dos problemas cuando se crean programas utilizando arrays

1.- Definirles como variables        
tipo identificador_array[n]

2.- Llamar a uno de los valores del array
printf("%d",array[3]);



Este es un ejemplo de aplicación de este concepto


#include <iomanip>

int main ()
{
   int t[ 10 ][5]; // n is matiz of 10x5

   // initialize elements of array n to 0          
   for ( int i = 0; i < 10; i++ )
   {
    for( int j=0; j<5; j++){
    t[i][j]=i+j;
     printf("\t %d", t[i][j]);
   }
       printf("\n");
   }




 }

ACTIVIDADES

1.- Analice el ejemplo referido y construya su diagrama de flujo

2.- Diseñe y compile un programa capaz de ordenar una secuencia de 7 números introducidos mediante teclado. (Nota utilice un array para almacenarles y otro para ordenarles).

4.- LOS BUCLES DE PROGRAMACIÓN

 Cualquier programador con conocimientos básicos precisa compilar bucles. Es decir que se repita una o varias acciones hasta que se cumpla una determinada condición. Los ordenadores son máquinas y como tales son capaces de realizar tareas simples sin errores y mucho más rápidamente que los seres humanos. Gracias a los bucles de programación podremos automatizar la mayor parte de las funciones. Pero mucho cuidado en no crear el denominado bucle sinfín. Es preciso que exista alguna forma de salir del bucle y cerrar el programa.

Los bucles pueden consistir en repetir una serie de tareas un determinado número de veces. En estos casos deberán de incluir un contador. Esencialmente un contador es un acumulador n=n+paso. El paso es el incremento que queramos señalizar en nuestro contador. El contador es similar al acumulador en el que el paso sería otra variable. Para evitar utilizar el contador en C++ se puede utilizar ++. Una forma común de bucle que repite según un contador es utilizar for.

for (inicialización; condición; incremento){
acción 1;
....................................
acción n;
}
Cuando se realiza un bucle hasta cumplirse una condición se puede utilizar while.
while (expresión){
acción 1;
.................................
acción n;
}

En este ejemplo se suman 5 números que introducimos mediante teclado.

a) Con WHILE
#include <stdio.h>
main(){
float num, s;
int contador;
s=0;
contador=1;
while (contador<5) { 
printf("Introduce la cifra   ");
scanf("%f", &num);
s=s+num;
contador=contador+1;
}
printf(" La suma es...... %f ", s);
scanf("%f", &s);
}

b) Con FOR


#include "stdio.h"

using namespace std;
main()
{
int numero, suma, contador; 
printf("HALLAREMOS LA SUMA DE 5 NUMEROS  ");
printf("\n  Empezamos......");
for(contador = 0; contador < 5; contador++)
{/*Notemos que escribir contador++ es similar a escribir contador = contador+ 1*/
printf(" INTRODUCE UN NUMERO %d  ", numero);
scanf("%d", &numero);
    suma=suma+numero;
   
}
printf("LA SUMA DE LOS 5 NUMEROS ES %d", suma);


}

ACTIVIDADES

1.- Analice los ejemplos anteriores y construya su diagrama de flujo.

2.- Diseñe y compile un programa que genere los 10 primeros múltiplos del número que usted desee.