Newsletter altLab

2015-07-28 - Nº 13

Editorial

Aqui está a Newsletter Nº 13 no seu formato habitual.

Esta Newsletter encontra-se mais uma vez disponível no sistema documenta do altLab. Todas as Newsletters encontram-se indexadas no link.

Esta Newsletter tem os seguintes tópicos:

Nesta edição iremos falar de circuitos para implementar "level-shifters". Será apresentado um projeto de maker que implementa um jogo de carros numa matriz de 16x16 LEDs - MiniBitRace. O Software open source da semana é o VLC.

jpralves João Alves (jpralves@gmail.com)

O conteúdo da Newsletter encontra-se sob a licença by-nc-sa4.0 Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


Novidades da Semana ^

  • Chrysler recalls 1.4 million cars following hacking scare

    NL13_NS1

    "Fiat Chrysler Automobiles is recalling 1.4 millions vehicles to patch the software exploitation that was found by a group of hackers earlier this week. The company says the recall "aligns with an ongoing software distribution that insulates connected vehicles from remote manipulation, which, if unauthorized, constitutes criminal action.""

  • The Exoskeletons Are Coming

    NL13_NS2

    _"The Japanese company Panasonic announced recently that it will start selling an exoskeleton designed to help workers lift and carry objects more easily and with less risk of injury. The suit was developed in collaboration with a subsidiary company called ActiveLink. It weighs just over 13 pounds and attaches to the back, thighs, and feet, enabling the wearer to carry 33 pounds of extra load. The device has been tested by warehouse handlers in Osaka, Japan, and is currently in trials with forestry workers in the region."

  • Microchip Adds Two New PIC MCU Families

    NL13_NS3

    "Microchip Technology Inc. (NASDAQ: MCHP), a leading provider of microcontroller, mixed-signal, analog and Flash-IP solutions, today announced from ESC Silicon Valley two new 8-bit families that expand its growing portfolio of innovative PIC® MCUs with Core-Independent Peripherals (CIPs). 8-bit MCUs can now be used in a much broader range of applications, due to the growing number of these intelligent, interconnected CIPs that combine to perform functions autonomously, without the core. Because these functions are deterministically and reliably performed in hardware instead of software, CIPs enable system performance that is far beyond typical 8-bit MCUs while simplifying the design experience and reducing memory cost. Additionally, these two new families are available in 8 to 40-pin packages, reducing board space while serving a wide 1.8 to 5.5V operating range. Both families offer the Peripheral Pin Select feature, which enables flexible pin mapping and PCB routing to minimize EMI and crosstalk. Example applications include consumer electronics, the Internet of Things (IoT), wearable technology and safety-critical systems."


Ciência e Tecnologia ^

  • A solar-energy storage cell that works at night

    NL13_CT1

    "A University of Texas at Arlington materials science and engineering team has developed a new energy cell that can store large-scale solar energy even when it’s dark. The innovation is an advancement over the most common solar energy systems that rely on using sunlight immediately as a power source. Those systems are hindered by not being able to use that solar energy at night or when cloudy conditions exist. The UT Arlington team developed an all-vanadium photo-electrochemical flow cell that allows for efficient and large-scale solar energy storage even at nighttime. The team is now working on a larger prototype."

  • Robotic Construction Gets Fancy at ETH Zurich's Digital Fabrication Lab

    NL13_CT2

    "The use of building materials with unpredictable geometries, such as raw quarry stones or recycled concrete rubble, is a challenge for the traditions of digital fabrication. This research work focuses on developing advanced three-dimensional scanning of materials, real-time analysis, and digital robotic fabrication that is able to respond to such irregular materials. The goal for this research is therefore to define an innovative and environmentally sound building system that foregoes traditional binding materials, reinforcement systems and formwork."

  • After 85-year search, massless particle with promise for next-generation electronics discovered

    NL13_CT3

    "An international team led by Princeton University scientists has discovered an elusive massless particle theorized 85 years ago. The particle could give rise to faster and more efficient electronics because of its unusual ability to behave as matter and antimatter inside a crystal, according to new research. The researchers report in the journal Science July 16 the first observation of Weyl fermions, which, if applied to next-generation electronics, could allow for a nearly free and efficient flow of electricity in electronics, and thus greater power, especially for computers, the researchers suggest."


