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

Saturday, 26 February 2011

AutoBFont

AutoBFont is small tool for text rendering on OpenGL(and can be easily ported to DX) with bitmap fonts, providing a way to draw perfectly aligned text with bitmap sheets created in Fireworks/Photoshop/Gimp and Inkscape. The tool is composed by two parts : an generator and a loader class.

The monospace font with and without a drop shadow(effect created in Inkscape) rendered with the help of autobfont
The generator computes each character limits from the character sheet bitmap, which should be a RGBA TGA image with no compression. It should have 16 columns by 16 rows to fill with characters and the size of the image should be power of 2 (1024x1024 for example). If only the first 8 rows are used, the remaining rows can be used to fit a "bold" version of the font.

The generator program requires 3 mandatory arguments :
-i CHARACTER_CONVERSION_MAP.TXT 
-m CHARACTER_BITMAP_SHEET.TGA
-o OUTPUT_MAP.TXT
Optional arguments :
-b Compute the Bold characters in the last 8 rows.
-h VALUE  Set all characters line height (the default value is 3*CELL_SIZE/4).
-t VALUE Set alpha threshold value, improves character boundaries detection (default value is 50, max is 255).

The conversion map is a text file with the ASCII character for each cell in the bitmap sheet, although it's limited to Latin characters, the generator and loader can be changed to use wchar_t structure instead of char for other languages such as japanese. All the characters in the bitmap font should by white (if you want to use color blending in OGL, but isn't mandatory) with a background transparent (below the alpha threshold value).

The loader class is available in the demo.cpp class, which loads the generated output map and the renders the characters with OpenGL.

To convert the SVG to TGA use gimp with no RLE compression and  bottom left origin.

The typical commands to compile and run the generator and demo on linux:
make
./generator -i ct_PT.txt -m font_ubuntu.tga -o font_ubuntu_map.txt
./demo font_ubuntu_map.txt font_ubuntu.tga

DOWNLOAD

Tuesday, 8 February 2011

Logotype

Ok, a little explanation about the logo I finished recently.

For me the demoscene "thing" started around the year 1992 before i even understood what the heck "demoscene" meant or had any skills to do anything with computers beyond playing games. Back then my sister had received her first computer, a 486DX with 4MB of RAM. After some months she got some games from her friends and some of them included some cracktro apps, which back then where a confusing concept for me, since they had no propose beyond showing the artwork and moving letters plus some audio.

NapalmCore logo created with Blender 2.56
The first cracktro i saw was the TEKNO SKULL by TDT / TRSi, which impressed me since I was a little kid and had a particular fear of skeletons. In the course of the time, with the influence of the cyberpunk culture in animes and movies from the 80's & 90's, the fear was lost and this goreish characteristic remained as a symbol from those years and the culture it self.

The logotype creation started back then at the Euskal 2008 for the 3D competition, at the time it only featured the skull. Recently i decided to recycle the model, remaking the skull with better detail and adding the extra details, such as the mechanical stuff and the sun glasses. I also was inspired by latest razor 1911 prods which have an unique new-old-school style, mimicking the 90's hardware with the latest graphics effects, for example, the grid pattern effect can be seen on the "StarCraft 2 cracktro" or the "Pirates of the 777 seas". The sunglasses are due to the influences of Motoko Kusanagi from the ghost in the shell :)

With this, i can finally conclude by saying that the name of this blog/website/demoscene group reflects the unique cyberpunk culture from the last years of the 20 century, plus the cracking culture which evolved to the demoscene which we have currently.

Saturday, 15 January 2011

DIY Pseudo "iMac"

This was the situation : I have an laptop (HP-DV5000) with 5 years which still works pretty well apart from the broken LCD, which was due it had already been at Breakpoint, Inercia, Euskal and almost all the college period in my backpack. So the LCD started to show some weird vertical coloured lines which would require a new LCD, which is almost the price of a new laptop...
After i started my current job, which is purely macintosh based, i noticed the iMac where actually an interesting concept to keep all the cables inside the computer. So i though maybe i can do something similar to my old laptop !

The basic idea was to mount the laptop behind an LCD monitor, my monitor (Sony SDM-S93) had a sliding plate behind which helped to mount the metal holder bars. After that I only needed some sort of electronic connection to power up the laptop, since the power button would be hidden under the lid. 

The electronic circuit consists in a relay which is activated when we press the front power/iddle button in the monitor, the relay acts as the power switch of the laptop. I could have connected directly the two switches, but that wouldn't be very safe and healthy for both the devices. The circuit steals 12V from the monitor PSU, which is always available whatever the current state(idle or on). On idle state the available current is very low, because the PSU switching circuit is working at a very small duty cycle to use less mains power, so the laptop switching circuit must be power efficient.

Monitor PSU and control circuit plus my circuit in the breadboard The compact version of the laptop switching circuit

After building the circuit I only needed to add some cables to the laptop which would intercept the power button signal, using my trusty Dremel i drilled a path through the plastic and used the hole of one screw to pass the cables. The cables end with a male conector to help mount and unmount the laptop from the suport, or even still use the laptop .. as a laptop :)

Drilled path to pass the cables
The end result isn't a iMac, but still, I managed to recycle old hardware to create a new "computer" which manages to accomplish all my current needs (Blender, development, office and minecraft :P). It was still has some issues due to idle/on/off state of monitor, when it's on iddle mode and we press the power button, it powers up the laptop and powers down the monitor (iddle->off), but pressing it again it powers up the monitor without powering down the laptop. I could easily fix this by intercepting also the monitor power switch and with some extra logic, but for now it's enough ! 

Back view Front view