Thursday, September 21, 2023

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&current=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.