11:55:52 pm on 9/6/10
Menu
» Home
» About Scott
» VD Labs
» QRSS VD
» Old Stuff
» Archive
» Contact

Categories
» C/C++
» Circuitry
» DIY ECG
» General
» Linux
» Microcontrollers
» Molecular Biology
» My Website
» PHP
» Prime Numbers
» Python
» Radio
» UCF Lab
» Everything
Writings
» MD Labels
» Streamrip
» AIM Thoughts
» WindowsXP?
» Partitioning
» CD/DVD Repair
» Monitor Info
» CRT Deflection
» Venomcrack
» Flash Thing
» Heart/Brain
» Diabetes
» Triops
» Biomed

Friends
» Fred
» Kyle W
» Nick
» Louis
» Tom
» Kyle H




Archives
» September 2010
» August 2010
» July 2010
» June 2010
» May 2010
» April 2010
» March 2010
» February 2010
» January 2010
» December 2009
» September 2009
» August 2009
» July 2009
» June 2009
» May 2009
» April 2009
» March 2009
» February 2009
» January 2009
» December 2008
» November 2008
» October 2008
» September 2008
» September 2007
» December 2006
» August 2006
» January 2006
» August 2005
» July 2005
» June 2005
» May 2005
» April 2005
» March 2005
» February 2005
» January 2005
» December 2004
» November 2004
» October 2004
» September 2004
» August 2004
» July 2004
» June 2004
» May 2004
» April 2004
» March 2004
» February 2004
» January 2004
» December 2003
» November 2003
» October 2003
» September 2003
» August 2003
» July 2003
» June 2003
» May 2003
» April 2003
» March 2003
» February 2003
» January 2003
» December 2002
» November 2002
» October 2002
» September 2002
» June 2001

You are currently browsing the The Blogging Protagonist weblog archives for May, 2010.

Archive for May, 2010



PWM Junk in CKOUT?
Posted by
Scott May 29th, 2010 | 5,253 words | No Comments »


Scott was 24.68 years old when he wrote this!

I’m fighting with this! No matter what I do, I can’t seem to get a clear CKOUT signal as long as PWM is activated.



Measuring QRP Radio Output Power with an Oscilliscope
Posted by
Scott May 28th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

PIMP MY OSCILLOSCOPE! Yeah, see that backlight? I made it. My o-scope’s backlight hasn’t worked since I got it (for $10), so I soldered-up a row of 9 orange LEDs (I had them in a big bag) and hooked them directly up to a 3v wall wart. In retrospect I wish I had a bunch of blue LEDs… but for now I can’t get over how well this worked! Compare it to the images a few posts back – you can really see the grid lines now!oscilliscope_leds

I know this is super-basic stuff for a lot of you all, but I haven’t found a place online which CLEARLY documents this process, so I figured I’d toss-up a no-nonsense post which documents how I calculate the power output (in watts) of my QRP devices (i.e., QRSS MEPT) using an oscilloscope.qrss_qrp_circuit_scope

This is the circuit I’m trying to measure.

supply

I think I have increased power output because I’m now powering my 74HC240 from this power supply (5v, 200A) rather than USB power (which still powers the microcontroller). Let’s see!

qrss_qrp_signal

There’s the signal, and I haven’t calibrated the grid squares (this thing shifts wildly) so I have to measure PPV (peak-to-peak voltage) in “squares”. The PPV of this is about 5.3 squares.

10vSquare

I now use a function generator to create square waves at a convenient height. Using the same oscilloscope settings, I noticed that 10v square waves are about 7 squares high. My function generator isn’t extremely accurate as you can see (very fuzzy) but this is a good approximation. I now know that my signal is 5.3/7*10 volts. The rest of the math is pictured here:

powerCalcs

140mW – cool! It’s not huge… but it’s pretty good for what it is (a 2-chip transmitter). I’d like to take it up to a full watt… we’ll see how it goes. My 74HC240 is totally mutilated. I accidentally broke off one of the legs, couldn’t solder to it anymore, and thought I destroyed the chip. After getting distraught about a $0.51 component, I ripped ALL the legs off. Later I realized I was running out of these chips, and decided to try to revive it. I used a dremel with an extremely small bit (similar to a quarter-round burr in dentistry) and drilled into the black casing of the microchip just above the metal contacts, allowing me enough surface area for solder to adhere to. I’m amazed it works! Now, to get more milliwatts and perhaps even watts…