Cursos MOOC ^


Modelos 3D ^

Com a disponibilidade de ferramentas que permitem dar azo a nossa imaginação na criação de peças 3D e espaços como o thingiverse para as publicar, esta rubrica apresenta alguns modelos selecionados que poderão ser úteis.

Stylish (?) and a little bit Startrekesque soldering iron holder (http://www.thingiverse.com/thing:243415)

Modelos3D_1_IronStand

I had enough of burning my desk and reducing to ashes half of my office because the cheapo soldering iron from my local hardware shop did not have anything to rest on. So i did this...not on purpose (i wanted something to be printed fast...), it kind of look like some Startrek stuff..

Compact Tool Holder (http://www.thingiverse.com/thing:939630)

Modelos3D_2_CompactToolHolder

A little wall mount tool holder that I made. Goal was to hold as many of my tools as possible while staying small enough to mount to the back of my work bench.

EllerSCAD Maze Generator (http://www.thingiverse.com/thing:942566)

Modelos_3D_3_ellerscad

Pure OpenSCAD maze generator using Eller's algorithm.


Open Source ^

VLC media player

OpenSource_VLC

Hoje vamos analisar o VLC. Trata-se de uma aplicação que permite abrir todo o tipo de ficheiros de audio e video. Originalmente criado em 1996 como um projeto académico tornou-se num produto open source em 1998 tendo sido reescrito de raiz nessa altura. É atualmente gerido pela VideoLAN que é uma entidade sem fins lucrativos.

Trata-se de uma ferramenta escrita em C, C++ (com a Framework QT), Objective-C e Lua.

Encontra-se atualmente na versão 2.2.1 e pode ser descarregada a partir deste link.

OpenSource_VLC_screenshot

As principais funcionalidades desta ferramenta são:

  • Suporte em múltiplas plataformas inclusive as móveis:
    • Linux, Windows, OS X, BSD, BeOS, Solaris, Android, IOS, Etc.
  • Suporte de leitura:
    • Formatos contentores:
      • 3GP, ASF, AVI, DVR-MS, FLV, Matroska, MIDI, QuickTime File Format, MP4, Ogg, OGM, WAV, MPEG-2 (ES, PS, TS, PVA, MP3), AIFF, Raw audio, Raw DV, MXF, VOB, RM, DVD-Video, VCD, SVCD, CD Audio, DVB
    • Formatos de Vídeo:
      • Cinepak, Dirac, DV, H.263, H.264/MPEG-4 AVC, H.265/MPEG HEVC, HuffYUV, Indeo 3, MJPEG, MPEG-1, MPEG-2, MPEG-4 Part 2, RealVideo 3&4, Sorenson, Theora, VC-1, VP5, VP6, VP8, VP9, DNxHD, ProRes e alguns WMV
    • Formatos de Áudio:
      • AAC, AC3, ALAC, AMR, DTS, DV Audio, XM, FLAC, It, MACE, Mod, Monkey's Audio, MP3, Opus, PLS, QCP, QDM2/QDMC, RealAudio,Speex, Screamtracker 3/S3M, TTA, Vorbis, WavPack, WMA (WMA 1/2, WMA 3 parcialmente).
    • Subtítulos:
      • DVD-Video, SVCD, DVB, OGM, SubStation Alpha, SubRip, Advanced SubStation Alpha, MPEG-4 Timed Text, Text file, VobSub, MPL2, Teletext.
    • Protocolos de rede:
      • UDP, RTP (unicast ou multicast), HTTP, FTP, MMS, RTSP, RTMP, RSS/Atom
    • Formatos de Stream de rede:
      • RTP/RTSP ISMA/3GPP PSS, Windows Media MMS, Flash RTMP, MPEG Transport Stream, Apple HLS, MPEG DASH
    • Dispositivos de Captura:
      • Video4Linux (em Linux), DirectShow (em Windows), Desktop (screencast), Digital TV (DVB-C, DVB-S, DVB-T, DVB-S2, DVB-T2, ATSC, Clear QAM)
  • Suporte de escrita:
    • Formatos contentores:
      • ASF, AVI, FLV, Fraps, MP4, Ogg, WAV, MPEG-2 (ES, PS, TS, PVA, MP3), MPJPEG, FLAC, QuickTime File Format, Matroska, WebM
    • Formatos de Vídeo:
      • H.263, H.264/MPEG-4 AVC, H.265/MPEG-H HEVC, MJPEG, MPEG-1, MPEG-2, MPEG-4 Part 2, VP5, nVP6, VP8, VP9, Theora, DV, Dirac
    • Formatos de Áudio:
      • AAC, AC-3, DV Audio, FLAC, MP3, Speex, Vorbis
    • Protocolos de Streaming:
      • UDP, HTTP, RTP, RTSP, MMS
  • Suporte de diversos filtros:
    • Deinterlace, Cropping, Image Wall, Image Adjust, Rotate/Mirror, Logo Overlay, Magnification, Image Distortion, Bluescreen, RSS/Atom Feeds, Visualizaton Effects , Equalizer
  • Suporte de diversos interfaces:
    • Qt4, Skins, Web, Telnet, CommandLine, Mouse gestures
  • Funcionalidades adicionais:
    • Anúncios de SAP/SDP
    • Protocolo Bonjour
    • Plugin de Mozilla/Firefox
    • Localização
    • CD-Text
    • CDDB CD Info
    • IGMPv3
    • IPv6
    • MLDv2
    • SVCD Menus
    • Aceleração de CPU com extensões especificas do Processador (MMX, MMXEXT, SSE, SSE2, 3D Now! e AltiVec)

Links úteis:


Circuitos ^

Aqui é apresentado um circuito simples que poderá ser construído com componentes.

Level Shifter

Circuitos_1

Cada vez mais, quando estamos a desenhar um circuito, encontramos componentes que funcionam com tensões diferentes das do micro-controlador. Isto obriga a que para que os mesmos possam comunicar seja necessário implementar um "level shifter", ou seja, assegurar que existe uma transição entre tensões dos componentes.

Foram implementados dois circuitos, um para a comunicação RX/TX e o outro para o bus I2C/TWI. No primeiro caso trata-se de um level-shifter unidirecional e no segundo caso um level-shift bidirecional.

No primeiro circuito a parte mais complexa de fazer é assegurar que a tensão baixa sobe o suficiente para garantir que o que é considerado a 1 na lógica de 3.3V também é considerada a 1 na lógica de 5V (TX de 3.3V para 5V). No sentido oposto a solução é mais simples podendo ser usado um divisor de tensão com resistências (RX de 5V para 3.3V).

No segundo circuito (baseado no trabalho de Jim Hagerman) cada uma das linhas do Clock (SCL) e de Data (SCA) é convertida através do uso de dois transístores NPN e duas resistências. O circuito acrescenta uma resistência adicional para controlar se o sinal está ou não ativo (ENABLE).

Existem já placas especificamente preparadas para fazer este trabalho, no entanto os circuitos apresentados são suficientemente simples para ser implementados com poucos componentes e de forma rápida.

Esquemático

Circuitos_3_Schematics

Componentes (BOM):

Circuito 1:

  • 2x NPN Transístor 2N2222 (Q1 e Q2)
  • 5x Resistência de 1K Ohms (R1 a R4 e R6)
  • 1x Resistência de 2K Ohms (R5)

Circuito 2:

  • 6x Resistência de 10k Ohms (R7 a R12)
  • 4x NPN Transístor 2N2222 (Q3 a Q6)

Pin-out dos IC

Circuitos_4_Pinout

Links úteis:


Artigo do Maker ^

Projeto interessante publicado por um maker.

MiniBitRace

O projeto de maker da semana foi criado pelo Aron Bordin e é um pequeno jogo que usa uma matriz de 16x16 LED. Os detalhes do mesmo encontram-se publicados no site do Byte::Debugger();.

ArtigoMaker_1_MiniBitRace

O vídeo publicado no youtube apresenta o projeto a funcionar.

Items

Para que o projeto seja construído são necessários os seguintes componentes:

  • um Arduino
  • Matriz de 16×16 LED
  • 2x Botões
  • 2x Resistências de 8.2K Ohms

Proceder à ligação da Matriz 16x16 LED à placa Arduino, como é apresentado na imagem. Usando os pinos indicados. Em vez de ir buscar o GND e os 5V da placa, podem ir buscar os mesmos à breadboard.

ArtigoMaker_2_led1616

Agora proceder à ligação dos botões de toque:

ArtigoMaker_3_arduino_bb

Bibliotecas

Para a programação deste projeto foram usados dois módulos disponibilizados pela Framework .PNG Arduino

Código

O Código encontra-se disponível no GitHub

/**
 *  
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// required libraries
#include "LedMatrixObject.h"
#include "Timer.h"

// default pins
#define btnLeft     3
#define btnRight    2

// .PNG Arduino Framework objects

LedMatrixObject *led = new LedMatrixObject(12, 11, 10, 9, 8, 7, 6, 5);
Timer *fps = new Timer(1/30); //game with 30fps


unsigned char  Logo[16][16] = {
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,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 1},
    {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0},
};


// game variables

unsigned long deadTime = millis(); // time that the player dies
bool isHome = true; // display the homescreen 
bool isLogo = true; // display the homescreen 
int heroX = 5; //start the hero in the center of the screen
float vSpeed = 0.05;
float borderPos = 0;
bool pressed = false; //indicates if there is a button pressed
// positions of the enemies
int enemyX[2] = {5, 10};
float enemyY[2] = {0, -8};

/**
 * Setup basic game arduino items and start the game loops
 */
void setup(){
    Serial.begin(9600);
    pinMode(btnLeft, INPUT);
    pinMode(btnRight, INPUT);

    // start the game update loop

    fps->setOnTimer(&gameUpdate);
    fps->Start();

}

/**
 * Updates the player position
 * @param  {int} int d             player direciton. 0 keep, -1 left, 1 right
 */
void goDirection(int d){
    if(d > 0 && heroX < 12)
        heroX += d;
    if(d < 0 && heroX > 3)
        heroX += d;
}


/**
 * Draws the hero car in the screen
 * Hero looks like:             
 *               *
 *              ***
 *               *
 *              ***
 *  HeroX indicates the middle px in the bottom of the car
 */
void drawHero(){
    led->setLedOn(15, heroX);
    led->setLedOn(15, heroX + 1);
    led->setLedOn(15, heroX - 1);
    led->setLedOn(14, heroX);
    led->setLedOn(13, heroX);
    led->setLedOn(13, heroX + 1);
    led->setLedOn(13, heroX - 1);
    led->setLedOn(12, heroX);
}

/**
 * Draw road edges
 */
void drawBorder(){
    byte i;
    if(borderPos > 1){
        i = 1;
    } else {
        i = 0;
    }
    if(borderPos > 2)
        borderPos = 0;
    for(i; i < 16; i += 2){
        led->setLedOn(i, 1);
        led->setLedOn(i, 14);
    }
}

/**
 * Update entities positions in the scene
 */
void updatePos(){
    borderPos += vSpeed;

    for(byte e = 0; e < 2; e++){
        enemyY[e] += vSpeed;
        if(enemyY[e] > 18){
            enemyY[e] = -1;
            if(random(2))
                enemyX[e] = 5;
            else
                enemyX[e] = 10;
        }
    }
}

/**
 * restore default values
 */
void restartGame(){
    heroX = 5;
    borderPos = 0;
    pressed = false;
    enemyX[0] = 5;
    enemyX[1] = 10;
    enemyY[0] = 0;
    enemyY[1] = -8;
}

/** Dies */
void heroDie(){
    deadTime = millis();
    isHome = true;
    restartGame();
}

void checkCollisions() {
    for(byte e = 0; e < 2; e++){
        int ex = enemyX[e], ey = (int)enemyY[e];
        int diffX = abs(heroX - ex); 

        if(ey >= 13 && diffX <= 2){
            heroDie();
        }
    }
}

/** Draw enemies in the scene
    Enemy looks like: 

                 ***
                 ***
                  *
    The position of the enemy indicates the * in the bottom
 */
void drawEnemies(){
    for(byte e = 0; e < 2; e++){
        byte y = (byte) enemyY[e];
        byte x = (byte) enemyX[e];

        if(y >= 0 && y <= 15)
            led->setLedOn(y, x);
        if(y - 1 >= 0 && y - 1 <= 15){
            led->setLedOn(y - 1, x); 
            led->setLedOn(y - 1, x - 1); 
            led->setLedOn(y - 1, x + 1); 
        }
        if(y - 2 >= 0 && y - 2 <= 15){
            led->setLedOn(y - 2, x - 1); 
            led->setLedOn(y - 2, x + 1); 
            led->setLedOn(y - 2, x); 
        }
    }
}



/**
 * Check collisions and update game entities
 */
void gameUpdate(){
    updatePos();
    checkCollisions();

    drawHero();
    drawEnemies();
    drawBorder();

    led->draw();
}

/**
 * Arduino loop. If game is running, just keep the game loop running.
 * Otherwise shows the homescene
 */
void loop(){
    int direction = 0; //player direction. 0 keep pos, -1 go left, +1 go right

    if(digitalRead(btnRight))
        direction = -1;
    else if (digitalRead(btnLeft))
        direction = 1;

    if(isLogo){
        led->setScene(Logo);
        led->draw();

        if(millis() - deadTime > 5000)
            isLogo = false;
    } else {

        if(isHome) {
            led->setScene(Home);
            led->draw();

            if(direction != 0 && millis() - deadTime > 1000)
                isHome = false;
        } else {
            if(!pressed)
                goDirection(direction);
            fps->Update();
        }

        if(direction == 0){
            pressed = false;
        } else {
            pressed = true;
        }
    }
}

Agora é só compilar o código e fazer o upload do mesmo para o Arduino e Jogar!

Outros artigos/projetos interessantes de ler:


Compras ^

Artigos do ebay ou de outras lojas online que poderão ser úteis em projetos.

16x16 LED Lattice Screen 16*16 Dot-Matrix Infinite Cascade Compatible LCD12864

(http://www.ebay.co.uk/itm/400375652285) - £6.81

Compras_1

Features:

  • Working Voltage: DC5v;
  • Principle: Each row consists of two 74HC138 decoder composed of 4-16 + transistor drive; each column cascade driven by the two 74HC59; when the line output high, low cross point of the column output LED is lit;
  • Interface compatible with 12864LCD;
  • Provide 51 & Arduino code.
  • Red LED

Package Include:

  1. the jumper cap x5;
  2. dot matrix module x1;
  3. 8P data cable x1;
  4. the power supply DuPont line X2;
  5. the output of the input data port pin x1;
  6. LCD12864 interface pin (depending on their needs welding) x1;
  7. antistatic packaging

Useful 100PCS Mini 6x6x5mm Through-Hole 4pin Push Button Switch Momentary

(http://www.ebay.co.uk/itm/271659243456) - £0.99

Compras_2

Description:

  • 100% New & High Quality.
  • Feature momentary contact, 4 pins, round black push button, through hole mounting, 6x6x5mm size, etc.
  • Used in the fields of electronic products, household appliances and more.
  • High precision mechanism design offers acute operation and long service life.
  • Current Rating: 50mA
  • Voltage Rating: 2VDC
  • Insulating Resistance: >100M ohm 250V DC
  • Withstand Voltage: 250V AC in 1 minute
  • Contact Resistance: <100m ohm
  • Soldering Temperature: 240 deg C Max in 3 seconds
  • Mechanical Life: >100,000 Cycles
  • Electrical Life: >100,000 Cycles
  • Ambient Temperature: -25 deg C ~ +70 deg C
  • Ambient Humidity: <85 %RH
  • Operating Force: 180 +/- 50 gf

Package includes:

  • 100Pcs 6x6x5mm DIP Through-Hole 4Pin Tactile Push Button Switch Momentary

100pcs 1/4W 1K Metal Film Resistor

(http://www.ebay.co.uk/itm/400945860293) - £0.99

Compras_3

Features:

  • Tolerance: +/- 1 %
  • 1K
  • Type: Metal Film
  • Quantity:100pcs

Package including:

  • 1x100pcs 1K Metal Film Resistor

That's all Folks!