1. Luces led. / 1.Led lights.

En este ejercicio, necesitábamos programar a Piero en Simulink usando Simulink Blocks. Nuestro objetivo era hacer que el pulso de luz led o mantenerse continuo en un color determinado depende del valor constante.

 

 ENGLISH VERSION

In this exercise, we needed to program Piero in Simulink using Simulink Blocks. Our target was to make the led light pulse or stay continuous in a given colour depends on the constant value.

 

Desbloqueo / Introduction

Nuestro primer ejercicio fue programar a Piero de la siguiente manera:

A partir de un número constante que proporcionamos, necesitamos hacer el número binario. El rango para el número constante es de 0 a 15, de esa manera obtenemos los 4 bits:

Si el bit más antiguo es 1, la luz emitirá un pulso, pero si es 0, recordará continuamente. Es diferente con otros bits: si el bit específico es 1, se iluminará el color que indica, de lo contrario, se apagará.

baza_spg.png.1

 

ENGLISH VERSION

 

Our first exercise was to program Piero in the following way:

From a constant number, which we provide, we need to do the binary number. The range for constant number is from 0 to 15 - that way we get the 4 bits:

If the oldest bit is 1 then the light will pulse, but if it is 0 it will remind continuous. It's different with other bits - if the specific bit is 1 the colour that it indicates will light up, if not it will be turned off.

baza_ang.png.2

1.1 Bloques Simulink. / 1.1 Simulink Blocks.

 

 

15.png1. En primer lugar, estamos eligiendo el número constante por el bloque Constante. En  este ejemplo, elegimos 15.

 

 

 

 

bin.png

 

 2. Después de eso, hay BitWise Operator. El bloque Bitwise Operator realiza la operación bit a bit que se especifica en uno o más operandos. En esta situación, utilizamos para un solo operando. Cada rama es para otro.

 

 

 

 

 

 

 

 

 

 

 

 

 

3. En esta sección usamos:

  • Switch Block – el bloque que pasa a través de la primera entrada o la tercera entrada en función de la condición de la segunda entrada.
  • Pulse Generator – genera una señal de pulso.
  • Constant – genera un valor constante real.
  • Logical Operator - realiza la operación lógica en sus entradas. Eso significa que es VERDADERO (1) si ambas entradas son VERDADERAS (1).

pulsy.png

 

4. Al final estamos enviando la salida del Bloque Operador Lógico a los pines por el Digital Output Block desde la Biblioteca Arduino. El pin 49 está conectado al pin rojo, el pin 51 está conectado al verde y el pin 53 está conectado al azul. También el bloque Scope es para verificar las señales.

 cale.png

 ENGLISH VERSION

 

15.png1. Firstly we are choosing the constant number by Constant block. In this example, we chose 15.

 

 

 

 

bin.png

 

2. After that, there are BitWise Operators. The Bitwise Operator block performs the bitwise operation that is specified on one or more operands. In this situation, we used for one operand. Every branch is for other.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3. In this section we used :

  • Switch Block – the block which passes through the first input or the third input based on the condition of the second input.
  • Pulse Generator – generates a pulse signal.
  • Constant – generates a real constant value.
  • Logical Operator - performs the logical AND operation on its inputs. That means that it is TRUE(1) if both inputs are TRUE (1).

pulsy.png

4. At the end, we are sending the output of the Logical Operator Block to pins by Digital Output Block from Arduino Library. Pin  49 is pin connected to red, pin 51 is connected to green and pin 53 is connected to blue. Also, the Scope block is for checking the signals.

cale.png

 

1.2 Resumen. / 1.2 Summary

El programa funcionó sin ningún problema. Al principio traté de hacerlo de otra manera, pero resultó que este es más fácil y más eficiente. Aprendí a usar BitWise Operator y Switch Block. También he dominado mejor la construcción del Piero.

 

ENGLISH VERSION

The program worked without any problems. At first, I tried to do it other way but it turned out that this one is easier and more efficient. I have learned how to use the BitWise Operator and Switch Block. I have also mastered better the construction of the Piero.