testcircuit



AJ4VD Gator Spotted in Essex, England
Posted by
Scott May 28th, 2010 | 5,253 words | No Comments »


Scott was 24.95 years old when he wrote this!

It’s so awesome that such a small device can send such a low power signal so far away! Anyhow, the title says it all. Special thanks to G6AVK’s “part time” grabber for capturing this awesome series. That’s a 4356.4 mile trip on USB power! ha!

aj4vd_gator_essex



AJ4VD Gator Chomps its way into Belgium!
Posted by
Scott May 27th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

Yeah, that’s over 4,500 miles away! The following image was captured from ON5EX’s QRSS grabber in Belgium! Amazing. I don’t have the equipment to measure its power output, but it’s running on USB power and I’d assume it’s putting out less than 100mW. Amazingly cool!

aj4vd_gator_belgium



AJ4VD Gator Spotted in MA
Posted by
Scott May 27th, 2010 | 5,253 words | No Comments »


Scott was 24.95 years old when he wrote this!

That’s over 1,00 miles on a few milliwatts! mapThe transmitter is the ridiculously simple one pictured below. I’m blown away! It was seen on running QRSS VD software! Awesome!!

gatorSeen

actual

IMG_3456



Drop-In Lowpass Filters?
Posted by
Scott May 27th, 2010 | 5,253 words | No Comments »


Scott was 24.95 years old when he wrote this!

So I’m sitting in class bored as ever and I’m sketching circuit diagrams and I wondered if I could design a primary simplest-case QRSS transmitter board with drop-in capabilities to change lowpass filters. In other words, I designed a circuit which you can drop in any crystal into and it magically transmits at that frequency, so it would make sense to have a drop-in LPF to match. This is what I came up with… I wonder how realistic this is? It would also give the ability to add different filters (3 pole, 5 pole, or more) without having to re-PCB anything.

drop_in_LPF



Measuring Coil Inductance with an MFJ Antenna Analyzer
Posted by
Scott May 26th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

With my limited resources I’m attempting to design, test, and build a minimalist QRSS transmitter. While working on the output filter, I’ve done a lot of reading and thinking and have determined that a pi filter (a 3 pole Chebyshev filter) will give me the low-pass characteristics I’m looking for to eliminate harmonics of the QRPP output.

aade_filter

This is the filter (with values and AADE-generated gain plot) I’m shooting for. It has about a 12dB reduction by the time it gets to 14m. My major goal is suppressing harmonics, but I thought I’d be polite to the 20m crew. The filter uses standard 1nF capacitors and an inductor of ~.44uH which according to this chart I can get by 12 turns around a small yellow T37-6 toroid. Although I’d like to use an air coil because of the cost savings, I’ll admit that I understand why toroids are used. That’s the filter, as modeled by AADE, software gracefully recommended to me today by David (VK2/VK6DI).

David also suggested that I not rely on standardized values, but rather measure inductance myself. While an inductance meter is out of my budget (of about $10), I was able to check-out W4DFU’s MFJ antenna analyzer, which can measure inductance. However, my readings were not as expected. In fact, with a total short (center connector directly to ground) it read a very high inductance measurement. Knowing that series inductance can be added to get total inductance, I suspected that this could still be useful. I used a T37-6 toroid I had on hand and wound it from 0-25 times, checking the inductance reading after every turn. After plotting and curve fitting, I corrected each value by subtracting the y-intercept and compared these points with those discussed in this chart and, whew! They’re a good match. To measure inductance with this meter, I have to measure inductance with the straight wire, then subtract this value from the final measurement.

how_to_measure_inductance

All right, back to work. Dental school homework is due tomorrow [rolls eyes]

update: this is the antenna analyzer I used:

analyzer

UPDATE 2 I built the proposed filter with wire randomly coiled around an unknown toroid (oh the challenge!), added a 50 ohm (51 ohm, close enough!) resistor as a dummy load, and hooked it up to the SWR analyzer. I noticed a swr minimum around 8mhz… As I unwound loop by loop, I got higher and higher… 9.15, 9.64, and finally BOOM! 10.215mhz swr 1.0. 10.140mhz swr was 1.1. I assume that a low SWR means that the filter passes maximum signal of that frequency into the dummy load, so by “tuning” this filter into a dummy load to minimize SWR by adjusting the coil at a fixed frequency, I maximized gain at that desired frequency. Here’s a photo of the completed circuit. The capacitors are “102″, 0.001uF and the toroid is unknown, but 9 turns seems best.

