Monday, August 31, 2009

Notes on using the serial ports within python


I am using one computer for image processing (running the scanner) and another computer for film transport. The two computers both run python and can communicate over their respective serial ports. I am running python 2.5 and pyserial for this. I made a null modem cable by cutting up an old printer cable and a new 9 pin plug for the other end. A null modem requires that pins 2 and 3 be crossed. My cable uses the above pinout. The idea is that after the very first scan computer A must inform computer B to advance the film. When that is done, Computer B must tell A to scan another image. And so on. The serial port looks perfect for this. Computer B is an old "expendable" computer that I can experiment with, adding circuits to the parallel port. Whereas Computer A is my workday computer that I don't want to burn it out. That is why I am using two computers. Aside from that, there is no real advantage to using two computers.
The below code snippet show all you need to write to send data down you serial port - pretty easy.
_______________________________________
import serial
import os
ser=serial.Serial(0)
print ser.portstr # shows what port is opened
x=0
while x < 10000: #just a big loop for testing - this runs a long time
ser.write("hellowwwwww")
ser.write("\n") # new line - not sure about this!
print x
x=x+1
ser.close

__________________________________________

Friday, August 21, 2009

Film transport system notes



The film is pulled along two rails by a pin that rises from beneath. The pin is the end of spring that is driven by a solenoid. Since the pin cannot perfectly rise through a sprocket hole each try I have also placed a copper tab above the film so that when the pin hits the tab we will see a closed circuit that indicates that the pin is home and ready to pull the film. If the pin is not home we can try again by adjusting the pin position or re-firing the solenoid. The plastic rails were taken from a windshield wiper blade. The film slides through easily but there is a bit too much play. I t would be better to build rails from metal sheets so that the fit would not allow the film to shift side to side. Maybe next time! The system works well enough that I can connect it to my computer to see how it really performs under computer control.

Wednesday, August 19, 2009

Notes on using transistors as switches.

I realized I would need to take my 5 volts from data lines 2-9 and use that current through a transistor to power a solenoid or a motor or whatever else. I had never played with transistors before so here are my notes, which include the sorta intentional mistakes I made on a breadboard. I was really just playing around hoping to see how to use a PNP transistor and to see how to make it fail. I bought a pack of 15 2N3906 PNP transistors from Radio Shack for a couple of bucks. How to make a switch? From the back of the pack I identified the emitter, base and collector. I had a beginners book showing how to hook up a NPN transistor and this explained the logic of the wiring. If we consider a mere diode as having a N and P region and if we realize that a diode allows current to flow in only one direction then we might try to picture how this is occurring. One explanation I read is that the negative terminal from a 1.5 volt battery, for example, pushes or repels the electrons down the wire and rams them toward the junction where the N and P regions meet. Likewise the positive terminal of the battery would push the "holes" within the P region toward the junction so that with this arrangement we have the electrons and the holes (think of as positive) meeting at the junction and thus the electrons cross the junction or "flow", which is what we desire. Switching polarity of the battery however "draws" the electrons and holes in the opposite direction so that at the junction we can think of an empty space where current will not flow because the electrons have been pulled away from the junction. That is why a diode works in only one configuration. Now if we were to take a diode (PN regions) and add another P then we would have a PNP transistor, a sandwich of three semiconductors. But the logic of the diode above still pertains, plus there is some added behavior. By providing a second voltage source such as a 9 volt battery we can make 9 volts and a high current flow out of the transistor collector when we get a smaller current flowing in a "loop" (much as we witnessed in the diode above) through the emitter and base of the transistor. For my project I want 5 volts to control 10 volts to fire off a solenoid. The circuitry of a parallel port would burn out if we were to drive the solenoid directly but it can drive a little old transistor just fine, according to various web sites explaining this.

Here is a description of how a transistor works:
http://www.mayothi.com/transistors.html

And this page discusses using parallel ports:
http://www.epanorama.net/circuits/parallel_output.html

But what I don't know yet are many of the specs of the parts I will be using. My little solenoid (salvaged from a cassette player) draws 308 milliamps. A little motor I tried, surprisingly, drew only 195.8 milliamps until I jammed the motor and current draw rose to 280 mA. My 2N3906 was becoming hot so I checked the specs: the collector limit is only 100 mA ! So, I'll be using other transistors for my project.

Saturday, August 15, 2009

Transferring 16mm film - telecine project

I have about 20 rolls of 16mm film dating from 1949, so I figured I'd better get the film transferred to digital soon, before the images deteriorate. This blog will describe my (ongoing) project. So far I have an Epson 4490 Photo Scanner ($100 from Amazon) and I am building a film transfer system. I will be using the parallel port to send signals to a stepper motor driver (called EasyDriver $15 from Sparkfun) . I have succeeded in using Python to control the stepper so all the main elements are in place. After I acquire the images I will flipcard them to create a movie. I know only a little bit about electronics and Python but there are some good boards for help there. Since I couldn't locate a sprocket I have built a conveyance system that slides the film by means of a modded Canon scanner. Many of the parts are scrounged up from old devices. Some solenoids from a old cheapo cassette player and my transistors were just pulled from some old stereos and VCRs. This explains why some of my components are a bit off. I really didn't want to wait for parts to be shipped to me so I just built with what I had on hand, except for the breadboards and the EasyDriver for the stepper motor.