Sunday, 9 December 2012

Flashing de um Atmega novo

Quando tentei flashar um Atmega 8 novo usando o USBASP, o avrdude não consegui-o obter a assinatura do dispositivo, lançado a seguinte mensagem:
avrdude: error: programm enable: target doesn't answer. 1
Por defeito todos os atmega novos estão configurados para usar o oscilador interno, que é demasiado lento para o sinal de SCK do USBASP.

Mas existe uma opção para resolver o problema que consiste em activar a opção de SCK lento, conectando o pino 25 do Atmega8 do USBASP à massa, assim obtém-se a seguinte mensagem executado o comando de leitura do dispositivo:
avrdude: Device signature = 0x1e9307
Comando de leitura da assinatura: 
sudo avrdude -c usbasp -p m8

Comando para flashar o Atmega 8 para usar o oscilador de cristal de 12 MHz: 
sudo avrdude -c usbasp -p m8 -U lfuse:w:0xde:m -U hfuse:w:0xd9:m 

Os fusíveis podem ser calculados com a ajuda deste site, o start time escolhido não foi o maior que era possível, parece ser boa prática escolher o tempo mais longo para que o sinal gerado durante o arranque esteja o mais estável possível.

Saturday, 18 February 2012

Lowpoly human brain texturing

PT: Criação do mapa de relevo para um modelo de baixa resolução de um cérebro em Blender 2.6X.
EN: Creating the bumpmap for a lowpoly brain model in Blender 2.6X.

Download or click on View Image to see full-size version
PT
  1. Modelo de baixo detalhe criado a partir de uma referência encontrada na wikipedia;
  2. Pintar os relevos do cérebro no modelo usando a opção de edição Texture Paint na 3D View; 
  3. Mapa da textura não organizada(o mapa UV foi feito com o auto-unwrapping, não é recomendável eu é que fui perguiçoso ... :P );
  4. Mapa da textura reorganizada (criar uma nova camada de mapeamento UV, criar os seams necessários e unwrap, usar Render > Bake > Texture gerar então a textura reorganizada); Desfocar a textura pouco para suavizar a pintura;
  5. Adicionar os modificadores de multires e displace; No displace usar nova textura para deformar a geometria e depois carregar em Apply, isto vai transferir a deformação para o multires;
  6. Colocar o preview do multires em zero e ir ao separador Render > Bake > Normals para transferir os normais para uma textura;
  7. Mapa da textura de relevo gerada;
  8. Previsualização em tempo real do modelo com as texturas criadas.
EN
  1. Lowpoly model created from a wikipedia reference;
  2. Paint brain relief using Texture Paint editing option in the 3D View;
  3. Unsorted texture map (the uvmapping was made with auto-unwrapping because i was too lasy ... :P );
  4. Fixed texture map with a new uv layout, the texture was created using the Render > Bake > Texture feature; The texture should be blurred a bit to smooth the painting;
  5. Add multires & displace modifiers; On displace modifier use the new texture to displace the geometry, then press on the Apply Button to merge the displace modifier with the multires;
  6. Set the preview on Multires to zero and go to Render > Bake > Normals to generate the bumpmap;
  7. The generated bumpmap texture;
  8. Profit :) !

Tuesday, 14 February 2012

Sawtooth oscilator

This is a small sawtooth (almost) oscillator circuit which I have been tweaking the last weeks to generate a reasonably decent 100kHz waveform at Vcc=5V. It was based on some random schematic on the web, which didn't generated the output from 0V to Vcc, so I added a few more components and changed a few parts.

Circuit schematic
Assembled circuit
Oscilloscope signal capture

Basically it charges a capacitor (C1) and uses the 555 comparators to trigger the discharge via other PNP transistor(Q2). The triggering voltage is calibrated with the POT_2 and the capacitor fill time is calibrated with the POT_1.

It has a few glitches which didn't appeared on the simulation and neither on the breadboard(parasite capacitances FTW), but I also used some BC560 instead of the BC557.

Friday, 22 April 2011

USBasp & Noise Troubles

USBasp is a small circuit to flash atmel processors which uses the USB port, but since the USB communication isn't a feature available in the processor by default, it must use the V-USB firmware/drivers to deal with it.
Never ever do this for the USB data lines !
After assembling the circuit i had a few problems trying to understand why it did work on a older machine and didn't work on my recent laptops, using dmesg on the newer laptops I got these messages:

[ 7486.876197] usb 3-2: device descriptor read/64, error -71
[ 7487.105059] usb 3-2: device descriptor read/64, error -71
[ 7487.320153] usb 3-2: new low speed USB device using uhci_hcd and address 4
[ 7487.441052] usb 3-2: device descriptor read/64, error -71
[ 7487.664184] usb 3-2: device descriptor read/64, error -71

And with the older machine using the lsusb command:
Bus 003 Device 016: ID 16c0:05dc VOTI shared ID for use with libus

It seems the usb controler was unable to read the device description, but after an week and some google searches i found that the electromagnetic interference affects a lot with the circuit. To reduce this problem i rewired the circuit and replace the usb port with a short usb male cable instead of the female port and the problem was fixed. (And the circuit also works fine with an usb extension cable)

Rewired version

Back wiring
It appears that the Intel USB controller is more exigent with the quality of the signal than the SiS controller !

Ubuntu/Linux Commands

A list of useful commands which i keep forgetting :

Misc
sudo su // Change user to root

Installers
sudo apt-get install build-essential // C++ support
sudo apt-get install freeglut3-dev // FreeGLUT and OpenGL support
sudo apt-get install avrdude // AVR firmware upload tool
sudo apt-get install gcc-avr // AVR atmel processors compiler
sudo apt-get install avr-libc // C lib for AVR atmel processors
sudo apt-get install xorg-dev // X11 headers and libraries
sudo apt-get install libpng-dev // PNG headers and libraries
sudo apt-get install libjpeg-dev // JPEG headers and libraries
sudo apt-get install libasound-dev // Alsa headers and libraries

Tools
top // Real-time list of processes
ps // Show running processes
chmod a+rwx fileorfolder -R // Change permissions of all files to read/write recursively
dmesg // Get drivers messages
dmesg | grep tty // Get serial ports drivers messages
lsusb // Get usb devices
tail -f /var/log/messages // Similar to dmesg | tail
otool -hv library.a // Get compiled objects architecture
du -k filename // Get file size
ldd filename // Get shared libraries dependencies
find . -iname '*c' | xargs grep 'foo' -sl // search C files for the string foo

Network

nslookup address // Get the IP address of a domain name
dig address // DNS servers interrogator
traceroute / tracert address // Show the path of a packet to a certain address
ping address // Check if address is reachable
lsof -i :port // Get process using this port
 

Last update 1:47 23/12/2011