tuning_toroids



Pushing and Pulling
Posted by
Scott May 26th, 2010 | 5,253 words | No Comments »


Scott was 24.95 years old when he wrote this!

I found a way to quadruple the output power of my QRSS transmitter without changing its input parameters. Thanks to a bunch of people (most of whom are on the Knights QRSS mailing list) I decided to go with a push-pull configuration using 2 pairs of 4 gates (8 total) of a 74HC240. I’ll post circuit diagrams when I perfect it, but for now check out these waveforms!

qrss_amplified

First of all, this is the waveform before and after amplification with the 74HC240. I artificially weakened the input signal (top) with a resistor and fed it to the 74HC240. For the rest of the images, the input is 5v p-p and the output is similar, so amplification won’t be observed. The wave I’m starting with is the output of a microcontroller which is non-sinusoidal, but this can be fixed later with lowpass filtering.

qrss_74hc240

Here you can see the test circuit I’m using. It should be self-explanatory.

qrss_inPhase

Here’s the output of the microcontroller compared to the in-phase output of the 74HC240

qrss_out_of_phase

Here are the two outputs of the 74HC240. 4 of the gates are used to create output in-phase with the input, and the other four are used to create out-of-phase wave. Here are the two side by side. The top is 0 to 5v, the bottom is 0 to -5v, so we have a push-pull thing going on… woo hoo!

qrss_out_of_phase_overlap

The waves, when overlapped, look similar (which I guess is a good thing) with a slight (and I mean VERY slight) offset of the out-of-phase signal. I wonder if this is caused by the delay in the time it takes to trigger the 74HC240 to make the out-of-phase signal? The signal I’m working with is 1MHz.

Okay, that’s it for now. I’m just documenting my progress. 73



Solar Powered QRSS Beacon
Posted by
Scott May 24th, 2010 | 5,253 words | No Comments »


Scott was 24.66 years old when he wrote this!

Haray! I’m making awesome progress with my QRSS transmitter design. Because my current transmitter (previous few posts) was randomly freezing-up (likely due to the oscillator stopping its oscillating due to being overloaded) so I moved the oscillator from in-chip to an external oscillator. It’s been made small enough to fit in an altoids tin, and I already tested it with the solar panel and it works! Awesome! Here are some photos. Again, when I perfect the design I’ll post final schematics.

DSCN0537

DSCN0533

DSCN0539

Sticking out are wires for power and an antenna on each side. The goal is to hang the device between two trees by its own antenna.

DSCN0535

That’s my new chip development board. I made it with what I needed on it. It’s so convenient! It uses 5v of power from the USB port too!

DSCN0532

Alltogether I’ve tested the device and confirmed it transmits radio when the solar panel is illuminated. I’m thinking of making it more effective by adding more panels… but that’s it for now!



First QRSS Spot!
Posted by
Scott May 22nd, 2010 | 5,253 words | No Comments »


Scott was 24.66 years old when he wrote this!

I’m so excited! This little transmitter I made and programmed to transmit my call sign (AJ4VD) and a picture of a gator got its first spotting tonight! I’m so excited. It was reported by W4HBK in Pensacola, FL. It’s only 300 miles away, but it’s a start! I’m keeping my fingers crossed and maybe someday soon I’ll hear from Europe. Note that I *JUST* got this thing working this afternoon. I’m so excited!

spotNice

And again, here’s the transmitter in its glorious simplicity:

simple_qrss_transmitter-1



Debut of the AJ4VD QRSS Gator
Posted by
Scott May 22nd, 2010 | 5,253 words | No Comments »


Scott was 24.95 years old when he wrote this!

I re-wrote the code from the previous entry to do several things. Once of which was to make a gator rather than a fish. It’s more appropriate since I’m planning on housing the transmitter at the University of Florida. To do it, I drew a gator in paint and wrote a python script to convert the image into a series of points. I’ll post it later. One thing to note was that size was a SERIOUS issue. I only have two thousand bytes of code, and every point of that gator was a byte, so it was a memory hog. I helped it dramatically by using repeating segments wherever possible, and some creative math to help out the best I could (i.e., the spines on the back) Here’s what it looks like, and the code below it…

aj4vd_gator

#include <avr/io.h>
#include <util/delay.h>

// front top LED - PA0
// inside top LED - PA1
// inside bot LED - PA2
// front bot LED - PA3

