Studio Contrechoc

design & textile & technology entries

Monthly Archives: February 2010

POV Experiment

For the kids the persistence of vision phenomenon is always nice to wonder about. So I want to make it part of a small lecture on the speed of light…(or over the speed of light!).

In principle POV is very simple: make a row of LEDS go bright and dark very fast, in a certain pattern. Move the LED-row in the air. The eye, because of its finite refreshment of the cells responsible for detecting the light will make a pattern of the LEDS flashing.

The ATmega168 has a clock speed that fits, all we need to do is program the LEDS, and make certain the resistors are well chosen.

Although really simple, there is even a kit at this address:
http://www.ladyada.net/make/minipov3/download.html

and here you can find the gcc code too, which makes life even more simple.

This code is for the ATTINY2313 and I wanted to do it for the ATmega168. Not much difference except for the name of the timer, because there are more timers on the mega168:
ATTINY has TIMSK (timermask) and the mega168 has TIMSK1,
so
TIMSK1 |= 1 << OCIE1A; instead of
TIMSK |= 1 << OCIE1A;

then you have to change in the code also the interrupt vector:
SIGNAL( TIMER1_COMPA_vect ){ instead of
SIGNAL( SIG_TIMER1_COMPA ) {

since it was easier on the D port (the B port on the mega being rather dispersed) this was also changed:
DDRD = 0xFF; // set all 8 pins on port B to outputs

The data sheet of the attiny2313 and the atmega168 didn’t explain about the catching of the interrupt, that info had to be found in the AVR interrupt header. Explanation of that was found here:
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

At first all was on the breadboard, I want to find a way of showing me programming the chips over and over again, so changing the text and the POV patterns. I have to find out the nicest way of making a more permanent reprogrammable board.

Another method is preparing for different text and patterns in one code and alternating between the different texts with a button…

Since the mega168 is huge, one text only taking up just 2.5 percent of memory, storing 30 text lines should be no problem at all.

In this lecture for the local astronomy kids I presented faster than light phenomena in the universe and combined this geometrical talk with the POV. I programmed the name of the child in his bike, (only forgetting a space after his name so it comes out continuously …):

His name is “Wessel”….
I had to program my own 8 bits high bitmap font and I did that with FLASH, using the trace (in output window) to export my bits in the right format:
Output like this:
B8(11000000),
B8(00000011),
B8(00001100),
B8(00110000),
B8(11000000),
B8(00000011),
B8(00001100),
B8(00110000), which can be pasted in the sourcefile of this avr project:
This is the link to the avr project (with complete binary bit alphabet to be copied and pasted around 🙂

For the bike I sewed the board on cloth, also making a nice pocket for the batteries. I can program names of kids using the programmer and the connectors.
The speed is 16000 Hz, provided by the crystal, the fuses are at full swing.

Advertisements

Linux Ubuntu…serial things

Being relatively new to linux and having a double boot on my MACBOOK, MACOS and XP, I configured finally an old laptop with Ubuntu 9.10.

Then using the Synaptic I installed the python things I needed: numpy and scipy. I had to install ImageTK too to run cad.py.

then get nearer to the serial ports:
using synaptic you can install setserial.

(is this really needed? Later I found sstty:
http://tldp.org/HOWTO/Serial-HOWTO-12.html#stty_ )

then I found this link:
http://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/

usefull commands are (in the terminal window):
sudo chmod 777 fileName to give all rights to fileName, asking for the admin or root password

then listing the ports:
ls /dev/tty*

then
$ dmesg | grep tty
like in the linked page, this gives info on tty0

returning to setserial:
setserial -g /dev/ttyS[012345] (“info about how the device driver is configured for your ports”)
give a list of possible ports… not so much as ls /dev/tty* because these are not physical ports.
setting the portspeed…i still have to find that one.

Back to stty:
stty -a immediately gives the portspeed
$man stty gives the control possibilities:
“number      Set terminal baud rate to the number given, if possible.  If
the baud rate is set to zero, modem control is no longer
asserted.”

which means setting to 9600: stty 9600
% stty -F /dev/ttyUSB0 57600 for the specified port

For the rest I found this page: talking to the arduino ( apparently a virtual serial port)
http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/

From this I read something about “screen”, to get the serial data from arduino/atmega
$ screen /dev/ttyUSB0 57600 opens a port a that indicated speed

http://embeddedfreak.wordpress.com/2008/08/12/using-gnu-screen-to-debug-your-serial-port/

http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml

this is a useful page for starters with linux like me…:
http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

about file permissions:
https://help.ubuntu.com/community/FilePermissions

related: terminal commands and examples for MACOS: http://ss64.com/osx/
This helped me with a locked USB stick (read only)
in the terminal: diskutility eraseDisk UFS UntitledUFS disk1
after you have found the “disk1” with (in the terminal):diskutil list

now on MACOS there is “the same” terminal. Here is a link to all the commands:

http://ss64.com/osx/