Tuesday, October 13, 2009
Hacking an old joystick for data input - pygame
Having switched to a different computer (1.2 megahertz cpu) from which to run Ubuntu and python 2.5 I lost my parallel port capability, where I had hoped to read potentiometer values for data input. However, by pulling the board out of an old Interact joystick (USB) and using pyame, I can easily read resistance changes in the pots through the USB port, which is okay too. The idea is to sense light passing through film sprocket holes to ascertain film position relative to the dragging pin (which pulls the film along). I've played with a UV diode pulled from an old VCR and the sensor varies its resistance when exposed to the UV light. I hopes to simply place this sensor in series with the potentiometer now in the joystick circuit.
Sunday, September 13, 2009
Notes on reading a switch position
Notes on reading a switch position (a physical switch in the real world) using pin 10:
Shorting pin 10 to pin 25 (with a resistor preferably) will change a signal from True (in python) to False. In python using i=getInAcknowledge() I can get i, a variable, to be true or false as I stick a wire between pins 25 and 10 (but use a resistor). Using a variable resistor I determined that about 3500 to 4000 ohms should work. This fits the circuits you see on the web that recommend - usually 3.7 K ohms. Would using no resistor burn out the port? Hmmm, well pin 11 went a bit flakey when I tried it. I may have damaged the pin 11 line because now it always reads False. I did try pin 10 with no resistor for just an instant and no damage was done. I'll install a resistor, though.
Pin 10 is nACK and in not inverted according to web sources
The link to python info is here:
http://pyserial.sourceforge.net/pyparallel.html#examples.
Here is some of the info:
setData(value)
Apply the given byte to the data pins of the parallel port.
setDataStrobe(level)
Set the “data strobe” line to the given state.
setAutoFeed(level)
Set “auto feed” line to given state.
setInitOut(level)
Set “initialize” line to given state.
getInSelected()
Read level of “select” line.
getInPaperOut()
Read level of “paper out” line.
getInAcknowledge()
Read level of “Acknowledge” line. - so this is my pin 10.
Here is a pinout:
. .
The pinout came from http://www.probotix.com/manuals/PBX-2_manual.htm
And it looks like they sell a Breakout Board solution so you would not need to fool around with much electronics when interfacing the parallel port. I wanted to learn more about electronics, so I built my own circuits.
Model: PBX-2
Breakout Board Specs:
* DB25 Female
* All Pins Brought Out
* Jumper Enabled Input Pull-up Resistors
* Integrated 5V Logic Supply Regulator
* PROBOTIX Pinheader & Screw Clamp Terminals
* Experimental USB Powered Logic Supply
Movie showing transport system working
This little movie shows the white leader film being pulled along by the pin, which is probably impossible to see. Using a spring, the pin rises up into a sprocket hole when the solenoid is not fired. Firing the solenoid lowers the pin so that the pin assembly can move backwards without dragging the film back with it. This cycle ultimately will drag an entire reel of film over my scanner bed. The copper tab presses the film down so the pin can reach through the plane of the film. (Since there is too much slop in my improvised film rails built from windshield wiper blade spines.) When the metal pins touches the copper I will read this as "pin engaged" through the parallel port and that would mean that it is okay to start advancing the film. Otherwise, the pin might be stuck when it hits the film where there is no sprocket hole. By determining whether the pin is "engaged" I can ascertain a start position (call it zero) so that by using the stepper steps I can precisely advance the film a known distance (eg., 500 steps distant from the zero position.) Then I can back up the film a few steps if need be. The metal parts are mainly Erector set parts that had lying around the house. Erector sets are perfect for prototyping robots. The pin assembly is attached to the metal bed where there was once a scanner assembly. As I built this I was wondering if the motor could really pull a strip of film along, and it can. But if the film hangs up, the entire bed gets pulled upwards as it tries to drag the stuck film. The film was only hanging here because I didn't have a spacer to keep the scanner lid fully away from the film. I guess it is time to add a take-up reel!
Here is the url of the movie, posted to photobucket:
http://smg.photobucket.com/albums/v241/pixhopwow/?action=view¤t=MOV07480.flv
Here is the url of the movie, posted to photobucket:
http://smg.photobucket.com/albums/v241/pixhopwow/?action=view¤t=MOV07480.flv
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.
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.
Subscribe to:
Posts (Atom)