unsigned long int t_unit; // units of time
const int tDit = 100; //units for a dit
const int tDah = 255; //units for a dah
char fsk; // degree of frequency shift to use for CW
char fsk2; // degree of frequency shift to use for HELL

char light = 0; // which lights are on/off

void delay(){
        _delay_loop_2(t_unit);
        }

void blink(){
	return;
	if (light==0){
    	PORTA|=(1<<PA0); //on
    	PORTA|=(1<<PA1); //on
		PORTA&=~(1<<PA2); //off
		PORTA&=~(1<<PA3); //off
		light=1;
	} else {
    	PORTA|=(1<<PA2); //on
    	PORTA|=(1<<PA3); //on
		PORTA&=~(1<<PA0); //off
		PORTA&=~(1<<PA1); //off
		light=0;

	}
}

void tick(unsigned long ticks){
        while (ticks>0){
                delay();
                delay();
                ticks--;
        }
}

void pwm_init() {
    //Output on PA6, OC1A pin (ATTiny44a)
    OCR1A = 0x00; //enter the pulse width. We will use 0x00 for now, which is 0 power.
    TCCR1A = 0x81; //8-bit, non inverted PWM
    TCCR1B = 1; //start PWM
}

void set(int freq, int dly){
        OCR1A = freq;
        tick(dly);
}

void fish(){
	char mult = 3;

	char f2[]={2, 3, 4, 5, 6, 7, 4, 3, 7, 4, 7, 7, 6, 5, 4, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 4, 5, 6, 7, 8, 4, 9, 5, 9, 6, 9, 6, 9, 6, 9, 8, 8, 7, 7, 6, 5, 4, 3, 3, 3, 4, 5, 5};

	for (int i=0;i<sizeof(f2);i++) {
		OCR1A = f2[i]*mult;
		blink();
		tick(20);
		OCR1A = 1*mult;
		blink();
		tick(20);
		}

	char f3[]={1,2,3,4,3,2};

	char offset=0;
	while (offset<9){
		for (char j=0;j<3;j++){
			for (char i=0;i<sizeof(f3);i++){
				char val = (f3[i]+5-offset)*mult;
				if (val<mult || val > 10*mult){val=mult;}
				OCR1A = val;
				blink();
				tick(20);
				OCR1A = 1*mult;
				blink();
				tick(20);
				}
			}
		offset++;
	}

}

void id(){
        char f[]={0,0,1,2,0,1,2,2,2,0,1,1,1,1,2,0,1,1,1,2,0,2,1,1,0,0};
        char i=0;
        while (i<sizeof(f)) {
                blink();
                if (f[i]==0){OCR1A = 0;tick(tDah);}
                if (f[i]==1){OCR1A = fsk;tick(tDit);}
                if (f[i]==2){OCR1A = fsk;tick(tDah);}
                blink();
                OCR1A=0;
				tick(tDit);
                i++;
                }
}

void slope(){
        char i=0;
        while (i<25){
                OCR1A = 255-i;
                i++;
        }
        while (i>0){
                i--;
                OCR1A = 255-i;
        }
}

int main(void)
{
        DDRA = 255;
		blink();
        pwm_init();
        t_unit=1000;fsk=10;id(); // set to fast and ID once
        //fsk=50;//t_unit = 65536; // set to slow for QRSS
		t_unit=60000;

        while(1){;
                fish();
                id();
        }

        return 1;
}


Debut of the AJ4VD QRSS Fish
Posted by
Scott May 19th, 2010 | 5,253 words | 1 Comment »


Scott was 24.65 years old when he wrote this!

Finally! After a few years tumbling around in my head, a few months of reading-up on the subject, a few weeks of coding, a few days of bread-boarding, a few hours of building, a few minutes of soldering, and a few seconds of testing I’ve finally done it – I’ve created my first QRSS transmitter! I’ll describe it in more detail once I finalize the design, but for now an awesome working model. It’s ~100% digital, consisting of 2 ICs (an ATTiny44a for the PWM-controlled frequency modulation, and an octal buffer for the preamplifier) followed by a simple pi low-pass filter. I don’t want to waste time typing – let’s show some pics!

qrss desk

My desk is a little messy. I’m hard at work! Actually, I’m thinking of building another desk. I love the glass because I don’t have to worry (as much) about fires. Scary, I know…

qrss transmitter

