Fluidity Experiment

Today, I started this new experiment of making things look fluid. The problem with fluid simulations is that they take a lot of computation and requires over-the-top mathematics which I am not familiar with. Thus I started making program that would simply make things look fluid, with simplest computation possible. My AVS preset making skills finally paid off, and I was able to incorporate some fluidity in my screen, as you can see in the video,

This Processing sketch (Program) makes this circles look like parts of an viscous somewhat like electrically charged fluid, with the mouse cursor be a controlled electrode. It was fun to code, tweaked the functions and the parameters to make the whole thing look nice and perfect in my computer. Different computer will give differently timed outputs as the program is not constrained with time. It will run independently on the systems’ resources.

The sketch can be downloaded from here (Fluidity.rar). I have this bad habit of not commenting while coding, and be too lazy for commenting in the end. This is my first processing sketch where I used custom classes for better coding. I found out that with classes I can make stuff with significantly less complex code, obviously at the cost of performance I guess.

It would be better if I could do this with OpenFrameworks, would get a lot more speed. I will do that someday, but for now I am satisfied with Processing. Its’ built in random number generator. I will further enhance the fluid function that drives the fluid mechanics of the circles and maybe able to get a nicer effect of fluid. Also I would like to use Computer Vision to interact with this fluid with webcams and hands.

Numeric Patterns Part 1

I was exploring this idea of data painting, which is much like data visualization without being ‘meaningful’ essentially. I started with an idea of determining the simplicity of the number in term of remembering the number.

I started with a simple algorithm which would reflect the randomness of the sequence of numbers, which in turn would tell the viewer that the number is easily memorized or not. I started to work with Processing. Parsing numbers that is written on a text file.

Getting a suggestion from a friend, I decided to color the lines, but I always get in trouble coloring stuff with random number. He gave me the answer, BORDERS. And that was it, I changed and tweaked the program, added a few borders and that was it. The next picture is of my number again, colored. The color is decided by the last 6 digits of the number.

The idea is simple. The point starts from an arbitrary position. The program checks the next digit, and compares it with the current digit. The slopes in various places on the pattern indicate either the next number is greater, less or equal with the current number.

For example, let’s consider the number, 12537043332. For this number, the pattern is,

If you look at the details (from left) we will see that the 1st digit is smaller that 2nd, and there is a positive slope. Like wise, the first negative slope indicates 5 and 3. The string ‘333’ is indicated by that long straight near the end of the number.

Here are a few patterns that I generated.

There is a glitch with the co-ordinate system. Was being too lazy to fix that!

Here the link to the Processing sketch in Zip Files. The input should be a text file named ‘data.txt’ in the same folder containing the numbers with one number in a line (for the no name version). There is also another one designed to generate patterns from phone numbers with names. For that, do also put your name left to the phone number in ‘data.txt’. The outputs will be in GIF format in the sketch folder. Ignore the file names, my initial plan was reflected in the file names.

‘Custom function’ generator

Initially I planned to make a custom function generator which will be able to store waveforms, can be interfaced with computers, can be self contained, with a LCD as the UI, and would be able to produce bipolar waveforms with adjustable amplitudes and frequencies.

My first trial went in the attempt of running a 128×64 graphic LCD module with a PIC18F4550. After a little experimentation and brainstorming I realized that PIC18F4550 didn’t have enough RAM to run the display routines and generate the functions, let alone interfacing with the computers. I stopped trying,

A few days after my first failure of running the Graphic LCD module I learned about this emulated USB-serial library from Microchip. I thought it would be very cool when I will interface with the computers. From the start the PIC architecture scares me a little. Maybe that is because I am more accustomed with AVRs.

Few days ago I got this AVRISP mkII from Atmel and I started to work on the function generator. First I wrote a Processing sketch that would be used to ‘paint’ the waveforms. When the painting program was done, I started to rummage samples of DACs I got as samples from Texas Instruments. I find their service of samples really helpful for students like me.

I settled with the DAC TLC7226, it’s a quad DAC with 8-bit input. Has unipolar operation and can work in latched and transparent mode. After looking at the Datasheet I started wiring the DAC with an ATmega8 on breadboard. Within a few minutes I could get analog signals in my DSO nano.

Then I thought of bipolar signalling, although I left the electrical circuit part for unipolar to bipolar conversion for later, I started writing the AVR firmware for bipolar signalling with adjustable frequency which will be adjustable from the PC with UART communication line.

After I  coded a little, I started to test processing with the Bluetooth modem I had with me. I found out that it’s really a hassle free serial cable replacement but it won’t work with Processing. After a lot of tweaking the Processing IDE, I slid in the ExpressCard which adds Serial(RS-232) and Parallel port to my laptop and used my old custom made MAX232 board.

Then I started to code Processing sketch and the firmware almost simultaneously, trying to make a serial communication work. After an evening of bugging and debugging, I decided to strip down features and make a simple unipolar fixed frequency signal generator. After a while I was having trouble with the serial communication and found out that the problem was the slowness of the AVR and the speed of the PC. Even if I get the bauds right, the UART buffer in AVR is pitifully small and cannot handle all the bytes sent to it, so I added delay to the serial transmission from the PC. After getting the delays right, I found trouble in managing the UART routines in AVR. I decided to use interrupts with flags and got it done!

Ultimately I got the thing running and updating waveforms that was given from the PC. Then I added this frequency adjustment feature and I was at my first version.

This is the hardware on breadboard, and my custom breadboard AVRISP 6-pin programming header above. 🙂

Here’s the waveform generated, shown in DSO nano v2 running BenF firmware.

The circuit schematic is pretty simple I didn’t bother to document that. The AVR C (compiled with AVRGCC) code has all the necessary descriptions.

I uploaded the AVR Studio 5.0 project file and the processing sketch. Click here to download.

I couldn’t manage to get to higher frequencies, maybe with better designed routines I can push it a little more. My next stop would be to extending this function generator, with bipolar signal generation, amplitude control etc. For the the project is shelved. I have other things in mind.

Two waveforms and there DSO captures,

IDRays: An experiment with data presentation

Inspired by MIT Media Labs Identity I decided to make something that can be related to individuals. After a few minutes of thought I decided to relate the pattern with the persons’ name, his/her age, and his/her phone number. I wrote a processing sketch and I made some images from datasets related to some of my friends. And these are the images I made.

Most of the tweaks went into making the whole color scheme look good. The length of the lines are related to the ASCII codes of the characters of the persons’ name; Age and phone number is related with red and green colors of the lines and the circle inside by virtue of a linear mathematical expression. 🙂

Here is the link to the processing sketch.

Low pass filtering experiment…

I was trying to explore the realms of filtering, but didn’t a get a neat way to get into it. Then one day, I thought about this eased sloshy movement that I always wanted to achieve when I used to make AVS visualisations in Winamp. If you don’t know about AVS, check it up. It’s one of the coolest Music Visualization System, and with a pretty steep learning curve. I learned to use that when I was 16 years old. Was a co-ordinate geometry buff at that time. There are some of my AVSes at deviantArt. If you have WinAmp with AVS, you can check them out.

It suddenly came to me that low pass filtering might just be able to produce an easing effect. And that was it. Processing came handy and I implemented a moving average filter where the dot co-ordinates are simply low-passed mouse co-ordinates.

Helped me visualizing filtering.

The processing code.

P.S. Processing is a nice neat programming language based on Java that can be used as a graphical programming language. If you haven’t already did it, do check it out.