This is the transmitter. The box is mostly empty space, but it consists of the circuit, an antenna connection, a variable capacitor for center frequency tuning, and a potentiometer for setting the degree of frequency shift modulation.

qrss fish

AMAZING! Yeah, that’s a fishy. Specifically a goldfish (the cracker). It’s made with a single tone, shifting rapidly (0.5 sec) between tones. So cool. Anyway, I’m outta here for now – getting back to the code! I think I’ll try to make a gator…

As it is, here’s the code. It sends my ID quickly, some fish, then my ID in QRSS speed using PWM. You can figure out the pinout… I’ll document it with circuit diagrams soon!

#include <avr/io.h>
#include <util/delay.h>

const int tDit = 270/3;
const int tDah = 270;

char fsk;
unsigned long int t_unit;

void delay(){
	_delay_loop_2(t_unit);
	}

void blink(){
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
  	PORTA^=(1<<2);
  	PORTA^=(1<<3);
}

void tick(unsigned long ticks){
	while (ticks>0){
		delay();
		delay();
		ticks--;
	}
}

void pwm_init() {
    //Output on PA6, OC1A pin (ATTiny44a)
    OCR1A = 0x00; //enter the pulse width. We will use 0x00 for now, which is 0 power.
    TCCR1A = 0x81; //8-bit, non inverted PWM
    TCCR1B = 1; //start PWM
}

void set(int freq, int dly){
	OCR1A = freq;
	tick(dly);
}

void fish(){
	char f[]={0,0,0,4,5,3,6,2,7,1,5,6,8,1,8,1,8,1,8,1,8,2,7,3,6,2,7,1,8,1,8,4,5,2,3,6,7,0,0,0};
	char i=0;
	while (i<sizeof(f)) {
		i++;
		OCR1A = 255-f[i]*15;
		blink();
		tick(20);
		}
}

void id(){
	char f[]={0,0,1,2,0,1,2,2,2,0,1,1,1,1,2,0,1,1,1,2,0,2,1,1,0,0};
	char i=0;
	while (i<sizeof(f)) {
		blink();
		if (f[i]==0){OCR1A = 255;tick(tDah);}
		if (f[i]==1){OCR1A = 255-fsk;tick(tDit);}
		if (f[i]==2){OCR1A = 255-fsk;tick(tDah);}
		blink();
		OCR1A = 255;tick(tDit);
		i++;
		}
}

void slope(){
	char i=0;
	while (i<25){
		OCR1A = 255-i;
		i++;
	}
	while (i>0){
		i--;
		OCR1A = 255-i;
	}
}

int main(void)
{
	DDRA = 255;
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
	pwm_init();

	t_unit=2300;fsk=50;id(); // set to fast and ID once

	fsk=50;t_unit = 65536; // set to slow for QRSS

	while(1){
		id();
		for (char i=0;i<3;i++){
			fish();
			}
	}

	return 1;
}


Simplest QRSS Transmitter Ever!
Posted by
Scott May 17th, 2010 | 5,253 words | No Comments »


Scott was 24.64 years old when he wrote this!

Success! Amid the plethora of exams, psycho-motor tests, and other crazy shenanigans my dental school is putting me through, I managed to do something truly productive! Check it out. I built a simplest-case QRSS transmitter with an ATTiny44a micro-controller clocked by a 7.04mhz crystal which generates FSK signals and modulates its own frequency by applying potential to a reverse-biased diode at the base of the crystal, the output (CKOUT) of which is amplified by an octal buffer and sent out through an antenna. As it is, no lowpass filtering is implemented, so noisy harmonics are expected. However for ~2$ of parts this is a pretty sweet transmitter!

simple_qrss_transmitter

I was able to detect these signals VERY strongly at a station ~10 miles from my house. I haven’t yet dropped in a 10.140mhz crystal and tried to get this thing to transmit in the non-official QRSS band, but when I do I hope to get reports from all over the world! This is what it looks like:

aj4vd

The cool thing about this transmitter (aside from the fact that it’s so cheap to build) is that it will work with almost any crystal (I think below 20MHz-ish) – just drop it in the slot and go!



Generate LUTs with Python
Posted by
Scott May 10th, 2010 | 5,253 words | No Comments »


Scott was 24.63 years old when he wrote this!

Everyone’s favorite slacker hacked together a script to not only generate, but also thoroughly document equation-based LUTs (look up tables) with Python. There’s been a lot of heated discussion in the QRSS Knights mailing list as to the use of color maps when representing QRSS data. I’ll make a separate post (perhaps later?) documenting why it’s so critical to use particular mathematically-generated color maps rather than empirical “looks good to me” color selections. Anyway, this is what I came up with:

Blin_Glin_Rlin_scale

For my QRSS needs, I desire a colormap which is aesthetically pleasing but can also be quickly reverted to its original (gray-scale) data. I accomplished this by choosing a channel (green in this case) and applying its intensity linearly with respect to the value it represents. Thus, any “final” image can be imported into an editor, split by RGB, and the green channel represents the original data. This allows adjustment of contrast/brightness and even the reassignment of a different colormap, all without losing any data!

ORIGINAL DATA:Blin_Glin_Rlin.jpg (green)
(that’s the “flying W” and the FSK signal below it is WA5DJJ)

LINEAR COLORMAPBlin_Glin_Rlin_graph

RESULTING IMAGEBlin_Glin_Rlin

Note that it looks nice, shows weak signals, doesn’t get blown-out by strong signals, and it fully includes the noise floor (utilizing all available data).

BLUE CHANNEL: weak signals / noise floorBlin_Glin_Rlin.jpg (blue)

RED CHANNEL: strong signals / no noiseBlin_Glin_Rlin.jpg (red)

GREEN CHANNEL: original data!!!Blin_Glin_Rlin.jpg (green)

But what about sinusoidal curves?Bsin_Glin_Rsin_graph

They look okay, but not as great as linearBsin_Glin_Rsin

DOWNLOAD LUTs

The following links are downloadable LUTs which can be applied to 8-bit grayscale images using most editors (i.e., MBF ImageJ) generated by the python script below.
Linear LUT
Sinusoidal LUT

This is the Python script I wrote to generate the downloadable LUTs, graphs, and scale bars / keys / legends which are not posted. It requires python, matplotlib, and PIL.

import math
import pylab
from PIL import Image

####################### GENERATE RGB VALUES #######################

r,g,b=[],[],[]
name="Blin_Glin_Rlin"
for i in range(256):
    if i>128: #LOW HALF
        j=128
        k=i
    else: #HIGH HALF
        k=128
        j=i
    #b.append((math.sin(3.1415926535*j/128.0/2))*256)
    #r.append((1+math.sin(3.1415926535*(k-128*2)/128.0/2))*256)
    r.append(k*2-255)
    g.append(i)
    b.append(j*2-1)

    if r[-1]<0:r[-1]=0
    if g[-1]<0:g[-1]=0
    if b[-1]<0:b[-1]=0

    if r[-1]>255:b[-1]=255
    if g[-1]>255:g[-1]=255
    if b[-1]>255:b[-1]=255

####################### SAVE LUT FILE #######################
im = Image.new("RGB",(256*2,10*4))
pix = im.load()
for x in range(256):
    for y in range(10):
        pix[x,y] = (r[x],g[x],b[x])
        pix[x,y+10] = (r[x],0,0)
        pix[x,y+20] = (0,g[x],0)
        pix[x,y+30] = (0,0,b[x])
        a=(g[x]+g[x]+g[x])/3
        pix[256+x,y] = (a,a,a)
        pix[256+x,y+10] = (r[x],r[x],r[x])
        pix[256+x,y+20] = (g[x],g[x],g[x])
        pix[256+x,y+30] = (b[x],b[x],b[x])
#im=im.resize((256/2,40),Image.ANTIALIAS)
im.save(name+"_scale.png")

####################### PLOT IT #######################
pylab.figure(figsize=(8,4))
pylab.grid(alpha=.3)
pylab.title(name)
pylab.xlabel("Data Value")
pylab.ylabel("Color Intensity")
pylab.plot(g,'g-')
pylab.plot(r,'r-')
pylab.plot(b,'b-')
pylab.axis([-10,266,-10,266])
pylab.subplots_adjust(top=0.90, bottom=0.14, left=0.1, right=0.97)
pylab.savefig(name+"_graph.png",dpi=60)
#pylab.show()

####################### SAVE LUT FILE #######################
f=open(name+".lut",'w')
out="Index\tRed\tGreen\tBlue\n"
for i in range(256):
    out+=("\t%d\t%d\t%d\t%d\n"%(i,r[i],g[i],b[i]))
f.write(out)
f.close()
copyright © 2006 swharden@gmail.com